Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine why a Greasemonkey script is not running [duplicate]

Tags:

greasemonkey

When I was starting with user scripts, my first error was not using wildcards.

// Broken:
// @include        https://www.example.com/

// Working:
// @include        https://www.example.com/*

That's the simplest way for the script to not even apply, and thus not run at all. In addition, make sure to check for syntax errors; a misplaced semicolon can prevent the script from being parsed, and thus it is ignored.


For me there was a syntax error in the script and Greasemonkey didn't give an error message. Copy-pasting the script to the JS Console revealed the secret.


you can write logs everywhere in your scripts to get better traces of what if being done in them:

GM_log("Hello, World!");

http://wiki.greasespot.net/GM_log

More info: http://wiki.greasespot.net/Greasemonkey_Manual:Other_Useful_Tools#JavaScript_Console

Another tip: Take a look at the whole greasemonkey wiki. They have a lot of good stuff in there: http://wiki.greasespot.net/Main_Page


In Firefox, open Tools > Error Console and watch it as you load the page. If you're getting overwhelmed by Warnings from the page you can filter on Errors, which still often highlights your script problem.


My greasemonkey script was working; I added a line; it stopped working; I removed the line; it still didn't work.

I determined that greasemonkey had installed a broken updater.php script when I reloaded the script with the new line added. Reloading the old script kept the broken version of the updater.php script. I eventually found an error message referring to the updater.php script in my Firefox Web console. I replaced the updater.php script with a file containing a comment after loading the new version of the script, and my script started being executed.

On mac, my updater.php was in: /Users/csimmons/Library/Application Support/Firefox/Profiles/81ri7k71.default/gm_scripts/Extended_LoU_Tweak

You may be able to find a similar updater.php file in your Firefox default profile gm_scripts/ directory.