javascript - remove CSP header from webview in chromeApp -


i'm trying remove csp header specific website.

the problem cant first request of webview.

the (webrequest api) available after webview started load, , cant first request.

and code below dose not work since starts listen late

** wierd part works if devtools of webview open :0

previewwebview.addeventlistener('loadstart', function () {   var headers_to_strip_lowercase = [         'content-security-policy',         'content-security-policy-report-only'     ];     previewwebview.request.onheadersreceived.addlistener(         function (details) {              return {                 responseheaders: details.responseheaders.filter(function (header) {                     return headers_to_strip_lowercase.indexof(header.name.tolowercase()) === -1;                 })             };         }, {             urls: ["<all_urls>"]         }, ["blocking", "responseheaders"]);  }); 

to work right beginning (i.e. first load), you'd need webview declarative webrequest api.

  var w1 = document.createelement('webview');   var headerremoverule = {     conditions: [       new chrome.webviewrequest.requestmatcher()     ],     actions: [       new chrome.webviewrequest.removeresponseheader({         name: 'x-robots-tag'       })     ]   };    // declarative webrequest api, call before loading webview.   w1.request.onrequest.addrules([headerremoverule]);   w1.src = 'https://jsbin.com/piwakil';   document.body.appendchild(w1); 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -