Fixed types, removed console logs, fixed form errorss

This commit is contained in:
z0ccc 2022-08-02 21:50:52 -04:00
parent a732216d11
commit 64fe3a4760
6 changed files with 30 additions and 20 deletions

View file

@ -1,4 +1,4 @@
import React, { Dispatch, SetStateAction } from 'react' import React, { Dispatch, SetStateAction, ChangeEvent } from 'react'
import { Label, Select } from 'theme-ui' import { Label, Select } from 'theme-ui'
import configurations from '../../utils/configurations' import configurations from '../../utils/configurations'
import detachDebugger from '../../utils/detachDebugger' import detachDebugger from '../../utils/detachDebugger'
@ -12,7 +12,7 @@ const ConfigurationSelect = ({
configuration, configuration,
setConfiguration, setConfiguration,
}: ConfigurationSelectProps) => { }: ConfigurationSelectProps) => {
const changeConfiguration = (e: any) => { const changeConfiguration = (e: ChangeEvent<HTMLSelectElement>) => {
detachDebugger() detachDebugger()
chrome.storage.sync.set({ chrome.storage.sync.set({
configuration: e.target.value, configuration: e.target.value,

View file

@ -1,4 +1,10 @@
import React, { useState, useEffect, Dispatch, SetStateAction } from 'react' import React, {
useState,
useEffect,
Dispatch,
SetStateAction,
ChangeEvent,
} from 'react'
import configurations from '../../utils/configurations' import configurations from '../../utils/configurations'
import countryLocales from '../../utils/countryLocales' import countryLocales from '../../utils/countryLocales'
import detachDebugger from '../../utils/detachDebugger' import detachDebugger from '../../utils/detachDebugger'
@ -42,7 +48,7 @@ const LocationInput = ({
} }
}, [ip, configuration, type, value]) }, [ip, configuration, type, value])
const changeTextValue = (e: any) => { const changeTextValue = (e: ChangeEvent<HTMLInputElement>) => {
detachDebugger() detachDebugger()
chrome.storage.sync.set({ [type]: e.target.value }) chrome.storage.sync.set({ [type]: e.target.value })
setValue(e.target.value) setValue(e.target.value)

View file

@ -5,7 +5,11 @@ import ConfigurationSelect from './ConfigurationSelect'
import IPData from './IPData' import IPData from './IPData'
import getIP from '../../utils/getIP' import getIP from '../../utils/getIP'
const LocationPage = ({ tab }: any) => { interface LocationPageProps {
tab: string
}
const LocationPage = ({ tab }: LocationPageProps) => {
const [ip, setIP] = useState(null) const [ip, setIP] = useState(null)
const [configuration, setConfiguration] = useState('default') const [configuration, setConfiguration] = useState('default')

View file

@ -46,12 +46,12 @@ const Popup = () => {
<Text <Text
sx={{ sx={{
mb: '8px', mb: '8px',
fontSize: '11px', fontSize: '10px',
position: 'fixed', position: 'fixed',
bottom: '0', bottom: '0',
}} }}
> >
Current tab won't be fully spoofed until after reload. Current tab won't be fully spoofed until after 1st or 2nd reload.
</Text> </Text>
</Box> </Box>
</Flex> </Flex>

View file

@ -1,10 +1,14 @@
import React, { useState, useEffect } from 'react' import React, { useState, useEffect, ChangeEvent } from 'react'
import { Box, Label, Radio, Flex, Input, Select } from 'theme-ui' import { Box, Label, Radio, Flex, Input, Select } from 'theme-ui'
import userAgents from '../../utils/userAgents' import userAgents from '../../utils/userAgents'
import detachDebugger from '../../utils/detachDebugger' import detachDebugger from '../../utils/detachDebugger'
const UserAgentPage = ({ tab }: any) => { interface UserAgentPageProps {
const [type, setType] = useState('None') tab: string
}
const UserAgentPage = ({ tab }: UserAgentPageProps) => {
const [type, setType] = useState('none')
const [operatingSystem, setOperatingSystem] = useState('Windows') const [operatingSystem, setOperatingSystem] = useState('Windows')
const [browser, setBrowser] = useState('Chrome') const [browser, setBrowser] = useState('Chrome')
const [userAgent, setUserAgent] = useState('') const [userAgent, setUserAgent] = useState('')
@ -30,27 +34,25 @@ const UserAgentPage = ({ tab }: any) => {
type === 'preloaded' && setUserAgent(userAgents[operatingSystem][browser]) type === 'preloaded' && setUserAgent(userAgents[operatingSystem][browser])
}, [operatingSystem, browser, type]) }, [operatingSystem, browser, type])
const changeType = (e: any) => { 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.sync.set({ type: e.target.value })
setType(e.target.value) setType(e.target.value)
} }
const changeOperatingSystem = (e: any) => { const changeOperatingSystem = (e: ChangeEvent<HTMLSelectElement>) => {
console.log(e.target.value)
chrome.storage.sync.set({ operatingSystem: e.target.value }) chrome.storage.sync.set({ operatingSystem: e.target.value })
setOperatingSystem(e.target.value) setOperatingSystem(e.target.value)
} }
const changeBrowser = (e: any) => { const changeBrowser = (e: ChangeEvent<HTMLSelectElement>) => {
chrome.storage.sync.set({ browser: e.target.value }) chrome.storage.sync.set({ browser: e.target.value })
setBrowser(e.target.value) setBrowser(e.target.value)
} }
const changeUserAgent = (e: any) => { const changeUserAgent = (e: ChangeEvent<HTMLInputElement>) => {
detachDebugger() detachDebugger()
console.log(e.target.value)
chrome.storage.sync.set({ userAgent: e.target.value }) chrome.storage.sync.set({ userAgent: e.target.value })
chrome.storage.sync.set({ type: 'custom' }) chrome.storage.sync.set({ type: 'custom' })
setUserAgent(e.target.value) setUserAgent(e.target.value)
@ -107,7 +109,6 @@ const UserAgentPage = ({ tab }: any) => {
id="operatingSystem" id="operatingSystem"
value={operatingSystem} value={operatingSystem}
onChange={changeOperatingSystem} onChange={changeOperatingSystem}
defaultValue=""
mb={'8px'} mb={'8px'}
> >
<option sx={{ display: 'none' }}></option> <option sx={{ display: 'none' }}></option>
@ -123,7 +124,6 @@ const UserAgentPage = ({ tab }: any) => {
id="browser" id="browser"
value={browser} value={browser}
onChange={changeBrowser} onChange={changeBrowser}
defaultValue=""
mb={'8px'} mb={'8px'}
> >
{Object.keys(userAgents[operatingSystem]).map((key) => ( {Object.keys(userAgents[operatingSystem]).map((key) => (

View file

@ -1,4 +1,4 @@
import React, { Dispatch, SetStateAction } from 'react' import React, { Dispatch, SetStateAction, ChangeEvent } from 'react'
import { Label, Select } from 'theme-ui' import { Label, Select } from 'theme-ui'
import configurations from '../../utils/configurations' import configurations from '../../utils/configurations'
import detachDebugger from '../../utils/detachDebugger' import detachDebugger from '../../utils/detachDebugger'
@ -14,7 +14,7 @@ const UserAgentSelect = ({
configuration, configuration,
setConfiguration, setConfiguration,
}: ConfigurationSelectProps) => { }: ConfigurationSelectProps) => {
const changeConfiguration = (e: any) => { const changeConfiguration = (e: ChangeEvent<HTMLSelectElement>) => {
detachDebugger() detachDebugger()
chrome.storage.sync.set({ chrome.storage.sync.set({
configuration: e.target.value, configuration: e.target.value,