This commit is contained in:
cilame 2022-11-22 21:19:28 +08:00
parent 3b17e19251
commit a5247c571d
3 changed files with 53 additions and 20 deletions

View File

@ -369,14 +369,23 @@ function getLocalFileUrl(url) {
return ("data:" + (typeMap[type] || typeMap.txt) + ";charset=utf-8;base64," + base64);
}
chrome.storage.local.get(['config-hook-global'], function(e){
function sub_logger(){
chrome.storage.local.get([
'config-hook-global',
'config-myinject_toggle',
], function(e){
chrome.browserAction.setBadgeBackgroundColor({color: '#BC1717'});
var info = ''
if (e['config-hook-global']){
chrome.browserAction.setBadgeText({text: 'v'});
}else{
chrome.browserAction.setBadgeText({text: ''});
info += 'v'
}
})
if (e['config-myinject_toggle']){
info += 'i'
}
chrome.browserAction.setBadgeText({text: info});
})
}
sub_logger()
chrome.webRequest.onBeforeRequest.addListener(function (details) {
var url = details.url;

View File

@ -433,6 +433,23 @@ _mk_html(funcs_0, 'funcs_0', 0)
_mk_html(getsets_1, 'getsets_1', 1)
_mk_html(funcs_1, 'funcs_1', 1)
function sub_logger(){
chrome.storage.local.get([
'config-hook-global',
'config-myinject_toggle',
], function(e){
chrome.browserAction.setBadgeBackgroundColor({color: '#BC1717'});
var info = ''
if (e['config-hook-global']){
info += 'v'
}
if (e['config-myinject_toggle']){
info += 'i'
}
chrome.browserAction.setBadgeText({text: info});
})
}
document.querySelectorAll("input").forEach(function(v){
chrome.storage.local.get([v.dataset.key], function (result) {
if (v.type == 'checkbox'){
@ -445,14 +462,10 @@ document.querySelectorAll("input").forEach(function(v){
v.addEventListener("change", function (e) {
if (v.type == 'checkbox'){
// console.log(e.target.dataset.key, e.target.checked)
if (e.target.dataset.key == 'config-hook-global' && e.target.checked){
chrome.browserAction.setBadgeText({text: 'v'});
}else{
chrome.browserAction.setBadgeText({text: ''});
}
chrome.storage.local.set({
[e.target.dataset.key]: e.target.checked
})
sub_logger()
}
if (v.type == 'text' || v.type == 'password'){
chrome.storage.local.set({

View File

@ -1,3 +1,20 @@
function sub_logger(){
chrome.storage.local.get([
'config-hook-global',
'config-myinject_toggle',
], function(e){
chrome.browserAction.setBadgeBackgroundColor({color: '#BC1717'});
var info = ''
if (e['config-hook-global']){
info += 'v'
}
if (e['config-myinject_toggle']){
info += 'i'
}
chrome.browserAction.setBadgeText({text: info});
})
}
document.querySelectorAll("input").forEach(function(v){
chrome.storage.local.get([v.dataset.key], function (result) {
if (v.type == 'checkbox'){
@ -10,13 +27,6 @@ document.querySelectorAll("input").forEach(function(v){
v.addEventListener("change", function (e) {
if (v.type == 'checkbox'){
// console.log(e.target.dataset.key, e.target.checked)
if (e.target.dataset.key == 'config-hook-global'){
if (e.target.checked){
chrome.browserAction.setBadgeText({text: 'v'});
}else{
chrome.browserAction.setBadgeText({text: ''});
}
}
if (e.target.dataset.key == 'config-hook-log-toggle'){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'logtoggle', info: 'logtoggle'}}, function(response) {});
@ -25,6 +35,7 @@ document.querySelectorAll("input").forEach(function(v){
chrome.storage.local.set({
[e.target.dataset.key]: e.target.checked
})
sub_logger()
}
if (v.type == 'text'){
chrome.storage.local.set({