mirror of
https://git.mirrors.martin98.com/https://github.com/cilame/v_jstools
synced 2025-04-23 06:09:50 +08:00
add
This commit is contained in:
parent
73b85cf3de
commit
29c464bfe0
@ -1,2 +1 @@
|
||||
// background.js
|
||||
|
||||
// background.js
|
@ -2,13 +2,13 @@
|
||||
"name": "v_jstools",
|
||||
"version": "0.0.0",
|
||||
"description": "v_jstools js hook工具",
|
||||
"permissions": ["storage", "activeTab", "tabs", "debugger", "storage"],
|
||||
"permissions": ["storage", "activeTab", "tabs", "debugger", "storage", "extension", "scripting"],
|
||||
"browser_action": {
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"background": {
|
||||
"scripts": ["background.js"],
|
||||
"persistent": false
|
||||
"persistent": true
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
|
@ -9,6 +9,8 @@
|
||||
<body style="width: 600px;">
|
||||
<label ><input type="checkbox" data-key="config-hook-test">test</label>
|
||||
<br/>
|
||||
<label ><input type="checkbox" data-key="config-hook-console">hook-console</label>
|
||||
<br/>
|
||||
<label ><input type="checkbox" data-key="config-hook-Function">hook-Function</label>
|
||||
<br/>
|
||||
<label ><input type="checkbox" data-key="config-hook-eval">hook-eval</label>
|
||||
@ -37,8 +39,8 @@
|
||||
<br/>
|
||||
<label ><input type="checkbox" data-key="config-hook-unescape">hook-unescape</label>
|
||||
<br/>
|
||||
|
||||
|
||||
<label ><input type="checkbox" data-key="config-hook-domobj">hook-domobj</label>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
26
popup.js
26
popup.js
@ -1,10 +1,22 @@
|
||||
// var background = chrome.extension.getBackgroundPage();
|
||||
// var gettabid = background.gettabid
|
||||
|
||||
function sendMessageToContentScript(message, callback){
|
||||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
||||
chrome.tabs.sendMessage(tabs[0].id, message, function(response){
|
||||
if(callback) callback(response);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll("input").forEach(function(v){
|
||||
chrome.storage.sync.get([v.dataset.key], function (result) {
|
||||
v.checked = result[v.dataset.key];
|
||||
})
|
||||
v.addEventListener("change", function (e) {
|
||||
chrome.storage.sync.set({
|
||||
[e.target.dataset.key]: e.target.checked
|
||||
})
|
||||
chrome.storage.sync.get([v.dataset.key], function (result) {
|
||||
v.checked = result[v.dataset.key];
|
||||
})
|
||||
v.addEventListener("change", function (e) {
|
||||
sendMessageToContentScript({[e.target.dataset.key]: e.target.checked})
|
||||
chrome.storage.sync.set({
|
||||
[e.target.dataset.key]: e.target.checked
|
||||
})
|
||||
})
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user