mirror of
https://git.mirrors.martin98.com/https://github.com/cilame/v_jstools
synced 2025-08-14 06:45:54 +08:00
add
This commit is contained in:
parent
12bf84171c
commit
229b91b703
@ -17,42 +17,6 @@ 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) {
|
||||
|
@ -121,6 +121,13 @@
|
||||
<HR>
|
||||
<textarea id='myinject' data-key="config-myinject" style="width: 100%; height: 500px"></textarea>
|
||||
<br/>
|
||||
<br/>
|
||||
<button id='add_script_in_all_document'>超前注入</button>
|
||||
<div>仅调式模式下可用</div>
|
||||
<div>对已经打开的 tab 标签页面(非空页面)进行超前注入,注入过程只有一次,并不会像是上面的注入模式那样可以动态修改代码,如果想要让修改后的代码生效就需要关闭调式模式重新打开。</div>
|
||||
<HR>
|
||||
<textarea id='myinject_2' data-key="config-myinject_2" style="width: 100%; height: 500px"></textarea>
|
||||
<br/>
|
||||
<!-- <div>修改代理:<input type="text" data-key="config-proxy_config" id="proxy_config"></div> -->
|
||||
</section>
|
||||
<section class="tab">
|
||||
|
58
options.js
58
options.js
@ -500,6 +500,15 @@ myinject.addEventListener("change", function(v){
|
||||
[v.target.dataset.key]: v.target.value
|
||||
})
|
||||
})
|
||||
var myinject_2 = document.getElementById('myinject_2');
|
||||
chrome.storage.local.get([myinject_2.dataset.key], function (result) {
|
||||
myinject_2.value = result[myinject_2.dataset.key] || '';
|
||||
})
|
||||
myinject_2.addEventListener("change", function(v){
|
||||
chrome.storage.local.set({
|
||||
[v.target.dataset.key]: v.target.value
|
||||
})
|
||||
})
|
||||
|
||||
var get_now = document.getElementById('get_now');
|
||||
get_now.addEventListener("click", function(){
|
||||
@ -553,7 +562,54 @@ proxy_js.addEventListener("click", function(){
|
||||
code_model.value = clear_mode(mk_proxy_code)
|
||||
})
|
||||
|
||||
var add_script_in_all_document = document.getElementById('add_script_in_all_document');
|
||||
add_script_in_all_document.addEventListener("click", function(){
|
||||
debug_tab = true
|
||||
chrome.tabs.query(
|
||||
{ active: true, currentWindow: true },
|
||||
function (tabs) {
|
||||
chrome.debugger.attach({ tabId: tabs[0].id }, "1.2", function(){});
|
||||
}
|
||||
);
|
||||
})
|
||||
|
||||
var cache_tabid_new = {}
|
||||
var cache_tabid_att = {}
|
||||
var debug_tab = false
|
||||
function attach_tab_debug(tabId){
|
||||
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: myinject_2.value
|
||||
}, function(){});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// function attach_tab_debug_update(tabId, changeInfo, tab) {
|
||||
// if (!changeInfo.url || changeInfo.url.indexOf('chrome://') == 0) return
|
||||
// if (!debug_tab) return
|
||||
// attach_tab_debug(tabId)
|
||||
// }
|
||||
function attach_tab_debug_active(tabIdobj){
|
||||
if (!debug_tab) return
|
||||
attach_tab_debug(tabIdobj.tabId)
|
||||
}
|
||||
// chrome.tabs.onUpdated.addListener(attach_tab_debug_update);
|
||||
chrome.tabs.onActivated.addListener(attach_tab_debug_active);
|
||||
chrome.debugger.onDetach.addListener(function(){
|
||||
cache_tabid_new = {}
|
||||
cache_tabid_att = {}
|
||||
debug_tab = false
|
||||
})
|
||||
|
||||
// var proxy_config = document.getElementById('proxy_config');
|
||||
// proxy_config.addEventListener("change", function(v){
|
||||
// v.target.value
|
||||
// })
|
||||
// })
|
||||
|
Loading…
x
Reference in New Issue
Block a user