-1

I'm trying to write a userscript working on the Etherpad page whose content will be updated continuously. The relevant part of the page structure is on the screen: enter image description here

My userscript should affect all the div entries under 'td id="sidedivinner"' element. However, this element does not exist on the page initially and it is built only after the content of both iframes on the screen loads. All the solutions I found on the problem "Execute userscript after page load" failed, because they assumed either that there are no iframes, which still load after the script, or that iframe has the unique name or id.

So basically I want to execute js after all iframes load, as if I had done this via web browser console.

Also I want to run the same script after every AJAX request affecting sidedivinner (It will be too expensive to run it after every AJAX request). I suspect this solution won't work using #sidedivinner id because "waitForKeyElements.js" won't recognize an element by Id inside the iframe. How can I do this?

Community
  • 1
  • 1
Wolfram
  • 571
  • 3
  • 9

1 Answers1

1

Add your javascript to the onload event of the iframe - not the page.

iFrame onload JavaScript event

You could use jquery to check for the creation of the #sidedivinner object. The following jquery will search in any iframes on the page.

$("iframe").contents().find("#sidedivinner")

See the following for more on these jquery functions:

https://api.jquery.com/contents/

https://api.jquery.com/find/

Community
  • 1
  • 1
Glenn
  • 46
  • 4