2

I'm trying to access a javascript variable loaded in the page from a Greasemonkey script. I tried the var name directly , or using window.varname (which works in the console), but neither of them load in the greasemonkey script (the window variable is undefined).

I tried run-at document-end and using setTimeout around the function, neither of those work.

Is there a specific way required to do this, or did I run into a bug for a specific page ?

Accessing Variables from Greasemonkey to Page & vice versa asked this question as the second part of the question, but I didn't see a clear answer. (I would comment under that question, but I don't have the credits).

wesinat0r
  • 121
  • 8

1 Answers1

2

Using unsafeWindow can access page variables

unsafeWindow.varname

https://github.com/greasemonkey/greasemonkey/issues/2700

https://wiki.greasespot.net/UnsafeWindow

wesinat0r
  • 121
  • 8