From 47ffbd755b9858f51a4e35152fa777f5e1bf3fe0 Mon Sep 17 00:00:00 2001 From: cilame Date: Sat, 1 Oct 2022 19:46:38 +0800 Subject: [PATCH] add --- background.js | 11 ++++++++++- options.js | 6 ++++++ popup.html | 2 +- popup.js | 6 ++++++ tools/astexplorer_babel.js | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index b42d576..963b709 100644 --- a/background.js +++ b/background.js @@ -313,4 +313,13 @@ function get_html(url){ head.append(insert_script) } return $.html() -} \ No newline at end of file +} + +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: ''}); + } +}) \ No newline at end of file diff --git a/options.js b/options.js index 5d8c4a5..2bf7d09 100644 --- a/options.js +++ b/options.js @@ -444,6 +444,12 @@ 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 }) diff --git a/popup.html b/popup.html index 1c82e10..1a58db8 100644 --- a/popup.html +++ b/popup.html @@ -124,7 +124,7 @@ -
禁用覆盖newTab页
+
启用覆盖newTab页
diff --git a/popup.js b/popup.js index 604b0f8..78557f9 100644 --- a/popup.js +++ b/popup.js @@ -9,6 +9,12 @@ 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 }) diff --git a/tools/astexplorer_babel.js b/tools/astexplorer_babel.js index 873bb26..b3e87bb 100644 --- a/tools/astexplorer_babel.js +++ b/tools/astexplorer_babel.js @@ -1,5 +1,5 @@ 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" }) }else{ runall()