Anybody Use Greasemonkey with Firefox 5.0?

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

I've never used Greasemonkey but want to try it. I was able to find and install it in Fx and even got the scripts I wanted to try installed. The problem is that the scripts aren't working - at least they're not doing what I expected them to do which is to find certain key words and phrases and highlight them by changing their display colors. In reading web articles I discovered that there are controls for including and excluding the scripts from running on certain URL content. The information said that by following Tools>Greasemonkey>Manage_User_Scripts I would get a display of the script control panel. Instead I get the Fx Add-ons Manager screen with User Scripts selected and the names of the scripts I installed listed. There is no control panel - nor any way to invoke it that I can find - like the one pictured in screenshots in the articles I read.

If anyone can give me some pointers, I'd be very grateful.
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
stuckling1
2StarLounger
Posts: 142
Joined: 31 Dec 2010, 12:26

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuckling1 »

Until FFx 4, Greasemonkey's user script management window lived in it's own window - like this one
http://3.bp.blogspot.com/_riEeySebk1g/S ... ptions.jpg" onclick="window.open(this.href);return false;

Since FFx 4, userscripts have been much better integrated with FFx, with the options now found in the Fx Add-ons Manager.

In the old control panel, adding URL exclusions & inclusions to the metadata of the userscript had buttons & an interface & was easy - in the new, I can't find options to do this! Maybe this useful feature was removed in the aid of 'dumbing down' ?

Anyway, you can still edit the URLs on which scripts can run - it's just a bit more of a faff. In the section of Add-ons Manager dedicated to userscripts, rightclick the script in question, and choose edit. This opens the user.js in notepad.
Userscripts are written, as you know, in Java, so it can be quite interesting to have a poke around under the hood of your favourite scripts, just to see how they tick. Or rather, geeks like me find it interesting!
However we're only interested in the metadata at the head of the script, which tells Greasemonkey when to run the script.
Simply add any URLs to the // @include or // @exclude tags.
Place each URL on a new line with it's own // @include ; you can use * as a wildcard.

Hope that helps!

User avatar
stuckling1
2StarLounger
Posts: 142
Joined: 31 Dec 2010, 12:26

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuckling1 »

http://greasemonkey.mozdev.org/authoring.html" onclick="window.open(this.href);return false; Has some more pointers. Just a shame that FFx 's new addon's manager killed the easy window that used to let you do this without resorting to typing code!

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

Wow! Finally the information that I needed to understand why the thing wasn't working for me!!

I would never have known that the window for add-on script management had been removed from Fx 5, having never used Greasemonkey in earlier Fx versions.

I'll give those files a check later and report back my results - or, God forbid, more questions.

Thank you, Ken!
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
HansV
Administrator
Posts: 78487
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by HansV »

:whisper: Those replies are not from Ken (stuck) but from his eldest son stuckling1...
Best wishes,
Hans

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

HansV wrote::whisper: Those replies are not from Ken (stuck) but from his eldest son stuckling1...
WHoops! Thank you Ken's son!
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

OK. More questions it is!

I was able to poke around in the script file. I use HTMLPad for an editor. I didn't change anything in the scripts but I did find the // @include statesments. They contain an "*"

I'm guessing that there must be something else wrong with my scripts; so I sought help from the Firefox Forum and got this test script:

// ==UserScript==
// @name Test script
// @description Brings up an alert box
// @include http://*" onclick="window.open(this.href);return false;
// ==/UserScript==

alert("Yay! Greasemonkey works.");

//.user.js

That looks OK (to me) so I tried to copy this to HTMLPad and save the file as GreasemonkeyTest. I have this script in the correct path for Firefox to 'see' it, but it does not appear when I display User Scripts.

I then tried Tools>Greasemonkey>New_User_Script which returned a screen asking for the Name, Namespace, Description and Include/Exclude information that I want to use and it created a script and put it in place. The problem is it is a do-nothing script because I put no statement (like, "alert("Yay! Greasemonkey works.");") into the script generator because I didn't know where to put it.

There must be a way to install the script from the Mozilla path and subdirectories, but I haven't discovered it yet.

This proves, once again, that I am only a Geek-wannabe.
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
stuck
Panoramic Lounger
Posts: 8176
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuck »

BobH wrote:OK. More questions it is!
You may have to wait a while longer for feedback. :whisper: I'm at work so I can't confirm he's out of bed yet.
:evilgrin: :evilgrin:

Ken

User avatar
stuckling1
2StarLounger
Posts: 142
Joined: 31 Dec 2010, 12:26

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuckling1 »

BobH wrote:More questions it is!

I was able to poke around in the script file. I use HTMLPad for an editor. I didn't change anything in the scripts but I did find the // @include statesments. They contain an "*"

I'm guessing that there must be something else wrong with my scripts; so I sought help from the Firefox Forum and got this test script:

Code: Select all

// ==UserScript==
// @name          Test script
// @description   Brings up an alert box
// @include       http://*
// ==/UserScript==

alert("Yay! Greasemonkey works.");

//.user.js

Firstly no other script I've come across has the //.user.js line - it may be needed, it may not be.

When I create a new userscript (which I've only done once before, and only out of curiousity!)
I use Tools>Greasemonkey>New User Script
Enter my desired values into the dialogue as shown
Gm01.jpg
Then the new script opens in my text editor-
Gm02.jpg
Taking inspiration from your basic alert code I put one line of code in, save it, close text editor & then test it-
Gm03.jpg
trial& error code-bashing then ensues.
My final version looked like this:

Code: Select all

// ==UserScript==
// @name           Test Script
// @namespace      A Script for Testing
// @description    See above really.
// @include        http://*.google.*/*
// @include        http://www.eileenslounge.com/viewtopic.php?f=32&t=7130
// @exclude        https://www.twitter.com
// ==/UserScript==

alert('Hello earth');

The main trial and error in this case was just getting enough wildcards in the @include URL to make it run.
My first userscript (which I abandoned because I don't know enough Java to even begin to be good at this) was an attempted to clean up the MSN homepage using the .removeChild() function to get rid of CSS divs. That's a different matter, but if anyone has any suggestions... This took a lot of experimenting and it still didn't work properly, so I decided to leave Greasemonkey to the pros, and just poke around every now and then
You do not have the required permissions to view the files attached to this post.

User avatar
stuckling1
2StarLounger
Posts: 142
Joined: 31 Dec 2010, 12:26

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuckling1 »

Oh and Stuck, you can keep your comments about my sleep-time to yourself! I was very domesticated today - I looked after the neighbour's two toddlers, baked a cake, and did some painting. Haha! ;)

User avatar
stuck
Panoramic Lounger
Posts: 8176
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuck »

:blush: I stand corrected - on this occasion.

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

Yeah, Dad! Back off!

How funny!!
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

Thank you, Stuckling1!!!!!

I've got through the whole bit down to and including creating the file in HTMLPad.

Now I need to know how to install the script which I think also entails saving the file in a particular place for Fx to get at it.

Thank you again for the help.

(I've already chastised Stuck :rofl: )
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

Update:
I saved the script and it now appears to be installed. When I click on the pull down by the monkeymenu icon I see Enabled and the Test Script checked. But, I never see the "Hello Earth" message.

I'm beginning to think that I somehow have script execution blocked, but if I do I don't know how it did it nor how to undo it.

I looked at the Error Console to see if it told me anything I could understand and got this:
Error: gBrowser is not defined
Source File: chrome://browser/content/browser.js
Line: 5247

Error: Weave is not defined
Source File: chrome://browser/content/browser.js
Line: 5480

Next I viewed the source on this page and found no <script that contains the text in the Test Script although I did find others that appear to control how or what is displayed by Fx.

Under Tools>Options>Content the Enable JavaScript box is checked.


? ? ? ? ? ? ? ? ? ? ?
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
stuckling1
2StarLounger
Posts: 142
Joined: 31 Dec 2010, 12:26

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuckling1 »

You won't see Greasemonkey scripts if you view the source, as Greasemonkey works it's magic AFTER the page loads - I read something in some tutorial somewhere (perhaps on Greasespot) about Gm running after the DOM event.

I don't think Error: gBrowser is not defined
Source File: chrome://browser/content/browser.js
Line: 5247
has anything to do with Greasemonkey - sounds more like something to do with the underthehood workings of how FFx is processing the page.

If the script is installed & enabled correctly, which the fact that it shows up on the 'Monkey Menu' implies it is, I don't know why it's not working! Again, I plead my shameful ignorance of Javascript.

Hopefully someone else will have some ideas for troubleshooting your actual code, but I'm glad I was able to help with the basics :)

User avatar
BobH
UraniumLounger
Posts: 9284
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by BobH »

Thank you for the help, Stuckling1.

Sorry I didn't pick up your name correctly on the first post. :innocent:
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
stuck
Panoramic Lounger
Posts: 8176
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuck »

BobH wrote:Yeah, Dad! Back off!

How funny!!
I could tell you what time it was (and where he was) when the neighbour rang when asking if her toddlers could be dropped off and thus why the response had to be, "give me 15mins or so" but that would detract from his hero status so instead I'll award him a :chocciebar:

Ken

User avatar
stuckling1
2StarLounger
Posts: 142
Joined: 31 Dec 2010, 12:26

Re: Anybody Use Greasemonkey with Firefox 5.0?

Post by stuckling1 »

BobH wrote:Thank you for the help, Stuckling1.

Sorry I didn't pick up your name correctly on the first post. :innocent:

'S no problem :smile: