Skip to content

Comments

On activated tab listener#18

Merged
marija04 merged 5 commits intomainfrom
onActivated-tab-listener
Jul 14, 2025
Merged

On activated tab listener#18
marija04 merged 5 commits intomainfrom
onActivated-tab-listener

Conversation

@marija04
Copy link
Contributor

@marija04 marija04 commented Jul 9, 2025

No description provided.

@marija04 marija04 requested a review from erik-beus July 9, 2025 09:51
Copy link
Contributor

@erik-beus erik-beus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see suggestions

const url = new URL(urlString)

if (
url.host.endsWith('toddle.dev') === false &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually remove all references to the toddle.dev hostname now, as the editor is no longer served on that domain 👍 You might want to include -toddle.toddle.site though to make sure the extension works for preview branches of the editor project? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remind me why we would like to run this on the preview branches? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's useful to have the same experience of the browser extension regardless of which version of the editor you're running?


if (
url.host.endsWith('toddle.dev') === false &&
url.host.endsWith('nordcraft.com') === false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be 'editor.nordcraft.com'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are checking the endsWith it should work form the editor.nordcraft.com as well.

requestUrl: info.url,
setCookie: (cookie) => browser.cookies.set(cookie),
setCookie: (cookie, domain) => {
if (!domain?.endsWith('.toddle.site')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting an error in the extension that is not possible to set a cookie for a domain that has no permission.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense 👍 Perhaps you could also add in support for .nordcraft.site so we're ready for when that's possible?

Comment on lines 101 to 105
const cookies = await chrome.cookies.getAll({ domain })

if (cookies.length > 0) {
await updateSessionRules({ domainCookies: cookies, RULE_ID })
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems some of this code is the same as in the onBeforeNavigate listener above. Perhaps you could put the shared code in a function? The code that sends information about the cookies to the editor in the onBeforeNavigate listener might also be relevant for when a tab receives focus?

@marija04 marija04 requested a review from erik-beus July 9, 2025 12:51
Copy link
Contributor

@erik-beus erik-beus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see suggestion


if (
url.host.endsWith('nordcraft.com') === false &&
url.host.endsWith('-toddle.toddle.site')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url.host.endsWith('-toddle.toddle.site')
url.host.endsWith('-toddle.toddle.site') === false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈

return false
}

// Get the cookies for the .nordcraft.site domain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get the cookies for the .nordcraft.site domain
// Get the cookies for the .toddle.site domain

@marija04 marija04 requested a review from erik-beus July 11, 2025 08:20
erik-beus
erik-beus previously approved these changes Jul 11, 2025
@marija04 marija04 merged commit 67da214 into main Jul 14, 2025
1 check passed
@marija04 marija04 deleted the onActivated-tab-listener branch July 14, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants