This commit is contained in:
cilame 2021-10-21 21:29:37 +08:00
parent a2c20abeaf
commit 2abcfe7de2

View File

@ -36,10 +36,10 @@ chrome.debugger.onEvent.addListener(function (source, method, params){
if (result.body !== undefined){ // 收到的 result.body 是 base64(代码) 的代码,使用时需要解码一下 if (result.body !== undefined){ // 收到的 result.body 是 base64(代码) 的代码,使用时需要解码一下
chrome.storage.local.get(["config-fetch_hook"], function (res) { chrome.storage.local.get(["config-fetch_hook"], function (res) {
try{ try{
var respboby = atob(result.body) var respboby = decodeURIComponent(escape(atob(result.body)))
var replacer = eval((res["config-fetch_hook"]||'')+';fetch_hook') var replacer = eval((res["config-fetch_hook"]||'')+';fetch_hook')
if (params.resourceType == 'Script'){ var replbody = btoa(replacer(respboby, params.request.url)) } if (params.resourceType == 'Script'){ var replbody = btoa(replacer(respboby, params.request.url)) }
if (params.resourceType == 'Document'){ var replbody = btoa(html_script_replacer(respboby, replacer, params.request.url)) } if (params.resourceType == 'Document'){ var replbody = btoa(unescape(encodeURIComponent(html_script_replacer(respboby, replacer, params.request.url)))) }
fillfunc(replbody) } fillfunc(replbody) }
catch(e){ catch(e){
send_error_info_to_front(e.stack, currtab.tabId) send_error_info_to_front(e.stack, currtab.tabId)