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
10
votes
2 answers

Looking for Greasemonkey Scriptwriting basics/tutorial

I have been searching the internet for days now trying to find out how to write my own script, one more complicated than the "Hello World" script. I understand for the most part how to find specific elements using firebug (I have Firefox). I…
Landon
  • 109
  • 1
  • 3
10
votes
1 answer

How to debug Greasemonkey/Tampermonkey userscripts with FF 57+ (with WebExtensions)?

I can't find my userscript(s) in the Browser Debugger's Open file... box (with the name defined at // @name). It seems that Annarfych's answer and Hjulle's answer to How to debug Greasemonkey script with the Firebug extension? do not work any…
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
10
votes
1 answer

How to manage my greasemonkey userscripts using Git (in order to have them hosted in GitHub)

I'd like to use Git in order to facilitate the development of my userscripts (21). Also, I'd like to have them hosted in GitHub too. (using Greasemonkey with Firefox in windows 10). So, my question is: what is the suggested way to manage my…
darkred
  • 591
  • 5
  • 28
10
votes
2 answers

using jQuery in Safari Extension

I am trying to make a simple Safari 5 Extension that just injects a custom javascript. Any ideas how can I make use of jQuery in this custom script, please? I only know it's possible, because it is mentioned on one of WWDC videos, but I don't know…
Josef Richter
  • 497
  • 1
  • 9
  • 16
10
votes
1 answer

UserScript issue with Object.prototype

I'm developing a UserScript and i thought it would be more time saving to create 2 Prototype functions for Object. Object.prototype.Count = function() { var size = 0, key; for (key in this) { if (this.hasOwnProperty(key)) { …
Devian
  • 817
  • 1
  • 12
  • 22
9
votes
1 answer

Get 2 userscripts to interact with each other?

I have two scripts. I put them in the same namespace (the @namespace field). I'd like them to interactive with another. Specifically I want script A to set RunByDefault to 123. Have script B check if RunByDefault==123 or not and then have script A…
user34537
9
votes
2 answers

Userscript should run once, not multiple times

// ==UserScript== // @name Test // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://myanimelist.net/* // @require…
SadPanda
  • 135
  • 7
9
votes
2 answers

Is the Immediately-Invoked Function Expression (IIFE) pattern really necessary when writing userscripts?

My question is quite similar to What is the purpose of a self executing function in javascript?, however it concerns userscripts (specifically for GreaseMonkey) instead. I see that some userscripts are distributed with this pattern, and some are…
Marc.2377
  • 7,807
  • 7
  • 51
  • 95
9
votes
2 answers

Can I run a userscript on the new tab page?

I have a very simple userscript that I've written with TamperMonkey, and I'd like it to run on the Chrome new tab page. According to this site there is no way to run userscripts on the new tab page: The URL of the new tab page is "chrome://newtab/"…
Greedo
  • 4,967
  • 2
  • 30
  • 78
9
votes
4 answers

How do I prevent the browser from preloading the

I have written a user script extension for Chrome with JavaScript in order to prevent video and audio tags from downloading automatically on pageload This is the code: var videoTags = document.getElementsByTagName("Video"); var i; for(i=0;…
AliBoronsi
  • 764
  • 1
  • 12
  • 19
9
votes
2 answers

Can a userscript delete cookies from a given domain?

Can Greasemonkey delete cookies from a given domain? If so, how?
Thomas Eding
  • 35,312
  • 13
  • 75
  • 106
9
votes
6 answers

Save images to hard disk WITHOUT prompt?

I use twitter. Some people's tweets contain photos and I want to save them. I checked ifttt, where twitter is not a trigger. Thus, ifttt cannot help me do it. One idea is probably to use JavaScript. I use Firefox and installed Greasemonkey. I can…
Gqqnbig
  • 5,845
  • 10
  • 45
  • 86
9
votes
2 answers

How to use GM_xmlhttpRequest in Injected Code?

I am writing a userscript that is injected into a webpage. The script reads some data from a web-server and I want to send messages to a listening application to react to the data. For now, all I'm doing is trying to send a string command to my…
akagixxer
  • 1,767
  • 3
  • 21
  • 35
8
votes
1 answer

capture a pages xmlhttp requests with a userscript

I have a user script (for chrome and FF) that adds significant functionality to a page, but has recently been broken because the developers added some AJAX to the page. I would like to modify the script to listen to the pages xmlhttp requests, so…
zeel
  • 1,101
  • 1
  • 13
  • 31
8
votes
1 answer

How to correctly work on a GreaseMonkey userscript using git?

I am working on a userscript for Firefox, so I use GreaseMonkey. Moreover, to facilitate the development, I use git to update the different versions of my code. Now, let me try to explain the issue. When I add to GreaseMonkey the userscript from my…
Delgan
  • 18,571
  • 11
  • 90
  • 141