Skip to content

Support navigation based conditional matching #1610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 17, 2025

Conversation

jonathanKingston
Copy link
Contributor

@jonathanKingston jonathanKingston commented Apr 2, 2025

Asana Task/Github Issue: https://app.asana.com/0/481882893211075/1209844047592403/f

Description

Part of: https://app.asana.com/0/481882893211075/1209844047592403/f for navigation handling.

Testing Steps

Checklist

Please tick all that apply:

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged

Copy link

netlify bot commented Apr 2, 2025

Deploy Preview for content-scope-scripts ready!

Name Link
🔨 Latest commit 42d6241
🔍 Latest deploy log https://app.netlify.com/sites/content-scope-scripts/deploys/67ffb96e98c3380008db71ff
😎 Deploy Preview https://deploy-preview-1610--content-scope-scripts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Apr 2, 2025

Temporary Branch Update

The temporary branch has been updated with the latest changes. Below are the details:

Please use the above install command to update to the latest version.

Copy link

github-actions bot commented Apr 2, 2025

[Beta] Generated file diff

Time updated: Wed, 16 Apr 2025 14:11:56 GMT

Android
    - android/autofillPasswordImport.js
  • android/brokerProtection.js
  • android/contentScope.js

File has changed

Chrome-mv3
    - chrome-mv3/inject.js

File has changed

Firefox
    - firefox/inject.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

Apple
    - dist/contentScope.js
  • dist/contentScopeIsolated.js

File has changed

@jonathanKingston jonathanKingston force-pushed the jkt/web-interventions-navigate branch from 9aae6f9 to 698d54f Compare April 3, 2025 00:33
@jonathanKingston jonathanKingston marked this pull request as ready for review April 15, 2025 15:11
@jonathanKingston jonathanKingston requested review from dbajpeyi and a team as code owners April 15, 2025 15:11
@jonathanKingston jonathanKingston marked this pull request as draft April 15, 2025 15:12
@@ -26,6 +28,11 @@ export default class ApiManipulation extends ContentFeature {
}
}

urlChanged(site) {
super.urlChanged(site);
this.init();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means we'll rerun rules on navigation change.

registerForURLChanges(() => {
// The rationale for the two separate call here is to ensure that
// extensions to the class don't need to call super.urlChanged()
featureInstance.recomputeSiteObject();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dbajpeyi this is now split out so feature authors don't need to call super() as before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking: do we forsee any major issues if we have both recomputeSiteObject and urlChanged being called? Can there be any inconsistencies?

if ('navigation' in globalThis && 'addEventListener' in globalThis.navigation) {
// if the browser supports the navigation API, we can use that to listen for URL changes
// Listening to navigatesuccess instead of navigate to ensure the navigation is committed.
globalThis.navigation.addEventListener('navigatesuccess', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dbajpeyi the navigate event actually fired too early, I validated this works as expected. The API has a way to modify and deny navigations before they happen.

@jonathanKingston jonathanKingston changed the title PoC: interventions navigate Support navigation based conditional matching Apr 16, 2025
@jonathanKingston jonathanKingston marked this pull request as ready for review April 16, 2025 14:11
Copy link
Contributor

@dbajpeyi dbajpeyi left a comment

Choose a reason for hiding this comment

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

LGTM! Tested the password import case too, for sanity! All working well.

@jonathanKingston jonathanKingston merged commit 8718f95 into main Apr 17, 2025
21 checks passed
@jonathanKingston jonathanKingston deleted the jkt/web-interventions-navigate branch April 17, 2025 13:42
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