Skip to content

Instantly share code, notes, and snippets.

@jerone
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerone/e38e8637887559870d84 to your computer and use it in GitHub Desktop.
Save jerone/e38e8637887559870d84 to your computer and use it in GitHub Desktop.
Hook into jQuery existing events
// ==UserScript==
// @name test @grant GM_*
// @namespace https://github.com/jerone/UserScripts
// @include https://github.com/*
// @version 1
// @grant GM_setValue
// ==/UserScript==
unsafeWindow.$(document).on("pjax:end", exportFunction(function() {
console.log('test @grant GM_* 1');
}, unsafeWindow));
unsafeWindow.$(window).on('popstate', exportFunction(function() {
console.log('test @grant GM_* 2');
}, unsafeWindow));
// ==UserScript==
// @name test @grant none
// @namespace https://github.com/jerone/UserScripts
// @include https://github.com/*
// @version 1
// @grant none
// ==/UserScript==
unsafeWindow.$(document).on("pjax:end", function() {
console.log('test @grant none 1');
});
unsafeWindow.$(window).on('popstate', function() {
console.log('test @grant none 2');
});
@jerone
Copy link
Author

jerone commented Apr 1, 2015

@jerone
Copy link
Author

jerone commented Apr 1, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment