javascript - Chrome extension that modifies response headers -


i working on extension modify response headers. did extension , think modifies header value, problem modified header value not appear in inspect element window (network tab).

the headers suppose change set-cookie headers , after code changes value can see new value cookie viewer extension (editthiscookie), behavior of content stays if cookie not modified (content modifies based on cookie value).

i attach code below of script , manifest file.

manifest.json

{   "manifest_version": 2,    "name": "getting started example",   "description": "getting started example",   "version": "1.0",    "browser_action": {     "default_icon": "assets/logo.png",     "default_popup": "index.html"   },    "background": {     "scripts": ["main.js"]   },    "permissions": [     "activetab",     "webrequest",     "webrequestblocking",     "*://*.domain.com/"   ] } 

main.js

var callback = function(details) {   if (details.type == "main_frame") {     process_headers(details);     console.log("finished processing headers request url: ", details.url);   }   var final_response_headers = details.responseheaders;   console.log(final_response_headers);   return {responseheaders: final_response_headers}; };  function process_headers(details) {   var responseheaders = details.responseheaders;   (var in responseheaders) {     var responseheader = responseheaders[i];     if (responseheader.name == "set-cookie") {       try_changing_value(responseheader);     }   } }  function try_changing_value(header) {   var value = header.value;   var expected_value = "sub_cookie1";   var viewed_count_index = value.indexof(expected_value);   if (viewed_count_index != -1) {     var two_points_index = value.indexof(":", viewed_count_index);     var comma_index = value.indexof(",", viewed_count_index);     var result = value.substring(0, two_points_index + 1) + "5" + value.substring(comma_index);     header.value = result;   } }  chrome.webrequest.onheadersreceived.addlistener(callback, {urls: ["<all_urls>"]}, ["blocking", "responseheaders"]); 

the original set-cookie header value looks this:

cookie=sub_cookie:5,sub_sub_cookie:0;version=1;comment=;domain=.domain.com;path=/;max-age=3600 

to sum up, why doesn't new value appear on inspect element network tab when checking response headers? no changed correctly?

many thanks


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -