Last active
December 9, 2015 15:16
-
-
Save ThomasR/9b7c94e506f236ae4ba2 to your computer and use it in GitHub Desktop.
A Greasemonkey script template that injects the main script into the global scope, thus escaping the sandbox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name %name% | |
// @namespace %namespace% | |
// @description %description% | |
// @include %include% | |
// @exclude %exclude% | |
// @version 1 | |
// @noframes | |
// @grant none | |
// @run-at document-end | |
// ==/UserScript== | |
(main => { | |
// http://stackoverflow.com/a/5006952/27862 | |
var script = document.createElement('script'); | |
script.textContent = `try {(${main})();} catch (e) {console.log(e);}`; | |
document.body.appendChild(script).parentNode.removeChild(script); | |
})(() => { | |
// script content here | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment