Questions tagged [greasemonkey]

OBSOLETE as of Firefox 57. Use [greasemonkey-4] or [tampermonkey] as applicable. If using some other browser userscript engine, use [userscripts].

OBSOLETE as of Greasemonkey 4 -- which is a major change that is not backwards compatible.


Usage Hint

Use this tag if you are using Firefox, pre version 57. Use the tag if you are using Tampermonkey on Chrome. For all other userscripts, please use the tag.

GreasemonkeyMain add-on page is a userscript manager for Firefox. Userscripts are written in JavaScript, and run in every page as specified by the @include, @exclude, and @match rules.

Greasemonkey also permits special operations that ordinary javascript is not allowed to do. See the Greasemonkey API.

Userscripts are also available on/for other browsers; see the tag wiki of .
Important: Please use only if you are running the Firefox browser and/or using the add-on.
For all others, use , if it applies, or .


Premade userscripts:

Premade userscripts can be found at:


References:

2842 questions
376
votes
9 answers

Get image data URL in JavaScript?

I have a regular HTML page with some images (just regular HTML tags). I'd like to get their content, base64 encoded preferably, without the need to redownload the image (ie. it's already loaded by the browser, so now I want the content). I'd…
Detariael
  • 4,152
  • 4
  • 19
  • 10
251
votes
10 answers

How can I use jQuery in Greasemonkey?

I tried putting this line but it doesn't work: // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js jQuery doesn't work in Greasemonkey at all. Is there other way to use jQuery in Greasemonkey? -- For all the people who…
Keira Nighly
  • 15,326
  • 8
  • 29
  • 28
237
votes
25 answers

How do I get the information from a meta tag with JavaScript?

The information I need is in a meta tag. How can I access the "content" data of the meta tag when property="video"? HTML:
supercoolville
  • 8,636
  • 20
  • 52
  • 69
213
votes
17 answers

window.close and self.close do not close the window in Chrome

The issue is that when I invoke window.close() or self.close() it doesn't close the window. Now there seems to be a belief that in Chrome you can't close by script any window that is not script created. That is patently false but regardless it is…
GµårÐïåñ
  • 2,846
  • 5
  • 31
  • 35
173
votes
12 answers

Event when window.location.href changes

I'm writing a Greasemonkey script for a site which at some point modifies location.href. How can I get an event (via window.addEventListener or something similar) when window.location.href changes on a page? I also need access to the DOM of the…
Johan Dahlin
  • 25,300
  • 6
  • 40
  • 55
161
votes
11 answers

How can I use jQuery in Greasemonkey scripts in Google Chrome?

As some of you may know, Google Chrome has put some severe limitation on Greasemonkey scripts. Chromium does not support @require, @resource, unsafeWindow, GM_registerMenuCommand, GM_setValue, or GM_getValue. Without require, I can't find a way to…
Alekc
  • 4,682
  • 6
  • 32
  • 35
125
votes
7 answers

Userscript to wait for page to load before executing code techniques?

I'm writing a Greasemonkey user script, and want the specific code to execute when the page completely finishes loading since it returns a div count that I want to be displayed. The problem is, that this particular page sometimes takes a bit before…
Myne Mai
  • 1,305
  • 2
  • 10
  • 7
90
votes
4 answers

What is the Greasemonkey namespace needed for?

I'm learning how to use Greasemonkey, and was wondering what the @namespace metadata id is for. Does it have to be a web address? Or can it be a folder/directory on my computer? Does it even need to be filled in?
Nope
  • 34,682
  • 42
  • 94
  • 119
81
votes
6 answers

Why doesn't document.addEventListener('load', function) work in a greasemonkey script?

It doesn't give an error, and I put a console.log('loaded userscript wifi-autologin'), the console.log works, but the intended effect of the document.addEventListener doesn't happen. After doing a bit more debugging, making it print that the…
Yet Another User
  • 2,627
  • 3
  • 18
  • 27
73
votes
1 answer

How do I get the jQuery-UI version?

This should be an easy question, but how do I detect the jQuery-UI version? This is for a Greasemonkey script and the (current) target page appears to be running jQuery-UI, 1.5.2. But, different target pages may run different versions. console.log…
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
72
votes
14 answers

Removing an anonymous event listener

Is there anyway to remove an event listener added like this: element.addEventListener(event, function(){/* do work here */}, false); Without replacing the element?
erikvold
  • 15,988
  • 11
  • 54
  • 98
69
votes
3 answers

Simulating a mousedown, click, mouseup sequence in Tampermonkey?

I would like to simulate a whole click not just document.getElementsByClassName()[0].click(); How do I do that? Search results all seem to be about handling such events, not triggering them.
67
votes
5 answers

Detecting combination keypresses (Control, Alt, Shift)?

I am trying to make a script run when Ctrl + Alt + e is pressed. How can Tampermonkey fire on a simultaneous ctrl, alt, and e key? I have tried ctrlKey, and altKey. I've found nothing that works. How can I edit the script below to fire on Ctrl +…
Rasspy
  • 673
  • 1
  • 5
  • 5
67
votes
2 answers

How to change a class CSS with a Greasemonkey/Tampermonkey script?

I'm trying to set the background image of the body, but only where it uses the class banner_url. The HTML is as follows: Basically, I would like to force the page to use…
Xeo
  • 831
  • 2
  • 10
  • 14
60
votes
2 answers

What is the difference between @include and @match in userscripts?

The GreaseSpot page on metadata blocks says that the two are very similar but @match "sets more strict rules on what the * character means." GreaseSpot then proceeds to teach using @include, but Chrome examples like this generally seem to use…
WBT
  • 2,249
  • 3
  • 28
  • 40
1
2 3
99 100