From fcea9f5b5fd9efcd7e7bdd6d26cd3877045cf0a6 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Fri, 6 May 2022 13:28:24 -0400 Subject: [PATCH] Save and load custom values --- src/pages/Popup/DebugSettings.js | 11 +++++++---- src/pages/Popup/Popup.jsx | 2 +- src/pages/Popup/UserAgentSettings.js | 1 - src/utils/detachDebugger.js | 1 - 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pages/Popup/DebugSettings.js b/src/pages/Popup/DebugSettings.js index 74229cc..d858c4c 100644 --- a/src/pages/Popup/DebugSettings.js +++ b/src/pages/Popup/DebugSettings.js @@ -6,24 +6,27 @@ const DebugSettings = ({ type, title, ip, profile, setProfile }) => { useEffect(() => { if (profile === 'match') { - console.log(ip) + console.log(1) + if (ip) { setValue(ip[type]) chrome.storage.sync.set({ [type]: ip[type] }) } } else if (profile === 'custom') { - console.log(111) + console.log(2) chrome.storage.sync.get([type], (result) => { + console.log(type) + console.log(result) result[type] && setValue(result[type]) }) - } else { + } else if (profile !== 'default') { setValue(profiles[profile][type]) chrome.storage.sync.set({ [type]: profiles[profile][type] }) } }, [ip, profile, type]) const changeTextValue = (e) => { - chrome.storage.sync.set({ [type]: e.target.value }) + chrome.storage.sync.set({ timezone: e.target.value }) setValue(e.target.value) chrome.storage.sync.set({ profile: 'custom' }) setProfile('custom') diff --git a/src/pages/Popup/Popup.jsx b/src/pages/Popup/Popup.jsx index 1fcd366..3f0239a 100644 --- a/src/pages/Popup/Popup.jsx +++ b/src/pages/Popup/Popup.jsx @@ -15,7 +15,7 @@ const getIP = () => const Popup = () => { const [ip, setIP] = useState(null) - const [profile, setProfile] = useState('none') + const [profile, setProfile] = useState('default') useEffect(() => { chrome.storage.sync.get(['profile', 'ipData'], (result) => { diff --git a/src/pages/Popup/UserAgentSettings.js b/src/pages/Popup/UserAgentSettings.js index 1dbef79..83479a0 100644 --- a/src/pages/Popup/UserAgentSettings.js +++ b/src/pages/Popup/UserAgentSettings.js @@ -35,7 +35,6 @@ const UserAgentSettings = () => { } const changeInterval = (e) => { - console.log(e.target.value) chrome.storage.sync.set({ interval: e.target.value }) setInterval(e.target.value) } diff --git a/src/utils/detachDebugger.js b/src/utils/detachDebugger.js index 7d0dab2..75cf5ba 100644 --- a/src/utils/detachDebugger.js +++ b/src/utils/detachDebugger.js @@ -1,6 +1,5 @@ const detachDebugger = () => { chrome.debugger.getTargets((tabs) => { - console.log(tabs) for (const tab in tabs) { if (tabs[tab].attached && tabs[tab].tabId) { chrome.debugger.detach({ tabId: tabs[tab].tabId })