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

Does Microsoft Edge support userscripts?

Did Microsoft announce whether Edge supports userscripts? Doesn't matter if via plugins (similar to Greasemonkey in Firefox or Tampermonkey in Chrome) or as an out-of-the-box feature.
8
votes
1 answer

Adding search button and text box in ui-dialog-buttonpane

I am writing a greasemonkey script to manipulates the DOM, queries a server and displays the result on a separate jquery dialog. I want to add following two functionalities to it: Provide a search box which acts like a simple search on a browser…
Starney
  • 175
  • 1
  • 14
8
votes
1 answer

How to create a toolbar button for a Chrome Tampermonkey user script?

I have written a userscript that I would like to run when I call it (not every time a matching web page loads). Ideally I'd like to create a toolbar button for starting this script. How can this be done? PS: I need it to run in the same context with…
Ivan
  • 63,011
  • 101
  • 250
  • 382
7
votes
3 answers

Does IE have a simple, javascript-driven means of extension development like Chrome, FF, Safari and Opera do?

Before giving up on my extensive googling, I thought I'd make a last ditch effort and ask here... In Chrome, Safari, Firefox and Opera - it's very easy to write browser extensions using javascript (and some native javascript functions to each…
7
votes
2 answers

XMLHttpRequest for JSON file works perfectly in Chrome, but not in Firefox

I've narrowed my problem area down to the function below. It's part of a userscript I'm writing. It works perfectly in Chrome, but doesn't work at all in Firefox/Greasemonkey. I've tinkered with it all day and have hit a brick wall. The only thing…
gilrain
  • 111
  • 1
  • 7
7
votes
0 answers

Modifying a React component with a user script

Short version How can I modify a React component with a user script (e.g. code injected by Tampermonkey) without breaking the app when I don't have access to the original source? Longer version Modifying the DOM of a React component directly can…
Till Hoffmann
  • 9,479
  • 6
  • 46
  • 64
7
votes
2 answers

jQuery queue in Chrome userscript with popups?

I would like to ask if it is possible to build Chrome or Greasemonkey script witch could open all popups in queue. So far i have 2 seperate scripts for this, but that is not working well since popups have anti-spam feature that don't allow too much…
arma
  • 4,084
  • 10
  • 48
  • 63
7
votes
0 answers

Tampermonkey to access a JSON call/URL on a page?

I have a page index.html which calls an external URL. This external URL is a JSON endpoint. In other words, I see two resources when I open DevTools (with F12): index.html and myJSONEndpoint. I want to be able to grab that JSON each time I load…
A. Gardner
  • 571
  • 2
  • 7
  • 17
7
votes
3 answers

Make my userscript wait for other scripts to load

[Edit: I'm replacing the original, confusing question with a simplified example demonstrating the problem.] Background I'm trying to write a userscript which will run in Chrome. This script needs to call a JavaScript function AlertMe() that is…
Michael Martin-Smucker
  • 11,927
  • 7
  • 31
  • 36
7
votes
2 answers

How to override the alert function with a userscript?

On site there is code like that (its site on LAN) I try to disable that alert using GM. I was trying to do this unsafeWindow.alert=function() {}; but I see…
IAdapter
  • 62,595
  • 73
  • 179
  • 242
7
votes
3 answers

How to get video height and width from a MP4 URL with pure ecmascript and without browser support for h.264?

I'm writing a user script for downloading videos. The flash player of the web site use a JSON file. The purpose of my script is to get the url of the video by downloading and parsing the video according to the web page. Currently it can download an…
user2284570
  • 2,891
  • 3
  • 26
  • 74
7
votes
2 answers

How to overwrite a function using a userscript?

I want to change parts of the webpage display, is it possible to overwrite a function with a userscript? Below is the function I would like overwritten (also found Here): function StartDrawing() { if ((typeof (systemsJSON) != "undefined") &&…
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
7
votes
2 answers

My userscript only works when the page is refreshed or on iframes, not the main page?

This simple code doesn't work on a Facebook page. This code only alerts when I refresh the page. If I go to that page from my Facebook profile, with my mouse; The script stops working. There are no alerts or errors. :( It looks like the whole…
Arda
  • 470
  • 5
  • 10
7
votes
3 answers

window.onload works in Firefox+Greasemonkey script but not in a Chrome userscript?

There is a page http://example.com/1.php that includes javascript file as usual: This file contain function named exampleFunction which I need to use in my userscript. Also I have…
Alex
  • 634
  • 1
  • 8
  • 29
7
votes
1 answer

Override Chrome keyboard shortcuts in a user script

I wrote a user script that performs a certain operation on selected text in a textarea when pressing CTRL+SHIFT+B. This is done by registering a keypress event for the textarea and then checking the pressed key. To prevent the browser from handling…
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636