Skip to content

Instantly share code, notes, and snippets.

@arantius
arantius / long-name-no-space.user.js
Created January 26, 2018 15:10
User scripts with long @name values.
// ==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.

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 October 11, 2020 13:20
Serves a user script, slowly
#!/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 September 7, 2017 14:06
A super simple user script with an unobtrusive way of being clear that it's running.
// ==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';
C:\Users\t-bone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src\WiFiClientSecure.cpp: In function 'int ax_port_read(int, uint8_t*, size_t)':
C:\Users\t-bone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi\src\WiFiClientSecure.cpp:539:53: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if (!_client || _client->state() != ESTABLISHED && !_client->getSize()) {
^
C:\Users\t-bone\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266mDNS\ESP8266mDNS.cpp: In member function 'void MDNSResponder::_parsePacket()':
// ==UserScript==
// @name GM_[gs]etValue Bench
// @namespace https://github.com/arantius
// @description Test performance of lots of get/set value calls.
// @include http:*
// @version 1
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// ==/UserScript==
@arantius
arantius / index.php
Created February 3, 2016 15:18
Test script for online edit of `.user.js` files.
<?
////////////////////////////////////////////////////////////
// This proof of concept script is FULL OF SECURITY ISSUES.
// Don't use it, don't install it, don't expose it anywhere.
////////////////////////////////////////////////////////////
// Context: https://github.com/greasemonkey/greasemonkey/issues/2280
////////////////////////////////////////////////////////////
if (isset($_POST['file'])) {
$fp = fopen($_GET['file'], 'wb');
// ==UserScript==
// @name GM_getResourceText Test
// @namespace https://github.com/arantius
// @include *
// @version 2
// @grant GM_getResourceText
// @resource t https://github.com/greasemonkey/greasemonkey/issues/2346
// @require http://cdnjs.cloudflare.com/ajax/libs/mathjs/2.7.0/math.min.js
// ==/UserScript==
<!DOCTYPE html>
<html>
<head>
<title>Tab Open/Close order test</title>
</head>
<body>
<script>
if (location.search) {
document.title = 'Sub tab: ' + location.search;
}
// ==UserScript==
// @name Bug 1192821 test
// @namespace https://arantius.com/misc/greasemonkey
// @include https://bugzilla.mozilla.org/show_bug.cgi?id=1192821
// @version 1
// @grant GM_log
// ==/UserScript==
GM_log("Location hack test...");
location.assign(