Chrome Extension To Redirect To Url With Parameter
I'm attempting to create a Chrome extension which will add a parameter to the end of a URL if the URL matches a given pattern (*://*.mydomain.com/s/*). Below is the manifest file a
Solution 1:
- Use debugger - click your extension's
background page
on chrome://extensions page and switch to theSources
panel. - To obtain the url use onBeforeRequest's callback parameter
- Check if the url is already modified.
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
return {
redirectUrl: details.url +
(details.url.indexOf("?") == -1 ? "?" : "") +
(details.url.indexOf("&style=gridview") == -1 ? "&style=gridview" : "")
};
},
{urls: ['*://*.mydomain.com/s/*'], types: ['main_frame']},
['blocking']
);
Post a Comment for "Chrome Extension To Redirect To Url With Parameter"