Skip to content

Instantly share code, notes, and snippets.

View gm-dot-rmc-example.user.js
// ==UserScript==
// @name GM.rmc example
// @version 1
// @grant GM.registerMenuCommand
// ==/UserScript==
GM.registerMenuCommand('GM.rmc example', () => alert('GM.rmc example'));
View gm-rmc-example.user.js
// ==UserScript==
// @name GM.rmc example
// @version 1
// @grant none
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// ==/UserScript==
GM_registerMenuCommand('GM.rmc example', () => alert('GM.rmc example'));
View dhd.xml
<?xml version='1.0' encoding='UTF-8'?>
<rss version="2.0">
<channel>
<title>DOGHOUSEDIARIES</title>
<pubDate>Tue, 09 May 2017 00:00:00 +0000</pubDate>
<lastBuildDate>Sat, 28 Dec 2019 17:34:53 -0500</lastBuildDate>
<link>http://thedoghousediaries.com/</link>
<language>en</language>
<image>
<url>https://scontent-lga3-1.xx.fbcdn.net/v/t1.0-1/p50x50/1510694_10151971936966795_1493121884_n.png?_nc_cat=104&amp;_nc_ohc=5v9cCHoB7iAAQnE0SrL0_1bqdhnw9PaTl_yhpqXq06pscEDZejoSVvPWg&amp;_nc_ht=scontent-lga3-1.xx&amp;oh=5112824c0ca9b259591e3a58fc118994&amp;oe=5E6BD7F6</url>
View everything-red.css
* { color: red !important; }
@arantius
arantius / gm-get-set-demo-with-polyfill.user.js
Last active May 2, 2018
A simple persistent value test user script
View gm-get-set-demo-with-polyfill.user.js
'use strict';
// ==UserScript==
// @name GM set/get demo
// @description Exercises both GM.getValue() and GM.getValue(). Logs a counter which goes up by one, at each page load.
// @grant GM.getValue
// @grant GM_getValue
// @grant GM.setValue
// @grant GM_setValue
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
// ==/UserScript==
View gm-addstyle.js
function GM_addStyle(aCss) {
'use strict';
let head = document.getElementsByTagName('head')[0];
if (head) {
let style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.textContent = aCss;
head.appendChild(style);
return style;
}
@arantius
arantius / long-name-no-space.user.js
Created Jan 26, 2018
User scripts with long @name values.
View long-name-no-space.user.js
// ==UserScript==
// @name This_user_script_has_a_terribly_long_name_and_is_likely_to_break_UI_that_hasn't_been_crafted_specifically_to_handle_long_names.
// @grant none
// ==/UserScript==
// No_op.
View README.md

Check out this repository/download this ZIP. Run:

$ npm i --save-dev
$ npm test

> sinon-chrome-webext-test@0.0.1 test /.../sinon-chrome-webext-test
> karma start karma.conf.js

Firefox 57.0.0 (Ubuntu 0.0.0) ERROR
  ReferenceError: browser is not defined
@arantius
arantius / serve-user-script-slow.py
Last active Oct 11, 2020
Serves a user script, slowly
View serve-user-script-slow.py
#!/usr/bin/env python
import time
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
PORT = 8000
USER_JS = """// ==UserScript==
// @name Red Border
@arantius
arantius / red-border.user.js
Created Sep 7, 2017
A super simple user script with an unobtrusive way of being clear that it's running.
View red-border.user.js
// ==UserScript==
// @name Red Border
// @description A super simple user script with an unobtrusive way of being clear that it's running.
// @namespace test
// @include http*
// @version 1
// @grant none
// ==/UserScript==
document.body.style.border = '3px dashed red';