Created
September 5, 2012 21:15
-
-
Save arantius/3644903 to your computer and use it in GitHub Desktop.
User Script Scope Test
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 User Script Scope Test | |
// @namespace http://arantius.com/misc/greasemonkey | |
// @description Test the affect of assigning to various scopes in a script, on the content page | |
// @include http://jsbin.com/abemus/* | |
// @version 1 | |
// @grant GM_log | |
// ==/UserScript== | |
bare_val = 'grant-ed bare'; | |
var var_val = 'grant-ed var'; | |
window.window_val = 'grant-ed window'; | |
document.body.innerHTML += 'Script sees content_val: ' | |
+ (typeof content_val == 'undefined' ? 'undefined' : content_val) | |
+ '<br>'; | |
document.body.innerHTML += 'Script sees window.content_val: ' | |
+ (typeof window.content_val == 'undefined' ? 'undefined' : window.content_val) | |
+ '<br>'; | |
document.body.innerHTML += 'Script sees unsafeWindow.content_val: ' | |
+ (typeof unsafeWindow.content_val == 'undefined' ? 'undefined' : unsafeWindow.content_val) | |
+ '<br>'; |
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 User Script Scope Test | |
// @namespace http://arantius.com/misc/greasemonkey | |
// @description Test the affect of assigning to various scopes in a script, on the content page | |
// @include http://jsbin.com/abemus/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
bare_val = 'grant-less bare'; | |
var var_val = 'grant-less var'; | |
window.window_val = 'grant-less window'; | |
document.body.innerHTML += 'Script sees content_val: ' | |
+ (typeof content_val == 'undefined' ? 'undefined' : content_val) | |
+ '<br>'; | |
document.body.innerHTML += 'Script sees window.content_val: ' | |
+ (typeof window.content_val == 'undefined' ? 'undefined' : window.content_val) | |
+ '<br>'; | |
document.body.innerHTML += 'Script sees unsafeWindow.content_val: ' | |
+ (typeof unsafeWindow.content_val == 'undefined' ? 'undefined' : unsafeWindow.content_val) | |
+ '<br>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment