From 65dc85ee4f6cc39cb10660632780a6a407f34633 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Sun, 1 May 2022 20:52:33 -0400 Subject: [PATCH] Fixed bugs with user agent --- src/pages/Background/index.js | 36 ++++++++++++++-------------- src/pages/Popup/DebugSettings.js | 5 +++- src/pages/Popup/UserAgentSettings.js | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/pages/Background/index.js b/src/pages/Background/index.js index 7c41990..e075572 100644 --- a/src/pages/Background/index.js +++ b/src/pages/Background/index.js @@ -27,15 +27,15 @@ const attachTab = (tabId, ipData) => { // 'Emulation.clearIdleOverride' // ) - chrome.debugger.sendCommand( - { tabId: tabId }, - 'Emulation.setTimezoneOverride', - { - timezoneId: result.timezoneMatchIP - ? result.ipData.timezone - : result.timezone, - } - ) + if (result.timezone) { + chrome.debugger.sendCommand( + { tabId: tabId }, + 'Emulation.setTimezoneOverride', + { + timezoneId: result.timezone, + } + ) + } console.log( result.localeMatchIP, @@ -48,15 +48,15 @@ const attachTab = (tabId, ipData) => { : result.locale ) - chrome.debugger.sendCommand( - { tabId: tabId }, - 'Emulation.setLocaleOverride', - { - locale: result.localeMatchIP - ? countryLocales[result.ipData.countryCode].locale - : result.locale, - } - ) + if (result.locale) { + chrome.debugger.sendCommand( + { tabId: tabId }, + 'Emulation.setLocaleOverride', + { + locale: result.locale, + } + ) + } const latitude = result.latMatchIP ? result.ipData.lat diff --git a/src/pages/Popup/DebugSettings.js b/src/pages/Popup/DebugSettings.js index ed409d8..3ea74fa 100644 --- a/src/pages/Popup/DebugSettings.js +++ b/src/pages/Popup/DebugSettings.js @@ -30,7 +30,10 @@ const DebugSettings = ({ type, title, ip }) => { } const toggleMatchIP = (e) => { - chrome.storage.sync.set({ [matchIPStorage]: !matchIP }) + chrome.storage.sync.set({ + [type]: ip[type], + [matchIPStorage]: !matchIP, + }) !matchIP && setValue(ip[type]) setMatchIP(e.target.checked) } diff --git a/src/pages/Popup/UserAgentSettings.js b/src/pages/Popup/UserAgentSettings.js index 58db859..322c73b 100644 --- a/src/pages/Popup/UserAgentSettings.js +++ b/src/pages/Popup/UserAgentSettings.js @@ -29,7 +29,7 @@ const UserAgentSettings = () => { const randomUserAgent = userAgents[Math.floor(Math.random() * userAgents.length)] chrome.storage.sync.set({ - randomize: randomUserAgent, + userAgent: randomUserAgent, randomUA: e.target.checked, }) e.target.checked ? setUserAgent(randomUserAgent) : setUserAgent('')