I'm currently building a Google Chrome extension which tests for certain patterns and if found, redirects them to a new URL.
I've gotten the pattern checking done via a content script, and now I'm not sure how can I proceed with getting the redirect done. Any suggestions ?
To redirect from an HTML page, use the META Tag. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The value of the content is the number of seconds; you want the page to redirect after.
Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Choose the desired domain, fill in the URL you want to redirect to another and add the URL of the new page destination. When ready, click Create.
Send redirect url from a content script to a background page:
chrome.runtime.sendMessage({redirect: "http://redirect"});
In a background page update tab's url which would cause redirect:
chrome.runtime.onMessage.addListener(function(request, sender) { chrome.tabs.update(sender.tab.id, {url: request.redirect}); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With