Closed kyxap closed 12 months ago
@math
? Did you mean @match
?
https://www.linkedin.com/jobs/
doesn't match any @match
from the script, and if happens soft navigation to any page, the script won't be loaded either. Userscripts get loaded only at hard navigation.
You can try to match https://www.linkedin.com/*
and use onurlchange event to run your code on the target pages.
However, in such cases, I check the presence of the target element and ignore url.
@math
? Did you mean@match
?
yeah, fixed
https://www.linkedin.com/jobs/
doesn't match any@match
from the script, and if happens soft navigation to any page, the script won't be loaded either. Userscripts get loaded only at hard navigation. yeah it does not, the idea is to navigate to one those:// @match https://www.linkedin.com/jobs/search/* // @match https://www.linkedin.com/jobs/collections/recommended/*
without opening page directly You can try to match
https://www.linkedin.com/*
and use onurlchange event to run your code on the target pages.
hm seems very tricky, how this will be different from using document.URL
and do custom match and if match just execute the script?
But you cannot listen for changes of document.URL
.
// @grant window.onurlchange
function matchScript ({ url }) {
if (url.startsWith("https://www.linkedin.com/jobs/search/") || url.startsWith("https://www.linkedin.com/jobs/collections/recommended/") {
runScript();
}
}
window.addEventListener("urlchange", matchScript);
matchScript({ url: location.href }); // check the initial location
function runScript () {
// main code
}
Update: of course, you need to take into account that runScript
can be run multiple times (again after each navigation).
Thanks @7nik
Duplicate of https://github.com/Tampermonkey/tampermonkey/issues/1639#issuecomment-1310077826
it does not work for me, addEventListener
calls matchScript
only 1 time, when I go for page url change matchScript
never triggers
upd: it works you do back, forward via browser buttons but not when you interact with the page
upd2: found another way to overcome that issue
Steps to reproduce
0) Pit
Tampermonkey
plugin to your browser Tool Bar for visibility 1) Openhttps://www.linkedin.com/jobs/
2) Click on Show All (you will be redirected tohttps://www.linkedin.com/jobs/collections/recommended/*
) 3) Observe Plugin Icon on Tool Bar, very script is workingExpected Behavior
Tampermonkey
plugin shows Icon and1
on it which indicates there 1 active script This is workingActual Behavior
Tampermonkey
plugin does not show that there any active scripts This does not workSpecifications
Script
Full script: (Please give an example of the script if applicable.)
But you can do something like this without actual js in it