G
G
genesis11112019-05-06 16:29:12
Google Chrome
genesis1111, 2019-05-06 16:29:12

Wait for DOM to load in chrome extension?

I am writing a browser extension and I ran into a difficulty - I need to open the url in a new tab and execute the script.

chrome.tabs.create({
         url: 'http://ooo.com',
         active: true,
       var sos = document.getElementById("id").children[0];
      });

As I understand it, the DOM of the page does not have time to load.
Please tell me how to wait for the page to load and make the var sos variable global (so that it can be used in another browser tab)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander +, 2019-07-26
@genezis1111

Inject a content script into this page, wait for DOMContentLOaded there, and from there send a message with the data you need to get from the page via runtime.sendMessage. Profit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question