What is wrong with this Greasemonkey script?
June 6, 2009 12:59 PM Subscribe
What is wrong with this Greasemonkey script?
I just installed Greasemonkey for the first time, and I've started trying to figure out how to create Greasemonkey scripts, but I can't seem to get it to actually insert anything into the HTML. For example, I got the following very basic script from this tutorial page:
The script is definitely running on the appropriate page; for example, if I instead do this:
I've installed the Mefi deleted posts script, just to see if some "real" script works, and it does.
I've also tried
The console doesn't show any error messages or anything.
This is for Firefox 3.0.10.0, and Greasemonkey 0.8.20090123.1.
Thanks for any help!
I just installed Greasemonkey for the first time, and I've started trying to figure out how to create Greasemonkey scripts, but I can't seem to get it to actually insert anything into the HTML. For example, I got the following very basic script from this tutorial page:
var elmNewContent = document.createElement('div');
document.body.appendChild(elmNewContent);
I would expect that this should insert an empty <div>
into the page's HTML (for a page in the "include" list, and not in the "exclude" list), but it doesn't.The script is definitely running on the appropriate page; for example, if I instead do this:
alert('start');
var elmNewContent = document.createElement('div');
document.body.appendChild(elmNewContent);
alert('end');
I do get the "start" and "end" message boxes. Similarly, I can issue log messages to the console via GM_log
.I've installed the Mefi deleted posts script, just to see if some "real" script works, and it does.
I've also tried
insertBefore
instead of appendChild
; this doesn't help.The console doesn't show any error messages or anything.
This is for Firefox 3.0.10.0, and Greasemonkey 0.8.20090123.1.
Thanks for any help!
Response by poster:
That was it! Thanks very much.
posted by Flunkie at 1:32 PM on June 6, 2009
How do you know if an empty div is not being inserted?Ummmm... by looking at View / Page Source....
That was it! Thanks very much.
posted by Flunkie at 1:32 PM on June 6, 2009
This thread is closed to new comments.
If you are using View > Page Source in Firefox, that will not show any elements added by GreaseMonkey. You need to view the 'generated' source -- the Web Developer extension is useful here, and a less reliable alternative is selecting, right-clicking and choosing View Selection Source.
If you try adding a div with some content, does it show up?
posted by matthewr at 1:26 PM on June 6, 2009