function Foo1() {
var bar = 'test';
}
AFAIK, it is impossible to access the variable bar from global scope, unless one writes a privileged function to do so, such as
function Foo2() {
var bar = 'test';
this.read = function(){return bar;};
}
Does Greasemonkey (or any other tool) provide any means to access the variable bar, short of re-defining the entire function Foo1 with Foo2? Greasemonkey has GM_xmlhttprequest which sidesteps certain restrictions, so I was wondering if it could do this too and save me some issues.
What I am trying to do currently is to read and write a private variable embedded in a function, which is also itself located in a separate .js include. Thus, I cannot directly modify the script, and I have to load the .js with AJAX, carry out the modification, and then overwrite the original script. This is very cumbersome and I would like an easier way to carry this task out.