Added platform input to user agent spoofing
This commit is contained in:
parent
92cc65fecf
commit
1258acdfeb
3 changed files with 91 additions and 61 deletions
|
|
@ -3,6 +3,7 @@ import { Box, Label, Radio, Flex, Select } from 'theme-ui'
|
||||||
import DebouncedInput from '../../Components/DebouncedInput'
|
import DebouncedInput from '../../Components/DebouncedInput'
|
||||||
import userAgents from '../../../utils/userAgents'
|
import userAgents from '../../../utils/userAgents'
|
||||||
import detachDebugger from '../../../utils/detachDebugger'
|
import detachDebugger from '../../../utils/detachDebugger'
|
||||||
|
import attachCurrentTab from '../../../utils/attachCurrentTab'
|
||||||
import Page from '../../Components/Page'
|
import Page from '../../Components/Page'
|
||||||
import CheckBox from '../../Components/CheckBox'
|
import CheckBox from '../../Components/CheckBox'
|
||||||
import FooterLink from '../../Components/FooterLink'
|
import FooterLink from '../../Components/FooterLink'
|
||||||
|
|
@ -16,15 +17,17 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
const [operatingSystem, setOperatingSystem] = useState('Windows')
|
const [operatingSystem, setOperatingSystem] = useState('Windows')
|
||||||
const [browser, setBrowser] = useState('Chrome')
|
const [browser, setBrowser] = useState('Chrome')
|
||||||
const [userAgent, setUserAgent] = useState(navigator.userAgent)
|
const [userAgent, setUserAgent] = useState(navigator.userAgent)
|
||||||
|
const [platform, setPlatform] = useState(navigator.platform)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
chrome.storage.local.get(
|
chrome.storage.local.get(
|
||||||
['userAgentType', 'operatingSystem', 'browser', 'userAgent'],
|
['userAgentType', 'operatingSystem', 'browser', 'userAgent', 'platform'],
|
||||||
(storage) => {
|
(storage) => {
|
||||||
storage.userAgentType && setUserAgentType(storage.userAgentType)
|
storage.userAgentType && setUserAgentType(storage.userAgentType)
|
||||||
storage.operatingSystem && setOperatingSystem(storage.operatingSystem)
|
storage.operatingSystem && setOperatingSystem(storage.operatingSystem)
|
||||||
storage.browser && setBrowser(storage.browser)
|
storage.browser && setBrowser(storage.browser)
|
||||||
storage.userAgent && setUserAgent(storage.userAgent)
|
storage.userAgent && setUserAgent(storage.userAgent)
|
||||||
|
storage.platform && setPlatform(storage.platform)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
@ -36,38 +39,45 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
|
|
||||||
if (e.target.value === 'default') {
|
if (e.target.value === 'default') {
|
||||||
setUserAgent(navigator.userAgent)
|
setUserAgent(navigator.userAgent)
|
||||||
|
setPlatform(navigator.platform)
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
userAgent: '',
|
userAgent: '',
|
||||||
|
platform: '',
|
||||||
})
|
})
|
||||||
} else if (e.target.value === 'preloaded') {
|
} else if (e.target.value === 'preloaded') {
|
||||||
setUserAgent(userAgents[operatingSystem][browser])
|
setUserAgent(userAgents[operatingSystem]['userAgents'][browser])
|
||||||
|
setPlatform(userAgents[operatingSystem]['platform'])
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
userAgent: userAgents[operatingSystem][browser],
|
userAgent: userAgents[operatingSystem]['userAgents'][browser],
|
||||||
|
platform: userAgents[operatingSystem]['platform'],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeOperatingSystem = (e: ChangeEvent<HTMLSelectElement>) => {
|
const changeOperatingSystem = async (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
setOperatingSystem(e.target.value)
|
setOperatingSystem(e.target.value)
|
||||||
setUserAgent(userAgents[e.target.value][browser])
|
setUserAgent(userAgents[e.target.value]['userAgents'][browser])
|
||||||
|
setPlatform(userAgents[e.target.value]['platform'])
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
userAgent: userAgents[e.target.value][browser],
|
userAgent: userAgents[e.target.value]['userAgents'][browser],
|
||||||
|
platform: userAgents[e.target.value]['platform'],
|
||||||
operatingSystem: e.target.value,
|
operatingSystem: e.target.value,
|
||||||
})
|
})
|
||||||
|
await attachCurrentTab()
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeBrowser = (e: ChangeEvent<HTMLSelectElement>) => {
|
const changeBrowser = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
setBrowser(e.target.value)
|
setBrowser(e.target.value)
|
||||||
setUserAgent(userAgents[operatingSystem][e.target.value])
|
setUserAgent(userAgents[operatingSystem]['userAgents'][e.target.value])
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
userAgent: userAgents[operatingSystem][e.target.value],
|
userAgent: userAgents[operatingSystem]['userAgents'][e.target.value],
|
||||||
browser: e.target.value,
|
browser: e.target.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeUserAgent = () => {
|
const changeTextInput = () => {
|
||||||
if (userAgentType !== 'custom') {
|
if (userAgentType !== 'custom') {
|
||||||
setUserAgentType('custom')
|
setUserAgentType('custom')
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
|
|
@ -139,11 +149,13 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
onChange={changeBrowser}
|
onChange={changeBrowser}
|
||||||
mb={'8px'}
|
mb={'8px'}
|
||||||
>
|
>
|
||||||
{Object.keys(userAgents[operatingSystem]).map((key) => (
|
{Object.keys(userAgents[operatingSystem]['userAgents']).map(
|
||||||
<option value={key} key={key}>
|
(key) => (
|
||||||
{key}
|
<option value={key} key={key}>
|
||||||
</option>
|
{key}
|
||||||
))}
|
</option>
|
||||||
|
)
|
||||||
|
)}
|
||||||
</Select>
|
</Select>
|
||||||
</Box>
|
</Box>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
@ -153,15 +165,15 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
title="User Agent"
|
title="User Agent"
|
||||||
value={userAgent}
|
value={userAgent}
|
||||||
setValue={setUserAgent}
|
setValue={setUserAgent}
|
||||||
onChange={changeUserAgent}
|
onChange={changeTextInput}
|
||||||
mb="12px"
|
mb="12px"
|
||||||
/>
|
/>
|
||||||
<DebouncedInput
|
<DebouncedInput
|
||||||
name="platform"
|
name="platform"
|
||||||
title="Platform"
|
title="Platform"
|
||||||
value={navigator.platform}
|
value={platform}
|
||||||
setValue={setUserAgent}
|
setValue={setPlatform}
|
||||||
onChange={changeUserAgent}
|
onChange={changeTextInput}
|
||||||
mb="12px"
|
mb="12px"
|
||||||
/>
|
/>
|
||||||
{userAgentType !== 'default' && (
|
{userAgentType !== 'default' && (
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ const attachDebugger = (tabId: number) => {
|
||||||
'locale',
|
'locale',
|
||||||
'localeMatchIP',
|
'localeMatchIP',
|
||||||
'userAgent',
|
'userAgent',
|
||||||
|
'platform',
|
||||||
],
|
],
|
||||||
(storage) => {
|
(storage) => {
|
||||||
|
console.log(storage)
|
||||||
if (
|
if (
|
||||||
storage.timezone ||
|
storage.timezone ||
|
||||||
storage.lat ||
|
storage.lat ||
|
||||||
|
|
@ -77,15 +79,15 @@ const attachDebugger = (tabId: number) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storage.userAgent) {
|
if (storage.userAgent || storage.platform) {
|
||||||
chrome.debugger.sendCommand(
|
chrome.debugger.sendCommand(
|
||||||
{ tabId: tabId },
|
{ tabId: tabId },
|
||||||
'Emulation.setUserAgentOverride',
|
'Emulation.setUserAgentOverride',
|
||||||
{
|
{
|
||||||
userAgent: storage.userAgent,
|
userAgent: storage.userAgent,
|
||||||
|
platform: storage.platform,
|
||||||
}
|
}
|
||||||
// { acceptLanguage: "en-CA" },
|
// { acceptLanguage: "en-CA" },
|
||||||
// { platform: "WebTV OS" }
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,70 @@
|
||||||
const userAgents: any = {
|
const userAgents: any = {
|
||||||
Windows: {
|
Windows: {
|
||||||
Chrome:
|
platform: 'Win32',
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
userAgents: {
|
||||||
Edge: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.62',
|
Chrome:
|
||||||
Firefox:
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0',
|
Edge: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.62',
|
||||||
Brave:
|
Firefox:
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/83.0.4103.116 Safari/537.36',
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0',
|
||||||
|
Brave:
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/83.0.4103.116 Safari/537.36',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Mac: {
|
Mac: {
|
||||||
Safari:
|
platform: 'MacIntel',
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15',
|
userAgents: {
|
||||||
Chrome:
|
Safari:
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15',
|
||||||
Edge: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.62',
|
Chrome:
|
||||||
Firefox:
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12.4; rv:102.0) Gecko/20100101 Firefox/102.0',
|
Edge: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 Edg/103.0.1264.62',
|
||||||
Brave:
|
Firefox:
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/83.0.4103.116 Safari/537.36',
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 12.4; rv:102.0) Gecko/20100101 Firefox/102.0',
|
||||||
|
Brave:
|
||||||
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/83.0.4103.116 Safari/537.36',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
Linux: {
|
Linux: {
|
||||||
Chrome:
|
platform: 'Linux x86_64',
|
||||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
userAgents: {
|
||||||
Edge: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.44',
|
Chrome:
|
||||||
Firefox:
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36',
|
||||||
'Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Firefox/102.0',
|
Edge: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36 Edg/100.0.1185.44',
|
||||||
Brave:
|
Firefox:
|
||||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/80.0.3987.99 Safari/537.36',
|
'Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101 Firefox/102.0',
|
||||||
|
Brave:
|
||||||
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Brave Chrome/80.0.3987.99 Safari/537.36',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Android: {
|
Android: {
|
||||||
Samsung:
|
platform: 'Linux armv8l',
|
||||||
'Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/16.0 Chrome/92.0.4515.166 Mobile Safari/537.36',
|
userAgents: {
|
||||||
Chrome:
|
Samsung:
|
||||||
'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.71 Mobile Safari/537.36',
|
'Mozilla/5.0 (Linux; Android 12; SAMSUNG SM-G991B) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/16.0 Chrome/92.0.4515.166 Mobile Safari/537.36',
|
||||||
Edge: 'Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.71 Mobile Safari/537.36 EdgA/100.0.1185.50',
|
Chrome:
|
||||||
Firefox:
|
'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.71 Mobile Safari/537.36',
|
||||||
'Mozilla/5.0 (Android 12; Mobile; rv:68.0) Gecko/68.0 Firefox/102.0',
|
Edge: 'Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.71 Mobile Safari/537.36 EdgA/100.0.1185.50',
|
||||||
Brave:
|
Firefox:
|
||||||
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Mobile Safari/537.36',
|
'Mozilla/5.0 (Android 12; Mobile; rv:68.0) Gecko/68.0 Firefox/102.0',
|
||||||
|
Brave:
|
||||||
|
'Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Mobile Safari/537.36',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
iOS: {
|
iOS: {
|
||||||
Safari:
|
platform: 'iPhone',
|
||||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1',
|
userAgents: {
|
||||||
Chrome:
|
Safari:
|
||||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1',
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Mobile/15E148 Safari/604.1',
|
||||||
Edge: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 EdgiOS/100.1185.50 Mobile/15E148 Safari/605.1.15',
|
Chrome:
|
||||||
Firefox:
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1',
|
||||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/102.0 Mobile/15E148 Safari/605.1.15',
|
Edge: 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 EdgiOS/100.1185.50 Mobile/15E148 Safari/605.1.15',
|
||||||
Brave:
|
Firefox:
|
||||||
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Brave/1.2.9 Mobile/14A5297c Safari/602.1.38',
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/102.0 Mobile/15E148 Safari/605.1.15',
|
||||||
|
Brave:
|
||||||
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Brave/1.2.9 Mobile/14A5297c Safari/602.1.38',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue