i working on an extension to use myself – that i intend to inject into the Twitter/X
and got to a weird situation that i can’t overpass.
chrome.tabs.onUpdated.addListener(async (tabID,tabStatus) => {
if(tabStatus.status === "complete")// && loaded == false)
{
console.log("tabStatus.status: " + tabStatus.status);
console.log("tabStatus.loaded: " + loaded);
let tabProps = await getTabProperties(tabID);
if(tabProps.url.startsWith(twitterUrl))
{
chrome.scripting.executeScript({
injectImmediately: false,
target : {tabId : tabID},
args: [1],
//runAt:"document_end",
func : injectedFunction,
});
async function injectedFunction(a) {
document.querySelectorAll(`[role="tab"]`)
that document query selector doesn’t return nothing – I can understand that at the moment the script is run the doom is not loaded yet.
i try to use a delay – and that did the trick but not always (!) but it doesn’t seems the right way.
is there any way for me to understand when the document is fully loaded?