How can I programmatically block sites through the Chrome browser?

My idea is to do it through a custom extension, so I think it would be implemented in JavaScript.

I think it's as simple as redirecting from the page the user enters to a custom error page -- but I'm not sure exactly how to go about doing this (I haven't really done Chrome extensions before)

有帮助吗?

解决方案

You should look into chrome.webRequest and its samples.

They will achieve exactly what you need: you detect an attempt to open a page in onBeforeRequest in your background script, analyze the request and optionally redirect it to your page implementing your logic.

See CatBlock sample here for a starting point.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top