chrome.webRequest.onBeforeSendHeaders.addListener(function callback(details){ //console.log(JSON.stringify(details)); var headers = details.requestHeaders, blockingResponse = {}; var newRef = "https://www.reddit.com/r/koreanvariety/comments/723mtd/i_created_this_website_that_streams_korean_shows/"; var hasRef = false; // Each header parameter is stored in an array. Since Chrome // makes no guarantee about the contents/order of this array, // you'll have to iterate through it to find for the // 'User-Agent' element for( var i = 0, l = headers.length; i < l; ++i ) { if( headers[i].name == 'Referer' ) { //headers[i].value = newRef; hasRef = true; break; } // If you want to modify other headers, this is the place to // do it. Either remove the 'break;' statement and add in more // conditionals or use a 'switch' statement on 'headers[i].name' } if (!hasRef) { headers.push({name:"Referer", value:newRef}); } // } blockingResponse.requestHeaders = headers; return blockingResponse; }, {urls: [ "https://goplay.anontpp.com/" ]},['requestHeaders','blocking']);