Skip to content

Instantly share code, notes, and snippets.

// ==UserScript==
// @name 2067 test
// @namespace test
// @include *
// @version 1
// @grant GM_registerMenuCommand
// ==/UserScript==
console.log("Greasemonkey script running");
GM_registerMenuCommand("test", function(){});
// ==UserScript==
// @name script1
// @include *
// @grant unsafeWindow
// ==/UserScript==
unsafeWindow.MouseFunction = exportFunction(function (event) {
console.log(1);
}, unsafeWindow);
unsafeWindow.addEventListener("mousedown", unsafeWindow.MouseFunction, false);
@Ventero
Ventero / tests.js
Last active August 29, 2015 13:59
Greasemonkey @match test suite
// Placed in the public domain, where applicable.
// Also licensed under CC0/WTFPL.
function tests() {
// Unloading the module doesn't always work, so changes might require a browser restart.
Components.utils.unload("resource://greasemonkey/third-party/MatchPattern.js");
var scope = Components.utils.import("resource://greasemonkey/third-party/MatchPattern.js");
var tests = [
// format: [pattern, url, shouldMatch, shouldThrow]
// ==UserScript==
// @name GM_getResourceText ScriptChannel behavior
// @namespace test
// @version 1.0
// @include *
// @grant GM_getResourceText
// @grant GM_getResourceURL
// @resource script.user.js http://dump.ventero.de/greasemonkey/resource
// ==/UserScript==
<!DOCTYPE html>
<html>
<head><title>GM #1494 test</title></head>
<body>
<button onclick="sendEvent();">Click</button>
<script>
var div = document.createElement("div");
function sendEvent() {
div.click();
}
@Ventero
Ventero / userval.user.js
Created January 21, 2014 17:29
Greasemonkey user variable definition example
function makeUserModifiable(varName, defaultVal, parseFunc) {
if(typeof parseFunc !== "function")
parseFunc = function(a) { return a; };
var currentVal = GM_getValue(varName, defaultVal);
GM_registerMenuCommand("Set variable " + varName, function() {
var val = prompt("Value for " + varName, currentVal);
GM_setValue(varName, val);
// if you need live modification, uncomment this (requires varName to be a
// global variable)
// ==UserScript==
// @name Icon Update Test
// @description Test the displayed icon in the addon manager when updating this script.
// @namespace ventero.de
// @include http*
// @icon http://iconpacks.mozdev.org/images/firefox-world32x32.png
// @downloadURL https://gist.github.com/Ventero/5897253/raw/d1558153f6977f84a8288c260a3560b59577a7fc/update.user.js
// @updateURL https://gist.github.com/Ventero/5897253/raw/3d9118b6beca694e265648c9c46b815ac42dd367/update.meta.js
// @version 0.5
// ==/UserScript==
@Ventero
Ventero / scriptresource.user.js
Last active October 9, 2015 23:38
GM crash test
// example script resource
console.log("resource");
@Ventero
Ventero / deadobject.user.js
Created August 5, 2012 20:28
GM_xhr dead object test
// ==UserScript==
// @name GM_xhr dead object test
// @namespace test
// @include *
// @version 1
// @grant GM_xmlhttpRequest
// ==/UserScript==
GM_xmlhttpRequest({
method: "GET",
@Ventero
Ventero / issue_1584_2.diff
Created July 16, 2012 21:31
GM issue 1584 diff #2
diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index 4863722..559d178 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -322,6 +322,7 @@ function startup(aService) {
var observerService = Components.classes['@mozilla.org/observer-service;1']
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(aService, 'document-element-inserted', false);
+ observerService.addObserver(aService, 'content-document-global-created', false);
}