Added custom locales to debugger

This commit is contained in:
z0ccc 2022-04-16 13:39:09 -04:00
parent 3a76962921
commit 8fc026b348

View file

@ -1,6 +1,5 @@
import countryLocales from '../../utils/countryLocales' import countryLocales from '../../utils/countryLocales'
const attachTab = (tabId, ipData) => { const attachTab = (tabId, ipData) => {
chrome.storage.sync.get( chrome.storage.sync.get(
[ [
@ -11,6 +10,8 @@ const attachTab = (tabId, ipData) => {
'latitudeMatchIP', 'latitudeMatchIP',
'lon', 'lon',
'longitudeMatchIP', 'longitudeMatchIP',
'locale',
'localeMatchIP',
], ],
(result) => { (result) => {
chrome.debugger.attach({ tabId: tabId }, '1.3', function () { chrome.debugger.attach({ tabId: tabId }, '1.3', function () {
@ -38,7 +39,11 @@ const attachTab = (tabId, ipData) => {
chrome.debugger.sendCommand( chrome.debugger.sendCommand(
{ tabId: tabId }, { tabId: tabId },
'Emulation.setLocaleOverride', 'Emulation.setLocaleOverride',
{ locale: countryLocales[result.ipData.countryCode].locale } {
locale: result.localeMatchIP
? countryLocales[result.ipData.countryCode].locale
: result.locale,
}
) )
const latitude = result.latMatchIP const latitude = result.latMatchIP
@ -48,8 +53,6 @@ const attachTab = (tabId, ipData) => {
? result.ipData.lon ? result.ipData.lon
: parseFloat(result.lon) : parseFloat(result.lon)
console.log(latitude, longitude)
chrome.debugger.sendCommand( chrome.debugger.sendCommand(
{ tabId: tabId }, { tabId: tabId },
'Emulation.setGeolocationOverride', 'Emulation.setGeolocationOverride',