Added useragent masking
This commit is contained in:
parent
d47664b167
commit
1aa5c328b5
5 changed files with 80 additions and 35 deletions
|
|
@ -12,6 +12,7 @@ const attachTab = (tabId, ipData) => {
|
|||
'longitudeMatchIP',
|
||||
'locale',
|
||||
'localeMatchIP',
|
||||
'userAgent',
|
||||
],
|
||||
(result) => {
|
||||
chrome.debugger.attach({ tabId: tabId }, '1.3', function () {
|
||||
|
|
@ -36,6 +37,17 @@ const attachTab = (tabId, ipData) => {
|
|||
}
|
||||
)
|
||||
|
||||
console.log(
|
||||
result.localeMatchIP,
|
||||
countryLocales[result.ipData.countryCode].locale,
|
||||
result.locale
|
||||
)
|
||||
console.log(
|
||||
result.localeMatchIP
|
||||
? countryLocales[result.ipData.countryCode].locale
|
||||
: result.locale
|
||||
)
|
||||
|
||||
chrome.debugger.sendCommand(
|
||||
{ tabId: tabId },
|
||||
'Emulation.setLocaleOverride',
|
||||
|
|
@ -53,6 +65,12 @@ const attachTab = (tabId, ipData) => {
|
|||
? result.ipData.lon
|
||||
: parseFloat(result.lon)
|
||||
|
||||
console.log(
|
||||
result.latMatchIP,
|
||||
result.ipData.lat,
|
||||
parseFloat(result.lat)
|
||||
)
|
||||
|
||||
chrome.debugger.sendCommand(
|
||||
{ tabId: tabId },
|
||||
'Emulation.setGeolocationOverride',
|
||||
|
|
@ -63,16 +81,18 @@ const attachTab = (tabId, ipData) => {
|
|||
}
|
||||
)
|
||||
|
||||
if (result.userAgent) {
|
||||
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',
|
||||
userAgent: result.userAgent,
|
||||
}
|
||||
// { acceptLanguage: "en-CA" },
|
||||
// { platform: "WebTV OS" }
|
||||
)
|
||||
// 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.69',
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,5 @@
|
|||
import React, { useState, useEffect } from 'react'
|
||||
|
||||
const detachDebugger = () => {
|
||||
chrome.debugger.getTargets((tabs) => {
|
||||
for (const tab in tabs) {
|
||||
if (tabs[tab].attached && tabs[tab].tabId) {
|
||||
chrome.debugger.detach({ tabId: tabs[tab].tabId })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const DebugSettings = ({ type, title, ip }) => {
|
||||
const [value, setValue] = useState('')
|
||||
const [matchIP, setMatchIP] = useState(false)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,6 @@
|
|||
import React, { useState, useEffect, useRef } from 'react'
|
||||
import countryLocales from '../../utils/countryLocales'
|
||||
|
||||
const detachDebugger = () => {
|
||||
chrome.debugger.getTargets((tabs) => {
|
||||
for (const tab in tabs) {
|
||||
if (tabs[tab].attached && tabs[tab].tabId) {
|
||||
chrome.debugger.detach({ tabId: tabs[tab].tabId })
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const LocaleSettings = ({ ip }) => {
|
||||
const [value, setValue] = useState('')
|
||||
const [matchIP, setMatchIP] = useState(false)
|
||||
|
|
@ -20,10 +10,10 @@ const LocaleSettings = ({ ip }) => {
|
|||
if (ip) {
|
||||
locale.current = countryLocales[ip.countryCode].locale
|
||||
|
||||
chrome.storage.sync.get(['locale', 'localeMathIP'], (result) => {
|
||||
result.localeMathIP && setMatchIP(result.localeMathIP)
|
||||
chrome.storage.sync.get(['locale', 'localeMatchIP'], (result) => {
|
||||
result.localeMatchIP && setMatchIP(result.localeMatchIP)
|
||||
|
||||
if (result.localeMathIP) {
|
||||
if (result.localeMatchIP) {
|
||||
setValue(locale.current)
|
||||
chrome.storage.sync.set({ locale: locale.current })
|
||||
} else if (result.locale) {
|
||||
|
|
@ -37,13 +27,13 @@ const LocaleSettings = ({ ip }) => {
|
|||
chrome.storage.sync.set({ locale: e.target.value })
|
||||
setValue(e.target.value)
|
||||
if (matchIP) {
|
||||
chrome.storage.sync.set({ localeMathIP: !matchIP })
|
||||
chrome.storage.sync.set({ localeMatchIP: !matchIP })
|
||||
setMatchIP(!matchIP)
|
||||
}
|
||||
}
|
||||
|
||||
const toggleMatchIP = (e) => {
|
||||
chrome.storage.sync.set({ localeMathIP: !matchIP })
|
||||
chrome.storage.sync.set({ localeMatchIP: !matchIP })
|
||||
!matchIP && setValue(locale.current)
|
||||
setMatchIP(e.target.value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import Navbar from './Navbar'
|
|||
import IpSettings from './IpSettings'
|
||||
import DebugSettings from './DebugSettings'
|
||||
import LocaleSettings from './LocaleSettings'
|
||||
import UserAgentSettings from './UserAgentSettings'
|
||||
|
||||
const getIP = () =>
|
||||
fetch('http://ip-api.com/json/')
|
||||
|
|
@ -38,6 +39,7 @@ const Popup = () => {
|
|||
<DebugSettings type="lat" title="Latitude" ip={ip} />
|
||||
<DebugSettings type="lon" title="Longitude" ip={ip} />
|
||||
<LocaleSettings ip={ip} />
|
||||
<UserAgentSettings ip={ip} type="lat" title="Latitude" />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
43
src/pages/Popup/UserAgentSettings.js
Normal file
43
src/pages/Popup/UserAgentSettings.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import React, { useState, useEffect } from 'react'
|
||||
|
||||
const UserAgentSettings = () => {
|
||||
const [value, setUserAgent] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
chrome.storage.sync.get(['userAgent'], (result) => {
|
||||
if (result.userAgent) {
|
||||
setUserAgent(result.userAgent)
|
||||
}
|
||||
})
|
||||
}, [])
|
||||
|
||||
const changeTextValue = (e) => {
|
||||
chrome.storage.sync.set({ userAgent: e.target.value })
|
||||
setUserAgent(e.target.value)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
margin: '12px 0 0 0',
|
||||
}}
|
||||
>
|
||||
<label>
|
||||
<input
|
||||
type="text"
|
||||
value={value}
|
||||
onChange={changeTextValue}
|
||||
style={{
|
||||
width: '218px',
|
||||
margin: '0 5px 0 0',
|
||||
}}
|
||||
/>
|
||||
User Agent
|
||||
</label>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default UserAgentSettings
|
||||
Loading…
Add table
Reference in a new issue