Questions tagged [userscripts]

Use the Tampermonkey tag if running Tampermonkey or Violentmonkey, use the "Greasemonkey-4" tag if running that engine on Firefox. For all other engines, or multi-engine scripts, use the "Userscripts" tag. Userscripts primarily refers to JavaScript extensions for web browsers, used to automate or customize actions, the layout, or other aspects of the user experience.

Userscripts primarily refers to extensions for web browsers. Userscripts can automate or customize actions, and/or they can change the layout or even "mash up" different websites.

Userscripts are commonly installed in browsers using a userscript manager add-on/extension, but some browsers have limited native support.

On most browsers, when using a userscript manager, userscripts have access to an extended API that allows some actions that are not permitted for ordinary JavaScript code running in the page scope. However, that extended API is significantly less powerful than what's available to actual browser extensions.

Userscripts are available in most browsers:

Scripts meant for Greasemonkey or Tampermonkey should be tagged or , instead.
If the userscript is meant to be cross-browser compatible (not always worth the trouble), use both and .

Userscript API changes:
For quite some time, the APIs provided by userscript managers were reasonably cross-compatible. Those APIs were synchronous, with the exception of AJAX calls. However, Greasemonkey 4.X re-wrote the APIs it presents to userscripts such that they were asynchronous, using Promises, which makes scripts using those APIs not backwards/cross-compatible. The Greasemonkey project provides a polyfill which userscripts can @require in order to write scripts using their new APIs which will function in other userscript managers.

Tampermonkey has begun to provide support for these Promise based APIs.

Resources:

1300 questions
42
votes
1 answer

Where are Chrome/Tampermonkey userscripts stored on the filesystem?

Where are Chrome/Tampermonkey userscripts stored on the filesystem? I want to edit user scripts directly instead of using the hokey in-browser editor.
Landon Kuhn
  • 76,451
  • 45
  • 104
  • 130
36
votes
2 answers

UserScripts & Greasemonkey: calling a website's JavaScript functions

I'm creating a UserScript extension for Firefox & Chrome and I'm trying to use some of the code in the website's JavaScript, e.g.: function: myFunction(){ return Grooveshark.playNextSong(); } The problem is when I test this code, Grooveshark…
sebastian
  • 4,914
  • 2
  • 21
  • 21
35
votes
4 answers

How can I load a shared web worker with a user-script?

I want to load a shared worker with a user-script. The problem is the user-script is free, and has no business model for hosting a file - nor would I want to use a server, even a free one, to host one tiny file. Regardless, I tried it and I (of…
user5536767
34
votes
2 answers

Run Greasemonkey on html files located on the local filesystem?

I have an API documentation lying around on my Harddrive and to ease my workflow, I have written a simple script that modifies the page for my needs. I've developed it using FireBug on FireFox. @include-ing webpages works correctly, but Greasemonkey…
Niklas R
  • 16,299
  • 28
  • 108
  • 203
34
votes
6 answers

Apply a Greasemonkey/Tampermonkey userscript to an iframe

How can I make a userscript run inside an iframe?
UpIX
  • 483
  • 1
  • 4
  • 9
30
votes
6 answers

Native javascript equivalent of jQuery :contains() selector

I am writing a UserScript that will remove elements from a page that contain a certain string. If I understand jQuery's contains() function correctly, it seems like the correct tool for the job. Unfortunately, since the page I'll be running the…
coulbourne
  • 489
  • 1
  • 8
  • 16
28
votes
1 answer

Including a Greasemonkey script across multiple domains

This is a bit of an oddly specific question. I'm writing a Greasemonkey script that will run across ten domains. The websites all have identical structures, but the domain name for each one is different. For example, the script will run…
blimpage
  • 393
  • 1
  • 3
  • 6
27
votes
2 answers

Can a greasemonkey-type userscript be packaged as a Chrome extension?

Today Google changed the way userscripts are installed in Chrome. No longer can you just click on a link that contains one, confirm a couple dialog boxes and have it installed. Now you have to download the script with Save As..., open the…
mix
  • 6,943
  • 15
  • 61
  • 90
26
votes
7 answers

What's a simple way in Google Chrome to insert Javascript into sites?

I would like to be able to add custom snippets of javascript to any site that matches a regex. This is mostly because of sites that I use daily because of specialized content, but which have a poor design. I want to be able to do something…
bhuga
  • 1,292
  • 1
  • 14
  • 24
26
votes
1 answer

Why is window (and unsafeWindow) not the same from a userscript as from a