0

In my chrome extension, I modify the header before sending any HTTP request, using chrome.webRequest methods. There must be a way to achieve the same functionality without using chrome.webRequest but I can't seem to find any. Could anyone provide me with viable alternatives for it so I can check and modify headers before sending requests?

chrome.webRequest.onBeforeSendHeaders.addListener(function (req) {
  var customurl = req.url.substring(0, req.url.indexOf('/embed/'));
  var customRefererObject = { name: 'Referer', value: customurl };
  $.grep(req.requestHeaders, function (headers) {
    if (headers.name == 'Referer') {
      headers.value = customurl;
    }

In addition, I am modifying the headers from an Android webview. This post might be related.

Community
  • 1
  • 1
Maximus S
  • 10,759
  • 19
  • 75
  • 154

1 Answers1

0

Use window.location.href

Have a look at this: http://ntt.cc/2008/01/21/5-ways-to-redirect-url-with-javascript.html

cluster1
  • 4,968
  • 6
  • 32
  • 49