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
14
votes
1 answer

GreaseMonkey - Firefox Web console not showing all javascript errors

The Firefox Web console (Ctrl + Shift + K) is not showing all Javascript errors that are reported in the Firefox Error Console. How to change this? It's annoying because the Firefox Error Console has been deprecated and needs to be re-enabled…
KrisWebDev
  • 9,342
  • 4
  • 39
  • 59
13
votes
5 answers

Handler for dynamically created DOM nodes as they are inserted

I enjoy running custom scripts on pages that I do not own or control. Many times these pages have dynamically created content that I would like to apply a function to. Is this possible? If so, how can I do this? Ideally I am looking for something…
Muhd
  • 24,305
  • 22
  • 61
  • 78
13
votes
3 answers

Can a webpage detect a tampermonkey userscript?

My question is sort of two-fold. First, how the sandbox model works, how it impacts the userscript, what is accessible / seen from the webpage and userscript point of view, and if using a different sandbox model affects the page being able to notice…
Kobato
  • 726
  • 1
  • 7
  • 15
13
votes
3 answers

How to load the google maps api via a userscript / synchronously?

I'm writing a userscript (greasemonkey script) that needs to add a google map to a page on a website that I don't control. I tried to add the script like so (which works well when loading other scripts that I tried) : var my_script =…
GJ.
  • 5,226
  • 13
  • 59
  • 82
12
votes
2 answers

How can I inject a user script on iOS?

I'm working on Fahrii, which is, essentially, a userscript enabled mobile browser. At the moment, I'm having trouble invoking the scripts on a web page that's loaded into a UIWebView. I'd like to keep this public APIs if possible. If not, a proof of…
Moshe
  • 57,511
  • 78
  • 272
  • 425
12
votes
1 answer

How to @match a URL hash in a userscript?

I have a lot open tabs of a website - and I want to limit it to only one URL. The problem is that the URL has # in it and I can't seem to @match it. The URL looks like: https://xxx.xxxxxx.xxx/#/xxxxxx I tried: // @match…
Krzysztof
  • 189
  • 1
  • 10
12
votes
4 answers

Greasemonkey & global variables

I'm noob with JavaScript and Greasemonkey and I'd like to write a simple script. I know that Greasemonkey wraps your code with an anonymous function so your variables won't exist after leaving the current page. However, I need a global variable. I…
gombost
  • 317
  • 1
  • 3
  • 9
12
votes
4 answers

How can I replace the text in JSON string with a userscript for Greasemonkey

I want to create a user script for Greasemonkey in Firefox without using jQuery, which can replace old text by new text when the page of website is loaded. HTML code: .. window.app = profileBuilder({ .. "page": { "btn": { …
nemrod
  • 129
  • 1
  • 1
  • 6
12
votes
1 answer

How can I run a user script before any inline scripts run on a webpage?

I want to make a greasemonkey type script for firefox that runs before the scripts on the page. Greasemonkey scripts run after scripts on the page, so that won't work. The reason I need this is because I want to edit one of the scripts on the…
Telanor
  • 4,419
  • 6
  • 29
  • 36
12
votes
3 answers

How to set Chrome's user script version number

Edit: The bug that caused this problem has been fixed. The @version tag now works in the stable release. See Issue 30760 Hey. I've been wondering how I might set the version number displayed for user-scripts in Chrome's extension tab (source:…
Atli
  • 7,855
  • 2
  • 30
  • 43
12
votes
2 answers

Cross-origin XHR from a user script in Google Chrome

Has anybody had any luck performing cross origin XHRs from a user script in Google Chrome? The requests go through to the server (I can see them in the logs) but, the readystatechanged event is never fired. Extension permissions don't seem to be…
Pranav
  • 543
  • 4
  • 9
11
votes
1 answer

Tampermonkey script not auto-updating

At the top of my script I have the following: // ==UserScript== // @name Test script // @description testing auto-update // @namespace http://tampermonkey.net/ // @author newbie // @version 1.0.0 // @updateURL …
newbie
  • 1,551
  • 1
  • 11
  • 21
11
votes
2 answers

Read websocket communication via userscript

How can a greasemonkey script / Chrome's user-script intercept a running websocket communication? My goal is to have additional statistics for a in-browser game
Vojtech B
  • 2,837
  • 7
  • 31
  • 59
11
votes
0 answers

Tampermonkey script not updating

I am having issues getting my script to auto-update. If I force a check for an update, then it picks up the new version just fine. However, I am unable to get this to automatically notify me whenever a new update is available. My script has the…
Tristan Lee
  • 1,210
  • 10
  • 17
11
votes
1 answer

Hijacking a variable with a userscript for Chrome

I'm trying to change the variable in a page using a userscript. I know that in the source code there is a variable var smilies = false; In theory I should be able to change it like that: unsafeWindow.smilies = true; But it doesn't work. When I'm…
Badr Hari
  • 8,114
  • 18
  • 67
  • 100