Created
August 9, 2009 12:59
-
-
Save arantius/164761 to your computer and use it in GitHub Desktop.
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 DOMNodeInserted Test | |
// ==/UserScript== | |
GM_setValue('test', 'works'); | |
document.body.addEventListener('DOMNodeInserted', function(event) { | |
var access=GM_getValue('test', 'FAILS!!'); | |
if ('undefined'==typeof access) access='FAILS!!'; | |
alert('API Access: '+access); | |
}, true); | |
/* | |
When run on the page below, this script will fail, logging: | |
Error: Greasemonkey access violation: unsafeWindow cannot call GM_getValue. | |
To the error console, and getting undefined in "access". | |
<html> | |
<head> | |
<script type="text/javascript"> | |
function ins() { | |
var el=document.createElement('div'); | |
document.body.appendChild(el); | |
} | |
</script> | |
</head> | |
<body onload='ins()'> | |
</body> | |
</html> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment