0

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

SuperDOS
  • 301
  • 1
  • 3
  • 16
  • 1
    This API can't handle DOM changes. Use MutationObserver and [other methods](https://stackoverflow.com/a/39508954). – wOxxOm Jan 03 '22 at 14:13
  • Thanks added MutationObserver and triggered a location.reload(); when it detcted a change of url, will try some more if it's sufficient. – SuperDOS Jan 03 '22 at 14:49

0 Answers0