I am writing a chromium browser extension and trying to change part of the URL in a GET request. But I do not understand how to return the modified parameter? It is important that only the parameter in the URL is changed, and the rest of the headers remain.
I need to change the β blabla β part to β stopbla β. For example:
Before -----: http://site.com/index.php?bla=blabla&end=false
Replacement is successful. But Fidler shows that the sent values ββhave not changed.
I cannot use the following construct, as it only works in onBeforeSendHeaders . And also because the URL parameter is outside the requestHeaders parameter:
return {requestHeaders: details.requestHeaders};
What am I doing wrong?
background.js (part)
var callback = function (details) { if (details.url.indexOf('blabla') > -1) { bkg.console.log('++ Yes: ' + JSON.stringify(details.url)); details.url = details.url.replace('blabla', 'stopbla'); } return {url: details.url}; }; var filter = {urls: ["http://*/*", "https://*/*"], tabId: currentTabId}; var opt_extraInfoSpec = ['requestBody', "blocking"]; chrome.webRequest.onBeforeRequest.addListener( callback, filter, opt_extraInfoSpec); manifest.json (part)
"permissions": [ "tabs","background", "webRequest", "webRequestBlocking", "*://*/"], "background": {"scripts": ["background.js"]}, 