Updating X.com (twitter) DOM with google extensions

20 views
Skip to first unread message

José Machacaz

unread,
Jun 24, 2024, 7:36:30 AM (5 days ago) Jun 24
to Chromium Extensions
I'm working on a small google chrome extension to my own use when i intend to intereact with  some parts of the dom on twitter (X). 

I'm using pure JS for this. 

reading documentation i came with this 


 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))
     {
       loaded = true;
       console.log("completed");

        chrome.scripting.executeScript({
         injectImmediately: false,
         target : {tabId : tabID},
         args: [1],
         //runAt:"document_end",
         func : injectedFunction,
       });


Please note the tab status check - in documentation states that two states (loading and complete). 

on my js function : 
async function injectedFunction(a) {
 
  console.log("count after delay: " + document.querySelectorAll(`[role="tab"]`).length);

this always return undenied. 
am i doing something wrong here ? 
 
Reply all
Reply to author
Forward
0 new messages