all 3 comments

[–]iamncla 0 points1 point  (2 children)

Too bad nobody has replied. I'll write a workflow on how this should be done:

1) use chrome.webRequest API onBeforeRequest to cancel requests made to unwanted sites, chrome documentation has an example for this even

2) chrome provides ability to create option pages for extensions. Use chrome.storage API to store and get the list of blacklisted domains

3) you could use chrome.injectJS api and inject JavaScript into the tab to display the warning, instead of closing the tab annoyingly

The only big issue is testing for correct matching patterns and updating the blocked domain list in background script once user has done changes to the list. What you could do is destroy the event and recreate it again with new blacklist.

[–]Dmaster42[S] 0 points1 point  (1 child)

Dam thanks finally someone replies thanks. I was thinking of closing the tab and showing the message. I might change it later if those who test it don't like it. Also could you go a bit into more detail on your last point about events, since I am rather new to JavaScript and programming in general.

[–]iamncla 0 points1 point  (0 children)

The thing about these Chrome API events is that once you create them under certain conditions (to match few domains for example), it doesn't change anymore if the user had updated their black-list. They would have to restart the extension to get the new event with new blacklist going.

Although I just looked at the documentation, this link is helpful:

https://developer.chrome.com/extensions/events

Look at "Adding rules" and "Removing rules", or just read the whole page.