I'm writing a script to add a keyboard shortcut to download whatever the mouse cursor is pointing at, specifically for tumblr.
I noticed that I have several instances of the script running for each(?) iframe. I have a variable that holds the URL to the last image pointed at by the cursor.
When I try to update the variable (by pressing shift, or whatever key in the "keydown" event listener), it updates only in one instance, the other one stays undefined.
my current source code here (warning, not clean, some testing function and lots of debug messages):https://gist.github.com/glubsy/d41252e0883fbf61f6914aad722ed45c
Here's a page to test it on: https://yahoonews.tumblr.com/post/116159782521/photos-of-the-day-april-11-2015-a-visitor-takes
The function in question is the updateLink() one, which updates the currentLink variable.
I doubt there's a way to have this variable common for all instances of the script, unless I deactivate the script for iframes. But if I do that, I can't scrape the entire node tree for images.
Any idea on how to work around that?