-
Notifications
You must be signed in to change notification settings - Fork 418
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
Inject on pushState if URL wasn't matched before #2187
Comments
Here is my comment on the adjacent feature requests, and I believe most of the arguments also apply to your one. |
Where? |
#1305 (comment) - sorry, seems I forgot to insert the link |
I'm not familiar with the inner workings of Chrome extensions, however assuming the same JS APIs are available to it as to the DOM and that comment being 3 years old: For scripts that are not loaded on the current page (bc no @match) tampermonkey could do:
While obviously, this can just be done in each tampermonkey script itself, this would lead to the issues a)b)c) outlined in the OP. This approach obviously still has the issue of having to check whether tampermonkey already injected the script or not. Feel free to close if you don't think changing this behavior is a priority right now for you. |
when using @match and the site redirects using e.g. history.pushState tampermonkey will not inject the script - which normally is fine and is wontfix as discussed in #200 #1803
However, if the previous URL didn't have the script injected at all, tampermonkey will never inject the script and it's obviously also not possible to do from the script itself (since it's not loaded)
e.g.
Browser URL is https://mywebsite.com/external/ and I click on a button, which redirects me to https://mywebsite.com/internal/foo with history.pushState()
This means my tampermonkey script never gets injected.
I could obviously change my @match to
however this means it will load my script on tons of pages I don't need it
a) making it less secure, since suddenly my script runs on lots of pages it doesn't need to
b) making it impossible to use if there are subdirectories my script must not run (e.g. https://mywebsite.com/secure/ runs validations/other browser extensions that will make the page fail if it encounters any unexpected modifications to the DOM)
c) making the browser slower/consume more RAM
Expected Behavior
Inject the script on pushState,... if the script hasn't been injected yet because the previous URL didn't "@match"
Actual Behavior
Script will never run if URL is changed to an URL with history.pushState that @match if the previous URL didn't @match
Specifications
The text was updated successfully, but these errors were encountered: