I've made a chrome extension that uses an allow list of urls that you can visit, defined in extension option, if not your are redirected to a defined page.
I use declarativeNetRequest rules to handle the allow list.
So let say I only allow the site example.com and when visting any other site it will send me back to example.com, this works for most sites but some sites doesn't reload the page just change the DOM and alter the URL so the declarativeNetRequest isn't "firing". So can you detect the URL change and have it process the DynamicRules?
0:
action:
redirect: {url: 'https://example.com'}
type: "redirect"
condition:
isUrlFilterCaseSensitive: false
regexFilter: "^http"
resourceTypes: ['main_frame']
1:
action:
type: "allow"
condition:
isUrlFilterCaseSensitive: false
regexFilter: "^(?:[a-z0-9-_]+://)?(?:www.)?example.com(?:$|/.*$)"
resourceTypes: ['main_frame']
Example page I found is www.svt.se