Skip to content

Instantly share code, notes, and snippets.

@arantius
Created August 9, 2009 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save arantius/164761 to your computer and use it in GitHub Desktop.
Save arantius/164761 to your computer and use it in GitHub Desktop.
// ==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