use custom data for debugger
This commit is contained in:
parent
9f7754641e
commit
1c4ee91a1c
2 changed files with 68 additions and 45 deletions
|
|
@ -1,58 +1,82 @@
|
||||||
import countryLocales from './countryLocales'
|
import countryLocales from './countryLocales'
|
||||||
|
|
||||||
const attachTab = (tabId, ipData) => {
|
const attachTab = (tabId, ipData) => {
|
||||||
chrome.debugger.attach({ tabId: tabId }, '1.3', function () {
|
chrome.storage.sync.get(
|
||||||
if (!chrome.runtime.lastError) {
|
[
|
||||||
// chrome.debugger.sendCommand(
|
'ipData',
|
||||||
// { tabId: tabId },
|
'timezone',
|
||||||
// 'Emulation.clearGeolocationOverride'
|
'timezoneMatchIP',
|
||||||
// )
|
'lat',
|
||||||
|
'latitudeMatchIP',
|
||||||
|
'lon',
|
||||||
|
'longitudeMatchIP',
|
||||||
|
],
|
||||||
|
(result) => {
|
||||||
|
chrome.debugger.attach({ tabId: tabId }, '1.3', function () {
|
||||||
|
if (!chrome.runtime.lastError) {
|
||||||
|
// chrome.debugger.sendCommand(
|
||||||
|
// { tabId: tabId },
|
||||||
|
// 'Emulation.clearGeolocationOverride'
|
||||||
|
// )
|
||||||
|
|
||||||
// chrome.debugger.sendCommand(
|
// chrome.debugger.sendCommand(
|
||||||
// { tabId: tabId },
|
// { tabId: tabId },
|
||||||
// 'Emulation.clearIdleOverride'
|
// 'Emulation.clearIdleOverride'
|
||||||
// )
|
// )
|
||||||
|
|
||||||
chrome.debugger.sendCommand(
|
chrome.debugger.sendCommand(
|
||||||
{ tabId: tabId },
|
{ tabId: tabId },
|
||||||
'Emulation.setTimezoneOverride',
|
'Emulation.setTimezoneOverride',
|
||||||
{ timezoneId: ipData.timezone }
|
{
|
||||||
)
|
timezoneId: result.timezoneMatchIP
|
||||||
|
? result.ipData.timezone
|
||||||
|
: result.timezone,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
chrome.debugger.sendCommand(
|
chrome.debugger.sendCommand(
|
||||||
{ tabId: tabId },
|
{ tabId: tabId },
|
||||||
'Emulation.setLocaleOverride',
|
'Emulation.setLocaleOverride',
|
||||||
{ locale: countryLocales[ipData.countryCode].locale }
|
{ locale: countryLocales[result.ipData.countryCode].locale }
|
||||||
)
|
)
|
||||||
|
|
||||||
chrome.debugger.sendCommand(
|
const latitude = result.latMatchIP
|
||||||
{ tabId: tabId },
|
? result.ipData.lat
|
||||||
'Emulation.setGeolocationOverride',
|
: parseFloat(result.lat)
|
||||||
{
|
const longitude = result.lonMatchIP
|
||||||
latitude: ipData.lat,
|
? result.ipData.lon
|
||||||
longitude: ipData.lon,
|
: parseFloat(result.lon)
|
||||||
accuracy: 1,
|
|
||||||
|
console.log(latitude, longitude)
|
||||||
|
|
||||||
|
chrome.debugger.sendCommand(
|
||||||
|
{ tabId: tabId },
|
||||||
|
'Emulation.setGeolocationOverride',
|
||||||
|
{
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
accuracy: 1,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
chrome.debugger.sendCommand(
|
||||||
|
{ tabId: tabId },
|
||||||
|
'Emulation.setUserAgentOverride',
|
||||||
|
{
|
||||||
|
userAgent:
|
||||||
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.69',
|
||||||
|
}
|
||||||
|
// { acceptLanguage: "en-CA" },
|
||||||
|
// { platform: "WebTV OS" }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
)
|
})
|
||||||
|
|
||||||
chrome.debugger.sendCommand(
|
|
||||||
{ tabId: tabId },
|
|
||||||
'Emulation.setUserAgentOverride',
|
|
||||||
{
|
|
||||||
userAgent:
|
|
||||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.69',
|
|
||||||
}
|
|
||||||
// { acceptLanguage: "en-CA" },
|
|
||||||
// { platform: "WebTV OS" }
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
|
chrome.tabs.onUpdated.addListener((tabId, change, tab) => {
|
||||||
chrome.storage.sync.get(['ipData'], (result) => {
|
attachTab(tabId)
|
||||||
attachTab(tabId, result.ipData)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// const attachTabs = (ipData) => {
|
// const attachTabs = (ipData) => {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const DebugSettings = ({ type, ip }) => {
|
||||||
chrome.storage.sync.get([type, matchIPStorage], (result) => {
|
chrome.storage.sync.get([type, matchIPStorage], (result) => {
|
||||||
console.log(1, result)
|
console.log(1, result)
|
||||||
|
|
||||||
// result[matchIPStorage] && setMatchIP(result[matchIPStorage])
|
setMatchIP(result[matchIPStorage])
|
||||||
|
|
||||||
if (result[matchIPStorage]) {
|
if (result[matchIPStorage]) {
|
||||||
setValue(ip[type])
|
setValue(ip[type])
|
||||||
|
|
@ -50,7 +50,6 @@ const DebugSettings = ({ type, ip }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeTextValue = (e) => {
|
const changeTextValue = (e) => {
|
||||||
console.log(e.target.value)
|
|
||||||
chrome.storage.sync.set({ [type]: e.target.value })
|
chrome.storage.sync.set({ [type]: e.target.value })
|
||||||
setValue(e.target.value)
|
setValue(e.target.value)
|
||||||
if (matchIP) {
|
if (matchIP) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue