From 12bf84171ca9e7b08216c6bc0db411fd30056937 Mon Sep 17 00:00:00 2001 From: cilame Date: Thu, 28 Jul 2022 07:35:01 +0800 Subject: [PATCH] add --- background.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/background.js b/background.js index aee6c10..a1d8ce4 100644 --- a/background.js +++ b/background.js @@ -17,6 +17,42 @@ chrome.contextMenus.create({ AttachDebugger(); } }); +// var cache_tabid_new = {} +// var cache_tabid_att = {} +// var debug_tab = false +// function attach_tab_debug(tabId, changeInfo, tab) { +// if (!changeInfo.url || changeInfo.url.indexOf('chrome://') == 0) return +// if (!debug_tab) return +// cache_tabid_new[tabId] = 1 +// var tabids = Object.keys(cache_tabid_new) +// for (var i = 0; i < tabids.length; i++) { +// if (cache_tabid_new[tabids[i]] == 1 && !cache_tabid_att[tabids[i]]){ +// cache_tabid_att[tabids[i]] = 1 +// var currtab = { tabId: +tabids[i] }; +// chrome.debugger.attach(currtab, "1.2", function () { +// chrome.debugger.sendCommand(currtab, "Page.enable", {}, function(){}); +// chrome.debugger.sendCommand(currtab, "Page.addScriptToEvaluateOnNewDocument", { +// source: "console.log(123)" +// }, function(){}); +// }); +// } +// } +// } +// chrome.tabs.onUpdated.addListener(attach_tab_debug); +// chrome.debugger.onDetach.addListener(function(){ debug_tab = false }) +// chrome.contextMenus.create({ +// title: "测试代码超前运行", +// contexts: ['all'], +// onclick: function(){ +// debug_tab = true +// chrome.tabs.query( +// { active: true, currentWindow: true }, +// function (tabs) { +// attach_tab_debug(tabs[0].id, {url: 'vilame'}) +// } +// ); +// } +// }); function sendCommand(method, params, source, chainfun){ chrome.debugger.sendCommand(source, method, params, function(result){ if (chrome.runtime.lastError) {