greasemonkey

Executing JavaScript to Render HTML for Server-Side Caching

There are lots of widgets provided by sites that are effectively bits of JavaScript that generate HTML through DOM manipulation or document.write(). Rather than slow the browser down even more with additional requests and trust yet another provider to be fast, reliable and not change the widget output, I want to execute* the JavaScript t...

How can I disable a hotkey in GreaseMonkey while editing?

I'm using Ctrl+Left / Ctrl+Right in a GreaseMonkey script as a hotkey to turn back / forward pages. It seems to works fine, but I want to disable this behavior if I'm in a text edit area. I'm trying to use document.activeElement to get the page active element and test if it's an editable area, but it always returns "undefined". ...

GreaseMonkey script to auto login using HTTP authentication

I've got quite a few GreaseMonkey scripts that I wrote at my work which automatically log me into the internal sites we have here. I've managed to write a script for nearly each one of these sites except for our time sheet application, which uses HTTP authentication. Is there a way I can use GreaseMonkey to log me into this site auto...

How to implement "DOM Ready" event in a GreaseMonkey script?

I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but this event never fires. I'm using FireFox 2.0.0.16 / GreaseMonkey 0.8.20080609 This is the full script that I'm trying to modify, changing: window.addEventListener ("load", doStuff, false); to window.addEventListener ("DOMConten...

What is the best way to do web scripting/web macros?

I'm trying to streamline some of our tasks at my place of work, and it seems that quite a lot of our developers' time is spent doing semi-mechanical tasks on the web (specifically, editing online stores that use web-based interfaces). As such, I've been looking into some solutions that will allow these tasks to be done by scripts since I...

Accessing Greasemonkey metadata from within your script?

Is there any way that my script can retrieve metadata values that are declared in its own header? I don't see anything promising in the API, except perhaps GM_getValue(). That would of course involve a special name syntax. I have tried, for example: GM_getValue("@name"). The motivation here is to avoid redundant specification. If GM me...

Hidden features of Greasemonkey

What are some of the lesser-known but useful features and techniques that people are using in their Greasemonkey scripts? (Please, just one feature per answer.) Similar threads: Hidden Features of JavaScript Hidden Features of Java Hidden Features of C++ Hidden Features of C# ...

Can Greasemonkey cause the displayed title to change

I want to change the title showing in a page based on information I pick up from within the page (eg to show the number of inbox messages) document.getElementsByTagName('title')[0].innerHTML="foo"; does change the title tag, but firefox does not update the displayed title (in window and tags) when this happens. Is this possible? ...

Greasemonkey: love it or hate it?

As users, we love the power of Greasemonkey. As developers, it can complicate things. Some people advocate defensively disabling user scripts; others are willing to die to defend them. Is there a middle ground? How can we reduce the threat of an evolutionary arms race between users and unscrupulous advertisers? ...

Automate getting report from webpage

Hi all, I'm a Java developer and I have a question about automating a task I've been given. I'm having to 3 times daily, login to this website we have at work, select a few form elements and then click on submit to get a report printed out. I'm wondering how I can write some sort of script that will automate this task? Where should I sta...

Greasemonkey script for Google reader-digg

I'm a hardcore greasemonkey fan and an avid google reader user. I was just wondering if anyone has written or is aware of a greasemonkey script that converts digg links in google reader to the direct website link or at least automatically redirects from digg to that particular site. That would be a great tool, since with my dialup connec...

Unique element ID, even if element doesn't have one

I'm writing a GreaseMonkey script where I'm iterating through a bunch of elements. For each element, I need a string ID that I can use to reference that element later. The element itself doesn't have an id attribute, and I can't modify the original document to give it one (although I can make DOM changes in my script). I can't store the ...

Debugging greasemonkey-like scripts

I'm writing javascript code that is read in as a string and executed via eval() by a firefox extension. Firebug does "see" my script so I am not able to use breakpoints, see objects, etc. I am currently using Firefox's error console which I'm starting to find limiting. What are my other options? Ideally, I would be able to use Firebug ...

JavaScript function to match only Google URLs

Need a function like: function isGoogleURL(url) { ... } that returns true iff URL belongs to Google. No false positives; no false negatives. Luckily there's this as a reference: .google.com .google.ad .google.ae .google.com.af .google.com.ag .google.com.ai .google.am .google.it.ao .google.com.ar .google.as .google.at .google.com...

Reading the value of an input using XPath, then using in Greasemonkey

Hi - I'm using this XPath to get the value of a field: //input[@type="hidden"][@name="val"]/@value I get several results, but I only want the first. Using //input[@type="hidden"][@name="val"]/@value[1] Doesn't work. Once I have this, how do I pick up the value in Greasemonkey? I am trying things like: alert("val "+val.snapshotItem...

How safe is Greasemonkey?

I've never actually used greasemonkey, but I was considering using it. Considering that GreaseMonkey allows you to let random people on the Internet change the behavior of your favorite websites, how safe can it be? Can they steal my passwords? Look at my private data? Do things I didn't want to do? How safe is Greasemonkey? Thanks ...

Greasemonkey\JavaScript Copy to Clipboard button

I am trying to write a JavaScript script to add to greasemonkey that adds a button after an element. The onClick for this button should copy the parents element text to the keyboard. I have seen plenty of examples that copy already selected text to the clipboard such as this: <SCRIPT LANGUAGE="JavaScript"> <!-- Begin functio...

Activate Firefox tab in Greasemonkey/Javascript? Is this possible?

Hello, I developed a greasemonkey script that refreshes a page and checks for certain updates. I would like to run this script in a tab and browse the internet in another tab, but then have the script automatically activate it's tab when an update is found. Im not sure how clear that was, maybe this is better: Tab 1 is running a greas...

How do I close a firefox tab from a greasemonkey script?

I have a greasemonkey user script with this single line of code... window.close(); but firefox does not allow a user script to close a window (as reported by an error message in the error console) Is there a work around to this problem? ...

Counting Results in an Array

By means of a regular expression and Greasemonkey I have an array of results that looks like: choice1, choice2, choice3, choice3, choice1, etc.. My question is how do I tally up the choices so I know how many times choice1 is in the array, choice2 is in the array, etc. if I do not know exactly how many choices there are or what they...