0

i have found this extension Behind The Overlay which removes the overlay on the webpage that we visit. for doing so we have to click on the extension icon.

i want to do this programmatically. i.e on page load the extension should run automatically

https://github.com/NicolaeNMV/BehindTheOverlay

i want to add delay before this line

 chrome.tabs.executeScript(null, {file: "overlay_remover.js"});

how to do this?

chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
  if (changeInfo.status === 'complete' && tab.active) {

    // add some delay here


    chrome.tabs.executeScript(null, {file: "overlay_remover.js"});
  }
})
user4599
  • 77
  • 3
  • 11
  • background.js does not send alerts. Instead, try using `console.log()` and [check the extension's console](https://stackoverflow.com/a/10258029/10210841) (**It will not show in the website's console!!! Extensions have their own console!**) – Rojo Apr 21 '21 at 14:39
  • @Rojo i have updated the question please see. – user4599 Apr 21 '21 at 15:00

1 Answers1

1

You can do that by editing your background.js replacing alert() with chrome.tabs.executeScript(null, {file: "/js/overlay_remover.js"}); and include the overlay remover in your files:

chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
  if (changeInfo.status === 'complete' && tab.active) {
    setTimeout(() => {
      chrome.tabs.executeScript(null, {file: "overlay_remover.js"});
    }, 3000); // 3000 = delay in milliseconds (3 seconds)
  }
})

Note that you should keep your manifest the same and keep your background.js

Rojo
  • 2,749
  • 1
  • 13
  • 34
  • this worked, but i just found that the webpage that i want to remove overlay from , loads some data even after page loading is complete, so i want to run this script after some delay, how can i do this? – user4599 Apr 21 '21 at 15:14
  • i want to add some delay before this line executes chrome.tabs.executeScript(null, {file: "overlay_remover.js"}); – user4599 Apr 21 '21 at 15:15
  • @user4599 How long do you want the delay (in ms)? 1000 ms = 1 second – Rojo Apr 21 '21 at 15:35
  • i want to see how much delay will work , by doing trial and error – user4599 Apr 21 '21 at 15:47
  • 3 second possibly – user4599 Apr 21 '21 at 15:47
  • @user4599 I have implemented `setTimeout` with a delay of 3000 milliseconds. Note that users will have different loading times depending on wifi speed, server latency, CPU, and RAM speed. – Rojo Apr 21 '21 at 15:50