javascript - `chrome.tabs.executeScript` after window.location change -


i want execute list of codes in chrome tab. in extension have socket connection node server provide functions (as string). background script listening socket messages , executing functions. can execute using chrome.tabs.executescript api.

/* executed on socket message i'm using babel generate es5 code. es6 code below ex: receivedfunc = "(function () {console.log("print something")})()" */ await tabs.execute(tabinfo.id, {     code: receivedfunc,     runat: "document_idle" }); 

but due these scripts (button click or form submit or manual window.location change), window.location changed. want execution paused until window location change completed. can listen chrome.tabs.onupdate.addeventlistener() status of specific tab (callback function receives tabnumber , it's status, whether it's loading or completed loading).

so i'm looking below or better approach.

socket.on('message', (data) => {     let receivedfunc = data.func;      if(loading(tabnumber)){         waituntilcomplete();      await tabs.execute(tabinfo.id, {         code: receivedfunc,         runat: "document_idle"     }); }); 

how can pause execution? there better approach?


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -