function GetTask() { fetch(TaskUrl) } chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { switch (request.type) { case MsgType.CONTENT: console.log(request); case MsgType.TIMEOUT: // sendResponse({type: "error"}) } sendResponse({type: MsgType.NEWURL, url: "https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser"}); }); // chrome.webRequest.onCompleted.addListener( // function (details) { // console.log(details); // console.log(document); // // return { responseHeaders: details.responseHeaders}; // }, // { // urls: [""], // types: [ // "main_frame", // "sub_frame", // "stylesheet", // "script", // "image", // "object", // "xmlhttprequest", // "other" // ] // }, // ["responseHeaders", "extraHeaders"] // ); // fetch('https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser').then(r => r.text()).then(result => { // // Result now contains the response text, do what you want... // console.log(result); // }) // chrome.webRequest.onBeforeRequest.addListener(function(data){ // // data contains request_body // return {redirectUrl: "https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser"}; // },{'urls':[""]},['blocking']);