Open kkmuffme opened 18 hours ago
Here is my comment on the adjacent feature requests, and I believe most of the arguments also apply to your one.
Where?
https://github.com/Tampermonkey/tampermonkey/issues/1305#issuecomment-903281912 - sorry, seems I forgot to insert the link
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 https://github.com/Tampermonkey/tampermonkey/issues/200 https://github.com/Tampermonkey/tampermonkey/issues/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