This commit is contained in:
cilame 2022-10-01 19:46:38 +08:00
parent b673866848
commit 47ffbd755b
5 changed files with 24 additions and 3 deletions

View File

@ -313,4 +313,13 @@ function get_html(url){
head.append(insert_script) head.append(insert_script)
} }
return $.html() return $.html()
} }
chrome.storage.local.get(['config-hook-global'], function(e){
chrome.browserAction.setBadgeBackgroundColor({color: '#BC1717'});
if (e['config-hook-global']){
chrome.browserAction.setBadgeText({text: 'v'});
}else{
chrome.browserAction.setBadgeText({text: ''});
}
})

View File

@ -444,6 +444,12 @@ document.querySelectorAll("input").forEach(function(v){
}) })
v.addEventListener("change", function (e) { v.addEventListener("change", function (e) {
if (v.type == 'checkbox'){ 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({ chrome.storage.local.set({
[e.target.dataset.key]: e.target.checked [e.target.dataset.key]: e.target.checked
}) })

View File

@ -124,7 +124,7 @@
<label class="switch"> <label class="switch">
<input type="checkbox" data-key="config-hook-new-tab"><div class="slider"></div> <input type="checkbox" data-key="config-hook-new-tab"><div class="slider"></div>
</label> </label>
<div style="float: right; padding: 10px">用覆盖newTab页</div> <div style="float: right; padding: 10px">用覆盖newTab页</div>
<label class="switch"> <label class="switch">
<input type="checkbox" data-key="config-myinject_toggle"><div class="slider"></div> <input type="checkbox" data-key="config-myinject_toggle"><div class="slider"></div>
</label> </label>

View File

@ -9,6 +9,12 @@ document.querySelectorAll("input").forEach(function(v){
}) })
v.addEventListener("change", function (e) { v.addEventListener("change", function (e) {
if (v.type == 'checkbox'){ 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({ chrome.storage.local.set({
[e.target.dataset.key]: e.target.checked [e.target.dataset.key]: e.target.checked
}) })

View File

@ -1,5 +1,5 @@
chrome.storage.local.get(["config-hook-new-tab"], function(e) { chrome.storage.local.get(["config-hook-new-tab"], function(e) {
if(e['config-hook-new-tab']) { if(!e['config-hook-new-tab']) {
chrome.tabs.update({ url: "chrome-search://local-ntp/local-ntp.html" }) chrome.tabs.update({ url: "chrome-search://local-ntp/local-ntp.html" })
}else{ }else{
runall() runall()