Intercept URL before unload with javascript or jquery -
i'm writing simple chrome plugin intercept new url before page unload , if contains specific string want actions , invalidate redirect! have no idea how do.. can me?
you can use onbeforerequest
event of webrequest
api chrome extensions:
chrome.webrequest.onbeforerequest.addlistener( function(details) { // actions // ... return {cancel: true}; }, // block requests matching url {urls: ["*://www.evil.com/*"]}, ["blocking"] );
just make sure have right permissions in manifest.json
file:
you must declare "webrequest" permission in extension manifest use web request api, along host permissions hosts network requests want access.
"permissions": [ "webrequest", "webrequestblocking", "*://*.google.com" ],
Comments
Post a Comment