location page changes
This commit is contained in:
parent
15acdc0a38
commit
271a70f856
16 changed files with 217 additions and 123 deletions
|
|
@ -1,18 +1,18 @@
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { Box } from 'theme-ui'
|
import { Box } from 'theme-ui'
|
||||||
|
|
||||||
import getIP from '../../../utils/getIP'
|
import getIP from '../../../utils/getIp'
|
||||||
|
|
||||||
interface LocationPageProps {
|
interface LocationPageProps {
|
||||||
tab: string
|
tab: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddressAutofillPage = ({ tab }: LocationPageProps) => {
|
const AutofillPage = ({ tab }: LocationPageProps) => {
|
||||||
const [ip, setIP] = useState(null)
|
const [ip, setIP] = useState(null)
|
||||||
const [configuration, setConfiguration] = useState('default')
|
const [configuration, setConfiguration] = useState('default')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
chrome.storage.sync.get(['configuration', 'ipData'], (storage) => {
|
chrome.storage.local.get(['configuration', 'ipData'], (storage) => {
|
||||||
storage.configuration && setConfiguration(storage.configuration)
|
storage.configuration && setConfiguration(storage.configuration)
|
||||||
if (storage.ipData) {
|
if (storage.ipData) {
|
||||||
setIP(storage.ipData)
|
setIP(storage.ipData)
|
||||||
|
|
@ -25,12 +25,12 @@ const AddressAutofillPage = ({ tab }: LocationPageProps) => {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: tab === 'addressAutofill' ? 'block' : 'none',
|
display: tab === 'autofill' ? 'block' : 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box sx={{ fontSize: '20px', mb: '8px' }}>Address Autofill</Box>
|
<Box sx={{ fontSize: '20px', mb: '8px' }}>Autofill Values</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddressAutofillPage
|
export default AutofillPage
|
||||||
|
|
@ -14,7 +14,7 @@ const ConfigurationSelect = ({
|
||||||
}: ConfigurationSelectProps) => {
|
}: ConfigurationSelectProps) => {
|
||||||
const changeConfiguration = (e: ChangeEvent<HTMLSelectElement>) => {
|
const changeConfiguration = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
chrome.storage.sync.set({
|
chrome.storage.local.set({
|
||||||
configuration: e.target.value,
|
configuration: e.target.value,
|
||||||
})
|
})
|
||||||
setConfiguration(e.target.value)
|
setConfiguration(e.target.value)
|
||||||
|
|
@ -30,16 +30,12 @@ const ConfigurationSelect = ({
|
||||||
onChange={changeConfiguration}
|
onChange={changeConfiguration}
|
||||||
mb={'8px'}
|
mb={'8px'}
|
||||||
>
|
>
|
||||||
<option value="none">None</option>
|
|
||||||
<option value="match">Match IP</option>
|
|
||||||
<option value="custom">Custom</option>
|
<option value="custom">Custom</option>
|
||||||
<optgroup label="Locations">
|
|
||||||
{Object.keys(configurations).map((key) => (
|
{Object.keys(configurations).map((key) => (
|
||||||
<option value={key} key={key}>
|
<option value={key} key={key}>
|
||||||
{configurations[key].name}
|
{configurations[key].name}
|
||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</optgroup>
|
|
||||||
</Select>
|
</Select>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { Dispatch, SetStateAction } from 'react'
|
import { Dispatch, SetStateAction } from 'react'
|
||||||
import { Flex, Button, Text } from 'theme-ui'
|
import { Flex, Button, Text } from 'theme-ui'
|
||||||
import detachDebugger from '../../../utils/detachDebugger'
|
import detachDebugger from '../../../utils/detachDebugger'
|
||||||
import getIP from '../../../utils/getIP'
|
import getIp from '../../../utils/getIp'
|
||||||
|
import { ipData } from '../../../types'
|
||||||
|
|
||||||
const getFlagEmoji = (countryCode: string) => {
|
const getFlagEmoji = (countryCode: string) => {
|
||||||
const codePoints = countryCode
|
const codePoints = countryCode
|
||||||
|
|
@ -13,16 +14,16 @@ const getFlagEmoji = (countryCode: string) => {
|
||||||
|
|
||||||
interface IPDataProps {
|
interface IPDataProps {
|
||||||
ip: any
|
ip: any
|
||||||
setIP: Dispatch<SetStateAction<null>>
|
setIp: Dispatch<SetStateAction<ipData | undefined>>
|
||||||
}
|
}
|
||||||
|
|
||||||
const IPData = ({ ip, setIP }: IPDataProps) => {
|
const IpData = ({ ip, setIp }: IPDataProps) => {
|
||||||
return (
|
return (
|
||||||
<Flex sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
|
<Flex sx={{ justifyContent: 'space-between', alignItems: 'center' }}>
|
||||||
<Text>{ip && `${ip.query} ${getFlagEmoji(ip.countryCode)}`}</Text>
|
<Text>{ip && `${ip.query} ${getFlagEmoji(ip.countryCode)}`}</Text>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
Promise.resolve(getIP()).then((ipData) => setIP(ipData))
|
Promise.resolve(getIp()).then((ipData) => setIp(ipData))
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
@ -32,4 +33,4 @@ const IPData = ({ ip, setIP }: IPDataProps) => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IPData
|
export default IpData
|
||||||
|
|
@ -11,55 +11,55 @@ import detachDebugger from '../../../utils/detachDebugger'
|
||||||
import { Label, Input } from 'theme-ui'
|
import { Label, Input } from 'theme-ui'
|
||||||
|
|
||||||
interface LocationInputProps {
|
interface LocationInputProps {
|
||||||
type: string
|
name: string
|
||||||
title: string
|
title: string
|
||||||
ip: any
|
// ip: any
|
||||||
configuration: string
|
value: string
|
||||||
setConfiguration: Dispatch<SetStateAction<string>>
|
setValue: Dispatch<SetStateAction<string>>
|
||||||
}
|
}
|
||||||
|
|
||||||
const LocationInput = ({
|
const LocationInput = ({
|
||||||
type,
|
name,
|
||||||
title,
|
title,
|
||||||
ip,
|
// ip,
|
||||||
configuration,
|
value,
|
||||||
setConfiguration,
|
setValue,
|
||||||
}: LocationInputProps) => {
|
}: LocationInputProps) => {
|
||||||
const [value, setValue] = useState('')
|
// const [value, setValue] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (configuration === 'none') {
|
// if (configuration === 'none') {
|
||||||
setValue('')
|
// setValue('')
|
||||||
chrome.storage.sync.set({ [type]: '' })
|
// chrome.storage.local.set({ [type]: '' })
|
||||||
} else if (configuration === 'match') {
|
// } else if (configuration === 'match') {
|
||||||
if (ip) {
|
// if (ip) {
|
||||||
const ipTypeValue =
|
// const ipTypeValue =
|
||||||
type === 'locale' ? countryLocales[ip.countryCode].locale : ip[type]
|
// type === 'locale' ? countryLocales[ip.countryCode].locale : ip[type]
|
||||||
setValue(ipTypeValue)
|
// setValue(ipTypeValue)
|
||||||
chrome.storage.sync.set({ [type]: ipTypeValue })
|
// chrome.storage.local.set({ [type]: ipTypeValue })
|
||||||
}
|
// }
|
||||||
} else if (configuration === 'custom') {
|
// } else if (configuration === 'custom') {
|
||||||
chrome.storage.sync.get([type], (storage) => {
|
// chrome.storage.local.get([type], (storage) => {
|
||||||
storage[type] && setValue(storage[type])
|
// storage[type] && setValue(storage[type])
|
||||||
})
|
// })
|
||||||
} else if (configuration !== 'default') {
|
// } else if (configuration !== 'default') {
|
||||||
setValue(configurations[configuration][type])
|
// setValue(configurations[configuration][type])
|
||||||
chrome.storage.sync.set({ [type]: configurations[configuration][type] })
|
// chrome.storage.local.set({ [type]: configurations[configuration][type] })
|
||||||
}
|
// }
|
||||||
}, [ip, configuration, type, value])
|
// }, [name, value])
|
||||||
|
|
||||||
const changeTextValue = (e: ChangeEvent<HTMLInputElement>) => {
|
const changeTextValue = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
detachDebugger()
|
// detachDebugger()
|
||||||
chrome.storage.sync.set({ [type]: e.target.value })
|
// chrome.storage.local.set({ [type]: e.target.value })
|
||||||
setValue(e.target.value)
|
setValue(e.target.value)
|
||||||
chrome.storage.sync.set({ configuration: 'custom' })
|
// chrome.storage.local.set({ configuration: 'custom' })
|
||||||
setConfiguration('custom')
|
// setConfiguration('custom')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Label htmlFor={type}>{title}</Label>
|
<Label htmlFor={name}>{title}</Label>
|
||||||
<Input name={type} value={value} onChange={changeTextValue} />
|
<Input name={name} value={value} onChange={changeTextValue} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,159 @@
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect, ChangeEvent } from 'react'
|
||||||
import { Box } from 'theme-ui'
|
import { Box, Flex, Label, Radio } from 'theme-ui'
|
||||||
import LocationInput from './LocationInput'
|
import LocationInput from './LocationInput'
|
||||||
import ConfigurationSelect from './ConfigurationSelect'
|
import ConfigurationSelect from './ConfigurationSelect'
|
||||||
import IPData from './IPData'
|
import IpData from './IpData'
|
||||||
import getIP from '../../../utils/getIP'
|
import getIp from '../../../utils/getIp'
|
||||||
|
import detachDebugger from '../../../utils/detachDebugger'
|
||||||
|
import countryLocales from '../../../utils/countryLocales'
|
||||||
|
import { ipData } from '../../../types'
|
||||||
|
import configurations from '../../../utils/configurations'
|
||||||
|
|
||||||
interface LocationPageProps {
|
interface LocationPageProps {
|
||||||
tab: string
|
tab: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const LocationPage = ({ tab }: LocationPageProps) => {
|
const LocationPage = ({ tab }: LocationPageProps) => {
|
||||||
const [ip, setIP] = useState(null)
|
const [type, setType] = useState('default')
|
||||||
const [configuration, setConfiguration] = useState('default')
|
const [timezone, setTimezone] = useState('')
|
||||||
|
const [locale, setLocale] = useState('')
|
||||||
|
const [latitude, setLatitude] = useState('')
|
||||||
|
const [longitude, setLongitude] = useState('')
|
||||||
|
const [ip, setIp] = useState<ipData | undefined>(undefined)
|
||||||
|
const [configuration, setConfiguration] = useState('custom')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
chrome.storage.sync.get(['configuration', 'ipData'], (storage) => {
|
Promise.resolve(getIp()).then((ipData) => setIp(ipData))
|
||||||
storage.configuration && setConfiguration(storage.configuration)
|
|
||||||
if (storage.ipData) {
|
|
||||||
setIP(storage.ipData)
|
|
||||||
} else {
|
|
||||||
Promise.resolve(getIP()).then((ipData) => setIP(ipData))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (type === 'default') {
|
||||||
|
setTimezone('')
|
||||||
|
setLocale('')
|
||||||
|
setLatitude('')
|
||||||
|
setLongitude('')
|
||||||
|
chrome.storage.local.set({
|
||||||
|
timezone: '',
|
||||||
|
locale: '',
|
||||||
|
latitude: '',
|
||||||
|
longitude: '',
|
||||||
|
})
|
||||||
|
} else if (type === 'matchIp') {
|
||||||
|
if (ip) {
|
||||||
|
setTimezone(ip.timezone)
|
||||||
|
setLocale(countryLocales[ip.countryCode].locale)
|
||||||
|
setLatitude(`${ip.lat}`)
|
||||||
|
setLongitude(`${ip.lon}`)
|
||||||
|
chrome.storage.local.set({
|
||||||
|
timezone: ip.timezone,
|
||||||
|
locale: countryLocales[ip.countryCode].locale,
|
||||||
|
latitude: ip.lat,
|
||||||
|
longitude: ip.lon,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else if (type === 'custom') {
|
||||||
|
if (configuration !== 'custom') {
|
||||||
|
setTimezone(configurations[configuration].timezone)
|
||||||
|
setLocale(configurations[configuration].locale)
|
||||||
|
setLatitude(configurations[configuration].lat)
|
||||||
|
setLongitude(configurations[configuration].lon)
|
||||||
|
chrome.storage.local.set({
|
||||||
|
timezone: configurations[configuration].timezone,
|
||||||
|
locale: configurations[configuration].locale,
|
||||||
|
latitude: configurations[configuration].lat,
|
||||||
|
longitude: configurations[configuration].lon,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// setLocale(countryLocales[ip.countryCode].locale)
|
||||||
|
// setLatitude(`${ip.lat}`)
|
||||||
|
// setLongitude(`${ip.lon}`)
|
||||||
|
// chrome.storage.local.set({
|
||||||
|
// timezone: ip.timezone,
|
||||||
|
// locale: countryLocales[ip.countryCode].locale,
|
||||||
|
// latitude: ip.lat,
|
||||||
|
// longitude: ip.lon,
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
}, [configuration, ip, type])
|
||||||
|
|
||||||
|
const changeType = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
// detachDebugger()
|
||||||
|
// e.target.value === 'none' && setUserAgent('')
|
||||||
|
// chrome.storage.local.set({ type: e.target.value })
|
||||||
|
setType(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: tab === 'location' ? 'block' : 'none',
|
display: tab === 'location' ? 'block' : 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box sx={{ fontSize: '20px', mb: '8px' }}>Location Data</Box>
|
<Box sx={{ fontSize: '20px', mb: '12px' }}>Location Data</Box>
|
||||||
|
<Flex
|
||||||
|
sx={{
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
mb: '8px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Label>
|
||||||
|
<Radio
|
||||||
|
name="locationType"
|
||||||
|
value="default"
|
||||||
|
onChange={changeType}
|
||||||
|
checked={type === 'default'}
|
||||||
|
/>
|
||||||
|
Default
|
||||||
|
</Label>
|
||||||
|
<Label>
|
||||||
|
<Radio
|
||||||
|
name="locationType"
|
||||||
|
value="matchIp"
|
||||||
|
onChange={changeType}
|
||||||
|
checked={type === 'matchIp'}
|
||||||
|
/>
|
||||||
|
Match IP
|
||||||
|
</Label>
|
||||||
|
<Label>
|
||||||
|
<Radio
|
||||||
|
name="locationType"
|
||||||
|
value="custom"
|
||||||
|
onChange={changeType}
|
||||||
|
checked={type === 'custom'}
|
||||||
|
/>
|
||||||
|
Custom
|
||||||
|
</Label>
|
||||||
|
</Flex>
|
||||||
|
{type === 'matchIp' && <IpData ip={ip} setIp={setIp} />}
|
||||||
|
{type === 'custom' && (
|
||||||
<ConfigurationSelect
|
<ConfigurationSelect
|
||||||
configuration={configuration}
|
configuration={configuration}
|
||||||
setConfiguration={setConfiguration}
|
setConfiguration={setConfiguration}
|
||||||
/>
|
/>
|
||||||
{configuration === 'match' && <IPData ip={ip} setIP={setIP} />}
|
)}
|
||||||
<LocationInput
|
<LocationInput
|
||||||
type="timezone"
|
name="timezone"
|
||||||
title="Timezone"
|
title="Timezone"
|
||||||
ip={ip}
|
value={timezone}
|
||||||
configuration={configuration}
|
setValue={setTimezone}
|
||||||
setConfiguration={setConfiguration}
|
|
||||||
/>
|
/>
|
||||||
<LocationInput
|
<LocationInput
|
||||||
type="locale"
|
name="locale"
|
||||||
title="Locale"
|
title="Locale"
|
||||||
ip={ip}
|
value={locale}
|
||||||
configuration={configuration}
|
setValue={setLocale}
|
||||||
setConfiguration={setConfiguration}
|
|
||||||
/>
|
/>
|
||||||
<LocationInput
|
<LocationInput
|
||||||
type="lat"
|
name="lat"
|
||||||
title="Latitude"
|
title="Latitude"
|
||||||
ip={ip}
|
value={latitude}
|
||||||
configuration={configuration}
|
setValue={setLatitude}
|
||||||
setConfiguration={setConfiguration}
|
|
||||||
/>
|
/>
|
||||||
<LocationInput
|
<LocationInput
|
||||||
type="lon"
|
name="lon"
|
||||||
title="Longitude"
|
title="Longitude"
|
||||||
ip={ip}
|
value={longitude}
|
||||||
configuration={configuration}
|
setValue={setLongitude}
|
||||||
setConfiguration={setConfiguration}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const SettingsPage = ({ tab }: LocationPageProps) => {
|
||||||
const [isWebRtcDisabled, setIsWebRtcDisabled] = useState(false)
|
const [isWebRtcDisabled, setIsWebRtcDisabled] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
chrome.storage.sync.get(['isWebRtcDisabled'], (storage) => {
|
chrome.storage.local.get(['isWebRtcDisabled'], (storage) => {
|
||||||
storage.isWebRtcDisabled && setIsWebRtcDisabled(storage.isWebRtcDisabled)
|
storage.isWebRtcDisabled && setIsWebRtcDisabled(storage.isWebRtcDisabled)
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const UserAgentSelect = ({
|
||||||
}: ConfigurationSelectProps) => {
|
}: ConfigurationSelectProps) => {
|
||||||
const changeConfiguration = (e: ChangeEvent<HTMLSelectElement>) => {
|
const changeConfiguration = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
chrome.storage.sync.set({
|
chrome.storage.local.set({
|
||||||
configuration: e.target.value,
|
configuration: e.target.value,
|
||||||
})
|
})
|
||||||
setConfiguration(e.target.value)
|
setConfiguration(e.target.value)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
const [userAgent, setUserAgent] = useState('')
|
const [userAgent, setUserAgent] = useState('')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
chrome.storage.sync.get(
|
chrome.storage.local.get(
|
||||||
['type', 'operatingSystem', 'browser', 'userAgent'],
|
['type', 'operatingSystem', 'browser', 'userAgent'],
|
||||||
(storage) => {
|
(storage) => {
|
||||||
storage.type && setType(storage.type)
|
storage.type && setType(storage.type)
|
||||||
|
|
@ -27,7 +27,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
chrome.storage.sync.set({ userAgent })
|
chrome.storage.local.set({ userAgent })
|
||||||
}, [userAgent])
|
}, [userAgent])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -37,24 +37,24 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
const changeType = (e: ChangeEvent<HTMLInputElement>) => {
|
const changeType = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
e.target.value === 'none' && setUserAgent('')
|
e.target.value === 'none' && setUserAgent('')
|
||||||
chrome.storage.sync.set({ type: e.target.value })
|
chrome.storage.local.set({ type: e.target.value })
|
||||||
setType(e.target.value)
|
setType(e.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeOperatingSystem = (e: ChangeEvent<HTMLSelectElement>) => {
|
const changeOperatingSystem = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
chrome.storage.sync.set({ operatingSystem: e.target.value })
|
chrome.storage.local.set({ operatingSystem: e.target.value })
|
||||||
setOperatingSystem(e.target.value)
|
setOperatingSystem(e.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeBrowser = (e: ChangeEvent<HTMLSelectElement>) => {
|
const changeBrowser = (e: ChangeEvent<HTMLSelectElement>) => {
|
||||||
chrome.storage.sync.set({ browser: e.target.value })
|
chrome.storage.local.set({ browser: e.target.value })
|
||||||
setBrowser(e.target.value)
|
setBrowser(e.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeUserAgent = (e: ChangeEvent<HTMLInputElement>) => {
|
const changeUserAgent = (e: ChangeEvent<HTMLInputElement>) => {
|
||||||
detachDebugger()
|
detachDebugger()
|
||||||
chrome.storage.sync.set({ userAgent: e.target.value })
|
chrome.storage.local.set({ userAgent: e.target.value })
|
||||||
chrome.storage.sync.set({ type: 'custom' })
|
chrome.storage.local.set({ type: 'custom' })
|
||||||
setUserAgent(e.target.value)
|
setUserAgent(e.target.value)
|
||||||
setType('custom')
|
setType('custom')
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +78,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
value="none"
|
value="none"
|
||||||
onChange={changeType}
|
onChange={changeType}
|
||||||
checked={type === 'none'}
|
checked={type === 'none'}
|
||||||
/>{' '}
|
/>
|
||||||
None
|
None
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label>
|
||||||
|
|
@ -87,7 +87,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
value="preloaded"
|
value="preloaded"
|
||||||
onChange={changeType}
|
onChange={changeType}
|
||||||
checked={type === 'preloaded'}
|
checked={type === 'preloaded'}
|
||||||
/>{' '}
|
/>
|
||||||
Preloaded
|
Preloaded
|
||||||
</Label>
|
</Label>
|
||||||
<Label>
|
<Label>
|
||||||
|
|
@ -96,7 +96,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
|
||||||
value="custom"
|
value="custom"
|
||||||
onChange={changeType}
|
onChange={changeType}
|
||||||
checked={type === 'custom'}
|
checked={type === 'custom'}
|
||||||
/>{' '}
|
/>
|
||||||
Custom
|
Custom
|
||||||
</Label>
|
</Label>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const handleWebRtcPolicy = (value: string) => {
|
||||||
value,
|
value,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
chrome.storage.sync.set({
|
chrome.storage.local.set({
|
||||||
webRtcPolicy: value,
|
webRtcPolicy: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ const WebRtcPage = ({ tab }: LocationPageProps) => {
|
||||||
const [webRtcIp, setWebRtcIp] = useState([])
|
const [webRtcIp, setWebRtcIp] = useState([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
chrome.storage.sync.get(['webRtcPolicy'], (storage) => {
|
chrome.storage.local.get(['webRtcPolicy'], (storage) => {
|
||||||
storage.webRtcPolicy && setWebRtcPolicy(storage.webRtcPolicy)
|
storage.webRtcPolicy && setWebRtcPolicy(storage.webRtcPolicy)
|
||||||
})
|
})
|
||||||
}, [])
|
}, [])
|
||||||
|
|
@ -30,7 +30,7 @@ const WebRtcPage = ({ tab }: LocationPageProps) => {
|
||||||
display: tab === 'webRtc' ? 'block' : 'none',
|
display: tab === 'webRtc' ? 'block' : 'none',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box sx={{ fontSize: '20px', mb: '8px' }}>WebRTC</Box>
|
<Box sx={{ fontSize: '20px', mb: '8px' }}>WebRTC Policy</Box>
|
||||||
<Select
|
<Select
|
||||||
name="webRtcPolicy"
|
name="webRtcPolicy"
|
||||||
id="webRtcPolicy"
|
id="webRtcPolicy"
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@ import React, { useState } from 'react'
|
||||||
import { ThemeProvider, Flex, Box, Text } from 'theme-ui'
|
import { ThemeProvider, Flex, Box, Text } from 'theme-ui'
|
||||||
import { theme } from '../theme'
|
import { theme } from '../theme'
|
||||||
import {
|
import {
|
||||||
MapPin,
|
|
||||||
Home,
|
Home,
|
||||||
|
MapPin,
|
||||||
|
FileText,
|
||||||
MessageSquare,
|
MessageSquare,
|
||||||
Globe,
|
|
||||||
Sliders,
|
Sliders,
|
||||||
Settings,
|
Settings,
|
||||||
ExternalLink,
|
ExternalLink,
|
||||||
|
|
@ -14,11 +14,11 @@ import TabItem from './TabItem'
|
||||||
import LocationPage from './Pages/LocationPage'
|
import LocationPage from './Pages/LocationPage'
|
||||||
import UserAgentPage from './Pages/UserAgentPage'
|
import UserAgentPage from './Pages/UserAgentPage'
|
||||||
import SettingsPage from './Pages/SettingsPage'
|
import SettingsPage from './Pages/SettingsPage'
|
||||||
import AddressAutofillPage from './Pages/AddressAutofillPage'
|
import AutofillPage from './Pages/AutofillPage'
|
||||||
import WebRtcPage from './Pages/WebRtcPage'
|
import WebRtcPage from './Pages/WebRtcPage'
|
||||||
|
|
||||||
const Popup = () => {
|
const Popup = () => {
|
||||||
const [tab, setTab] = useState('webRtc')
|
const [tab, setTab] = useState('location')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
|
|
@ -42,9 +42,9 @@ const Popup = () => {
|
||||||
onClick={() => setTab('location')}
|
onClick={() => setTab('location')}
|
||||||
/>
|
/>
|
||||||
<TabItem
|
<TabItem
|
||||||
Icon={Home}
|
Icon={FileText}
|
||||||
active={tab === 'addressAutofill'}
|
active={tab === 'autofill'}
|
||||||
onClick={() => setTab('addressAutofill')}
|
onClick={() => setTab('autofill')}
|
||||||
/>
|
/>
|
||||||
<TabItem
|
<TabItem
|
||||||
Icon={MessageSquare}
|
Icon={MessageSquare}
|
||||||
|
|
@ -68,7 +68,7 @@ const Popup = () => {
|
||||||
</Flex>
|
</Flex>
|
||||||
<Box sx={{ m: '12px', width: '100%' }}>
|
<Box sx={{ m: '12px', width: '100%' }}>
|
||||||
<LocationPage tab={tab} />
|
<LocationPage tab={tab} />
|
||||||
<AddressAutofillPage tab={tab} />
|
<AutofillPage tab={tab} />
|
||||||
<WebRtcPage tab={tab} />
|
<WebRtcPage tab={tab} />
|
||||||
<UserAgentPage tab={tab} />
|
<UserAgentPage tab={tab} />
|
||||||
<SettingsPage tab={tab} />
|
<SettingsPage tab={tab} />
|
||||||
|
|
|
||||||
7
src/types.ts
Normal file
7
src/types.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export interface ipData {
|
||||||
|
query: string
|
||||||
|
timezone: string
|
||||||
|
countryCode: string
|
||||||
|
lat: number
|
||||||
|
lon: number
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const attachDebugger = (tabId: number) => {
|
const attachDebugger = (tabId: number) => {
|
||||||
chrome.storage.sync.get(
|
chrome.storage.local.get(
|
||||||
[
|
[
|
||||||
'ipData',
|
'ipData',
|
||||||
'timezone',
|
'timezone',
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ const configurations: any = {
|
||||||
},
|
},
|
||||||
berlin: {
|
berlin: {
|
||||||
name: 'Berlin',
|
name: 'Berlin',
|
||||||
|
|
||||||
timezone: 'Europe/Berlin',
|
timezone: 'Europe/Berlin',
|
||||||
locale: 'de-DE',
|
locale: 'de-DE',
|
||||||
lat: 52.520007,
|
lat: 52.520007,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
const getIP = () =>
|
const getIp = () =>
|
||||||
fetch('http://ip-api.com/json/')
|
fetch('http://ip-api.com/json/')
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((ipData) => {
|
.then((ipData) => {
|
||||||
chrome.storage.sync.set({ ipData })
|
chrome.storage.local.set({ ipData })
|
||||||
return ipData
|
return ipData
|
||||||
})
|
})
|
||||||
|
|
||||||
export default getIP
|
export default getIp
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const setAutofillAddress = () => {
|
const setAutofillAddress = () => {
|
||||||
chrome.storage.sync.get(['isWebRtcDisabled'], (storage) => {
|
chrome.storage.local.get(['isWebRtcDisabled'], (storage) => {
|
||||||
const value = storage.isWebRtcDisabled
|
const value = storage.isWebRtcDisabled
|
||||||
? 'default'
|
? 'default'
|
||||||
: 'disable_non_proxied_udp'
|
: 'disable_non_proxied_udp'
|
||||||
|
|
@ -10,7 +10,7 @@ const setAutofillAddress = () => {
|
||||||
value,
|
value,
|
||||||
},
|
},
|
||||||
() => {
|
() => {
|
||||||
chrome.storage.sync.set({
|
chrome.storage.local.set({
|
||||||
isWebRtcDisabled: !storage.isWebRtcDisabled,
|
isWebRtcDisabled: !storage.isWebRtcDisabled,
|
||||||
})
|
})
|
||||||
// chrome.privacy.network.webRTCIPHandlingPolicy.get({}, (s) => {
|
// chrome.privacy.network.webRTCIPHandlingPolicy.get({}, (s) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue