I am trying to access the details for the current url within my chrome extension, however I cannot even console them out.
This is what I have:
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
console.log(details.url);
},
{urls: ['*://*.mySite.co.uk/*'], types: ['main_frame']},
['blocking']
);
Which returns nothing in the console.
I am wanting to redirect a user based on the parameters found in the url. so how do i:
1) get the current url
2) if already contains correct parameter (location=123) then do nothing
3) if not correct parameter of (location=123) then change whatever parameter there, so maybe regex like location=/location=(.*)&/
If would be awesome if I could get that in a function that outputs a new details so I could just o this:
redirectUrl: details.url {
redirectUrl: details.url
}
Thanks guys.
update
here is the permission section in my manifest file
"permissions": [
"tabs",
"webRequest",
"*://*.mySite.co.uk/*",
"webRequestBlocking"
],