Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.