Search code examples
javascripttampermonkey

How to execute script once OR enable/disable script programaticly


Is it possible to run a TamperMonkey Script only once ?

According to me TamperMonkey Script are always executed when the url location does match so I was wondering to know if there was a way to execute a script only once and then to disable it for exemple. So when I refresh the page the script will not be executed again.

Is it possible ?


Solution

  • Sure.

    You could use GM_setValue and GM_getValue to save the URL you run on, and if the URL had already been saved, not re-run the script.