This problem puzzles me a great deal, as I had thought I'd gotten this 
technique to work (and responded to someone else here recently 
accordingly). But apparently I hadn't finished debugging it yet, so 
perhaps my advice should have been marked "untested" or something. :-[

I stripped down a test case, which triggers a "Greasemonkey access 
violation: unsafeWindow cannot call GM_setValue." error in the JS 
Console every time it runs, and exhibits some really bizarre behavior 
with GM_getValue. Does anyone know how to explain this? (Namely, on GM 
0.8.20090123.1 the second GM_getValue("type") returns the injected 
textContent of the <script> tag, which is one of the strangest things 
I've seen in any program I've ever written.)

Here it is:

// Attempts to set the type config entry to the value of the most recently 
passed element text
function listener(e) {
  GM_setValue("type", e.target.textContent);
}

document.body.addEventListener("DOMNodeInserted", listener, true);

// Fires the DOM event by adding a node
function trigger(type) {
  var n = document.createElement("span");
  n.style.display = "none";
  n.textContent = type.toString();
  document.body.appendChild(n);
}

trigger('in GM script context');
alert("Type: " + GM_getValue("type"));
// Inject script, including trigger function, and execute
var nodScript = document.createElement("script");
nodScript.textContent = trigger + "\n\ntrigger('in injected page script');";
alert("nodScript: " + nodScript.textContent);
document.body.removeChild(document.body.appendChild(nodScript));
alert("Type: " + GM_getValue("type"));



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to