You are looking for a web navigation API .
You can register listeners to handle user navigation by modifying or blocking the request on the fly.
In the example below, when the user goes to www.google.com , onBeforeNavigate even launched before the page launches, and you can redirect the user to the CSS validation page for this URL:
chrome.webNavigation.onBeforeNavigate.addListener((details) => { if(details.url.indexOf("www.google.com") !== -1)) { chrome.tabs.update(details.tabId, { url: "https://jigsaw.w3.org/css-validator/validator?uri=" + details.url }); } });
Remember to add "webNavigation" to the extension manifest to enable this functionality.
cvsguimaraes
source share