Is there any way to detect if a certain URL is opened in chrome and redirect to another page. I need it to make a site blocker.
Yes, you can it now with Chrome 17.
Add the background page and webRequest permissions to manifest.json:
{
"background_page": "background.html",
"permissions": [
"webRequest", "webRequestBlocking",
"http://www.mozilla.org/*"
]
}
and a redirect logic to background.html:
<html><body>
<script>
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
//console.log('before', details);
if (details.url == "http://www.mozilla.org/") {
return {redirectUrl: "https://www.google.com/chrome/"};
};
},
{
urls: ["http://www.mozilla.org/*"],
types: ["main_frame"]
},
["blocking"]
);
</script>
</body></html>
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