Aceessing variables inside a JS self invoking function

144 views Asked by At

I'm trying to write a bookmarklet that augments the functionality of a website I frequently use. All the code of said website is in a single script encompassed in a self invoking function like so:

(function() {

  var exampleVar=1;

  // code

}).call(this);

I have no control over that website. How do I get the value of exampleVar from the console or from a bookmarklet?

1

There are 1 answers

4
t.niese On

You can't, that's one of the purposes of scoping, to protect the variable form being accessed.