Skip to content

Commit

Permalink
dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
z0ccc committed Nov 7, 2022
1 parent 0f9706d commit 4f663f8
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 77 deletions.
42 changes: 23 additions & 19 deletions src/Popup/Components/FooterLink.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import { Link, Text } from 'theme-ui'
import { Link } from 'theme-ui'

interface FooterLinkProps {
link: string
text: string
hoverText: string
}

const FooterLink = ({ link, text, hoverText }: FooterLinkProps) => {
const FooterLink = () => {
return (
<Link variant="footer" href={`https://vytal.io/${link}`} target="_blank">
{text}{' '}
<Text
sx={{
color: 'primaryDark',
':hover': {
textDecoration: 'underline',
},
}}
<Link
variant="footer"
href={`https://go.nordvpn.net/aff_c?offer_id=15&aff_id=79520&url_id=902`}
target="_blank"
>
Vytal does not change your IP address. To change your IP you will need to
use a VPN such as{' '}
<Link
variant="hover"
href={`https://go.nordvpn.net/aff_c?offer_id=15&aff_id=79520&url_id=902`}
target="_blank"
>
NordVPN
</Link>{' '}
or{' '}
<Link
variant="hover"
href={`https://go.getproton.me/aff_c?offer_id=26&aff_id=3825`}
target="_blank"
>
{hoverText}
</Text>
ProtonVPN
</Link>
</Link>
)
}
Expand Down
3 changes: 2 additions & 1 deletion src/Popup/Components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const Table = ({ children }: TableProps) => {
<Box
sx={{
border: '1px solid',
mb: '12px',
mt: '12px',
mb: '8px',
borderRadius: '4px',
borderColor: 'grey',
}}
Expand Down
2 changes: 1 addition & 1 deletion src/Popup/Components/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TableRow = ({ title, value, noBorder = false }: TableRowProps) => {
borderBottomColor: 'grey',
}}
>
<td sx={{ fontWeight: '700', width: '100px', p: '8px' }}>{title}</td>
<td sx={{ fontWeight: '700', width: '100px', p: '5px 8px' }}>{title}</td>
<td>
<Box
sx={{
Expand Down
1 change: 0 additions & 1 deletion src/Popup/Pages/AutofillPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ const AutofillPage = ({ tab, autofillData }: AutofillPageProps) => {
>
Autofill Current Page
</Button>
<FooterLink link="test" text="Test" hoverText="autofill data" />
</Page>
)
}
Expand Down
5 changes: 0 additions & 5 deletions src/Popup/Pages/ConnectionPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ const ConnectionPage = ({ tab, ipData }: ConnectionPageProps) => {
noBorder
/>
</Table>
<FooterLink
link="test"
text="Connection info can be changed by using a"
hoverText="VPN or proxy"
/>
</Page>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import detachDebugger from '../../../utils/detachDebugger'
import countryLocales from '../../../utils/countryLocales'
import { ipData } from '../../../types'
import configurations from '../../../utils/configurations'
import CheckBox from '../../Components/CheckBox'
import FooterLink from '../../Components/FooterLink'
import Table from '../../Components/Table'
import TableRow from '../../Components/TableRow'

interface SystemPageProps {
interface LocationPageProps {
tab: string
ipData?: ipData
geolocation?: GeolocationCoordinates
}

const SystemPage = ({ tab, ipData, geolocation }: SystemPageProps) => {
const [systemType, setSystemType] = useState('')
const LocationPage = ({ tab, ipData, geolocation }: LocationPageProps) => {
const [locationType, setLocationType] = useState('')
const [timezone, setTimezone] = useState('')
const [locale, setLocale] = useState('')
const [lat, setLatitude] = useState('')
Expand All @@ -27,17 +28,17 @@ const SystemPage = ({ tab, ipData, geolocation }: SystemPageProps) => {

useEffect(() => {
chrome.storage.local.get(
['systemType', 'configuration', 'timezone', 'locale', 'lat', 'lon'],
['locationType', 'configuration', 'timezone', 'locale', 'lat', 'lon'],
(storage) => {
if (!storage.systemType || storage.systemType === 'default') {
if (!storage.locationType || storage.locationType === 'default') {
setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone)
setLocale(Intl.DateTimeFormat().resolvedOptions().locale)
if (geolocation) {
setLatitude(`${geolocation.latitude}`)
setLongitude(`${geolocation.longitude}`)
}
}
if (storage.systemType === 'matchIp' && ipData) {
if (storage.locationType === 'matchIp' && ipData) {
setTimezone(ipData.timezone)
setLocale(countryLocales[ipData.countryCode].locale)
setLatitude(`${ipData.lat}`)
Expand All @@ -48,24 +49,24 @@ const SystemPage = ({ tab, ipData, geolocation }: SystemPageProps) => {
lat: ipData.lat,
lon: ipData.lon,
})
} else if (storage.systemType === 'custom') {
} else if (storage.locationType === 'custom') {
storage.configuration && setConfiguration(storage.configuration)
storage.timezone && setTimezone(storage.timezone)
storage.locale && setLocale(storage.locale)
storage.lat && setLatitude(storage.lat)
storage.lon && setLongitude(storage.lon)
}
storage.systemType
? setSystemType(storage.systemType)
: setSystemType('default')
storage.locationType
? setLocationType(storage.locationType)
: setLocationType('default')
}
)
}, [geolocation, ipData])

const changeType = (e: ChangeEvent<HTMLInputElement>) => {
detachDebugger()
setSystemType(e.target.value)
chrome.storage.local.set({ systemType: e.target.value })
setLocationType(e.target.value)
chrome.storage.local.set({ locationType: e.target.value })

if (e.target.value === 'default') {
setTimezone(Intl.DateTimeFormat().resolvedOptions().timeZone)
Expand Down Expand Up @@ -129,18 +130,26 @@ const SystemPage = ({ tab, ipData, geolocation }: SystemPageProps) => {
}

const changeInputText = () => {
if (systemType !== 'custom' || configuration !== 'custom') {
if (locationType !== 'custom' || configuration !== 'custom') {
setConfiguration('custom')
setSystemType('custom')
setLocationType('custom')
chrome.storage.local.set({
configuration: 'custom',
systemType: 'custom',
locationType: 'custom',
})
}
}

const getFlagEmoji = (countryCode: string) => {
const codePoints = countryCode
.toUpperCase()
.split('')
.map((char) => 127397 + char.charCodeAt(0))
return String.fromCodePoint(...codePoints)
}

return (
<Page isCurrentTab={tab === 'system'} title={'System Data'}>
<Page isCurrentTab={tab === 'location'} title={'Location Data'}>
<Flex
sx={{
justifyContent: 'space-between',
Expand All @@ -149,33 +158,46 @@ const SystemPage = ({ tab, ipData, geolocation }: SystemPageProps) => {
>
<Label>
<Radio
name="systemType"
name="locationType"
value="default"
onChange={changeType}
checked={systemType === 'default'}
checked={locationType === 'default'}
/>
Default
</Label>
<Label>
<Radio
name="systemType"
name="locationType"
value="matchIp"
onChange={changeType}
checked={systemType === 'matchIp'}
checked={locationType === 'matchIp'}
/>
Match IP
</Label>
<Label>
<Radio
name="systemType"
name="locationType"
value="custom"
onChange={changeType}
checked={systemType === 'custom'}
checked={locationType === 'custom'}
/>
Custom
</Label>
</Flex>
{systemType === 'custom' && (
{locationType === 'matchIp' && (
<Table>
<TableRow
title="IP Address"
value={
ipData
? `${getFlagEmoji(ipData.countryCode)} ${ipData?.query}`
: 'loading...'
}
noBorder
/>
</Table>
)}
{locationType === 'custom' && (
<>
<Label htmlFor="configuration">Configuration</Label>
<Select
Expand Down Expand Up @@ -222,12 +244,9 @@ const SystemPage = ({ tab, ipData, geolocation }: SystemPageProps) => {
onChange={changeInputText}
mb="12px"
/>
{systemType !== 'default' && (
<CheckBox title={'Enable Debugger API Spoofing'} />
)}
<FooterLink link="test" text="Test with" hoverText="system data scan" />
<FooterLink />
</Page>
)
}

export default SystemPage
export default LocationPage
9 changes: 2 additions & 7 deletions src/Popup/Pages/UserAgentPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { Box, Label, Radio, Flex, Select } from 'theme-ui'
import DebouncedInput from '../../Components/DebouncedInput'
import userAgents from '../../../utils/userAgents'
import detachDebugger from '../../../utils/detachDebugger'
import attachCurrentTab from '../../../utils/attachCurrentTab'
import Page from '../../Components/Page'
import CheckBox from '../../Components/CheckBox'
import FooterLink from '../../Components/FooterLink'

interface UserAgentPageProps {
Expand Down Expand Up @@ -64,7 +62,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
platform: userAgents[e.target.value]['platform'],
operatingSystem: e.target.value,
})
await attachCurrentTab()
// await attachCurrentTab()
}

const changeBrowser = (e: ChangeEvent<HTMLSelectElement>) => {
Expand Down Expand Up @@ -176,10 +174,7 @@ const UserAgentPage = ({ tab }: UserAgentPageProps) => {
onChange={changeTextInput}
mb="12px"
/>
{userAgentType !== 'default' && (
<CheckBox title={'Enable Debugger API Spoofing'} />
)}
<FooterLink link="test" text="Scan for" hoverText="user agent leaks" />
<FooterLink />
</Page>
)
}
Expand Down
1 change: 0 additions & 1 deletion src/Popup/Pages/WebRtcPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const WebRtcPage = ({ tab }: SystemPageProps) => {
webRtcPolicy={webRtcPolicy}
onChange={changeRadioValue}
/>
<FooterLink link="test" text="Scan for" hoverText="WebRTC leaks" />
</Page>
)
}
Expand Down
22 changes: 11 additions & 11 deletions src/Popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { ThemeProvider, Flex, Box } from 'theme-ui'
import { theme } from '../theme'
import {
Wifi,
HardDrive,
MapPin,
FileText,
MessageSquare,
Globe,
Settings,
} from 'react-feather'
import TabItem from './TabItem'
import SystemPage from './Pages/SystemPage'
import LocationPage from './Pages/LocationPage'
import UserAgentPage from './Pages/UserAgentPage'
import SettingsPage from './Pages/SettingsPage'
import AutofillPage from './Pages/AutofillPage'
Expand All @@ -24,7 +24,7 @@ import OtherOptionsPage from './Pages/OtherOptionsPage'
import addresses from '../utils/addresses'

const Popup = () => {
const [tab, setTab] = useState('autofill')
const [tab, setTab] = useState('location')
const [ipData, setIpData] = useState<ipData>()
// const [reverseGeocoding, setReverseGeocoding] = useState<any>(undefined)
const [geolocation, setGeolocation] = useState<GeolocationCoordinates>()
Expand Down Expand Up @@ -69,17 +69,17 @@ const Popup = () => {
flexDirection: 'column',
}}
>
<TabItem
{/* <TabItem
Icon={Wifi}
active={tab === 'connection'}
onClick={() => setTab('connection')}
/>
/> */}
<TabItem
Icon={HardDrive}
active={tab === 'system'}
onClick={() => setTab('system')}
Icon={MapPin}
active={tab === 'location'}
onClick={() => setTab('location')}
/>
<TabItem
{/* <TabItem
Icon={FileText}
active={tab === 'autofill'}
onClick={() => setTab('autofill')}
Expand All @@ -88,7 +88,7 @@ const Popup = () => {
Icon={MessageSquare}
active={tab === 'webRtc'}
onClick={() => setTab('webRtc')}
/>
/> */}
<TabItem
Icon={Globe}
active={tab === 'userAgent'}
Expand All @@ -111,7 +111,7 @@ const Popup = () => {
</Flex>
<Box sx={{ m: '12px', width: '100%' }}>
<ConnectionPage tab={tab} ipData={ipData} />
<SystemPage tab={tab} ipData={ipData} geolocation={geolocation} />
<LocationPage tab={tab} ipData={ipData} geolocation={geolocation} />
<AutofillPage
tab={tab}
autofillData={autofillData}
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Vytal - VPN Companion",
"version": "2.0.0",
"name": "Vytal - Spoof timezone, location & user agent",
"version": "2.1.0",
"description": "Spoof Timezone, Geolocation, Locale and User Agent.",
"permissions": ["storage", "debugger", "privacy", "geolocation"],
"background": { "service_worker": "background.bundle.js" },
Expand Down
7 changes: 7 additions & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,12 @@ export const theme: Theme = {
bottom: '0',
textDecoration: 'none',
},
hover: {
color: 'primaryDark',
textDecoration: 'none',
'&:hover': {
textDecoration: 'underline',
},
},
},
}

0 comments on commit 4f663f8

Please sign in to comment.