So most likely this is because Tampermonkey scripts default to running at DOMContentLoad time, which means that the load event has already passed. If you need it to run at load time, tell the script to @run-at document-start ; otherwise, just call your function normally: (function() { //Your Code here })();
You’ve confused assignment and comparison. = is not ==.
window.location.href contains the protocol and any filenames attached to it; as such, it will never match “n12.co.il” exactly. You may be trying to do an includes test.
That is a beginner mistake that I think even experienced programmers make. I do not know if it works in JavaScript (I assume so) but some programmers do something as in the following.
if ("n12.co.il" == window.location.href)
And then if (and only if) = is used instead of == then that is a syntax error.
I shouldn’t in this case because the actual script is larger and does more actions on various websites (executed on any website), for example, for the sake of blocking any website that has the word “News” or “news” in its <title> or <meta> tags.
The N12 is just an example for an exception that doesn’t have such words in the HTML source code and should be clocked by a web domain.
It is a problem with the C programming language and even FORTRAN I think. It has been half a century since I wrote a FORTRAN program but see Fortran - Operators. It is one of those things that developers just must be aware of. The good news is that once you are accustomed to it your experience is likely relevant to other languages you learn.