From 0b5c77baea3f8035bddad86dd2b7e0de1d270d48 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Sat, 1 Oct 2022 15:30:24 -0400 Subject: [PATCH] Restructured folders --- package.json | 1 + .../index.js => Background/index.ts} | 8 ++--- .../LocationPage}/ConfigurationSelect.tsx | 6 ++-- .../Pages/LocationPage}/IPData.tsx | 6 ++-- .../Pages/LocationPage}/LocationInput.tsx | 8 ++--- .../Pages/LocationPage/index.tsx} | 4 +-- .../Pages/SettingsPage}/SettingsCheckBox.tsx | 0 .../Pages/SettingsPage/index.tsx} | 2 +- .../Pages/UserAgentPage}/UserAgentSelect.tsx | 6 ++-- .../Pages/UserAgentPage/index.tsx} | 6 ++-- src/{pages => }/Popup/Popup.tsx | 34 ++++++++++++++----- src/{pages => }/Popup/TabItem.tsx | 0 src/{pages => }/Popup/index.html | 0 .../Popup/index.jsx => Popup/index.tsx} | 0 src/manifest.json | 2 +- src/theme.ts | 1 + src/utils/setAutofillAddress.ts | 34 +++++++++++++++++++ tsconfig.json | 1 + webpack.config.js | 6 ++-- yarn.lock | 5 +++ 20 files changed, 95 insertions(+), 35 deletions(-) rename src/{pages/Background/index.js => Background/index.ts} (67%) rename src/{pages/Popup => Popup/Pages/LocationPage}/ConfigurationSelect.tsx (86%) rename src/{pages/Popup => Popup/Pages/LocationPage}/IPData.tsx (83%) rename src/{pages/Popup => Popup/Pages/LocationPage}/LocationInput.tsx (89%) rename src/{pages/Popup/LocationPage.tsx => Popup/Pages/LocationPage/index.tsx} (95%) rename src/{pages/Popup => Popup/Pages/SettingsPage}/SettingsCheckBox.tsx (100%) rename src/{pages/Popup/SettingsPage.tsx => Popup/Pages/SettingsPage/index.tsx} (96%) rename src/{pages/Popup => Popup/Pages/UserAgentPage}/UserAgentSelect.tsx (86%) rename src/{pages/Popup/UserAgentPage.tsx => Popup/Pages/UserAgentPage/index.tsx} (95%) rename src/{pages => }/Popup/Popup.tsx (70%) rename src/{pages => }/Popup/TabItem.tsx (100%) rename src/{pages => }/Popup/index.html (100%) rename src/{pages/Popup/index.jsx => Popup/index.tsx} (100%) create mode 100644 src/utils/setAutofillAddress.ts diff --git a/package.json b/package.json index 0142c2e..dd21067 100755 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@emotion/react": "^11.9.3", "@hot-loader/react-dom": "^17.0.2", "@mdx-js/react": "^2.1.2", + "@types/webpack-env": "^1.18.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-feather": "^2.0.10", diff --git a/src/pages/Background/index.js b/src/Background/index.ts similarity index 67% rename from src/pages/Background/index.js rename to src/Background/index.ts index 4d04d9d..0d1bb62 100644 --- a/src/pages/Background/index.js +++ b/src/Background/index.ts @@ -1,16 +1,16 @@ -import attachDebugger from '../../utils/attachDebugger' +import attachDebugger from '../utils/attachDebugger' -const attachTab = (tabId) => { +const attachTab = (tabId: number) => { chrome.debugger.getTargets((tabs) => { const currentTab = tabs.find((obj) => obj.tabId === tabId) - if (!currentTab.attached) { + if (!currentTab?.attached) { attachDebugger(tabId) } }) } chrome.tabs.onCreated.addListener((tab) => { - attachDebugger(tab.id) + tab.id && attachDebugger(tab.id) }) chrome.tabs.onActivated.addListener((tab) => { diff --git a/src/pages/Popup/ConfigurationSelect.tsx b/src/Popup/Pages/LocationPage/ConfigurationSelect.tsx similarity index 86% rename from src/pages/Popup/ConfigurationSelect.tsx rename to src/Popup/Pages/LocationPage/ConfigurationSelect.tsx index ea7ac8c..7c4390f 100644 --- a/src/pages/Popup/ConfigurationSelect.tsx +++ b/src/Popup/Pages/LocationPage/ConfigurationSelect.tsx @@ -1,7 +1,7 @@ -import React, { Dispatch, SetStateAction, ChangeEvent } from 'react' +import { Dispatch, SetStateAction, ChangeEvent } from 'react' import { Label, Select } from 'theme-ui' -import configurations from '../../utils/configurations' -import detachDebugger from '../../utils/detachDebugger' +import configurations from '../../../utils/configurations' +import detachDebugger from '../../../utils/detachDebugger' interface ConfigurationSelectProps { configuration: string diff --git a/src/pages/Popup/IPData.tsx b/src/Popup/Pages/LocationPage/IPData.tsx similarity index 83% rename from src/pages/Popup/IPData.tsx rename to src/Popup/Pages/LocationPage/IPData.tsx index d51550c..21241b6 100644 --- a/src/pages/Popup/IPData.tsx +++ b/src/Popup/Pages/LocationPage/IPData.tsx @@ -1,7 +1,7 @@ -import React, { Dispatch, SetStateAction } from 'react' +import { Dispatch, SetStateAction } from 'react' import { Flex, Button, Text } from 'theme-ui' -import detachDebugger from '../../utils/detachDebugger' -import getIP from '../../utils/getIP' +import detachDebugger from '../../../utils/detachDebugger' +import getIP from '../../../utils/getIP' const getFlagEmoji = (countryCode: string) => { const codePoints = countryCode diff --git a/src/pages/Popup/LocationInput.tsx b/src/Popup/Pages/LocationPage/LocationInput.tsx similarity index 89% rename from src/pages/Popup/LocationInput.tsx rename to src/Popup/Pages/LocationPage/LocationInput.tsx index e7a2d9a..d179d8d 100644 --- a/src/pages/Popup/LocationInput.tsx +++ b/src/Popup/Pages/LocationPage/LocationInput.tsx @@ -1,13 +1,13 @@ -import React, { +import { useState, useEffect, Dispatch, SetStateAction, ChangeEvent, } from 'react' -import configurations from '../../utils/configurations' -import countryLocales from '../../utils/countryLocales' -import detachDebugger from '../../utils/detachDebugger' +import configurations from '../../../utils/configurations' +import countryLocales from '../../../utils/countryLocales' +import detachDebugger from '../../../utils/detachDebugger' import { Label, Input } from 'theme-ui' interface LocationInputProps { diff --git a/src/pages/Popup/LocationPage.tsx b/src/Popup/Pages/LocationPage/index.tsx similarity index 95% rename from src/pages/Popup/LocationPage.tsx rename to src/Popup/Pages/LocationPage/index.tsx index c4b9353..e835fed 100644 --- a/src/pages/Popup/LocationPage.tsx +++ b/src/Popup/Pages/LocationPage/index.tsx @@ -1,9 +1,9 @@ -import React, { useState, useEffect } from 'react' +import { useState, useEffect } from 'react' import { Box } from 'theme-ui' import LocationInput from './LocationInput' import ConfigurationSelect from './ConfigurationSelect' import IPData from './IPData' -import getIP from '../../utils/getIP' +import getIP from '../../../utils/getIP' interface LocationPageProps { tab: string diff --git a/src/pages/Popup/SettingsCheckBox.tsx b/src/Popup/Pages/SettingsPage/SettingsCheckBox.tsx similarity index 100% rename from src/pages/Popup/SettingsCheckBox.tsx rename to src/Popup/Pages/SettingsPage/SettingsCheckBox.tsx diff --git a/src/pages/Popup/SettingsPage.tsx b/src/Popup/Pages/SettingsPage/index.tsx similarity index 96% rename from src/pages/Popup/SettingsPage.tsx rename to src/Popup/Pages/SettingsPage/index.tsx index 798ea8f..17213c4 100644 --- a/src/pages/Popup/SettingsPage.tsx +++ b/src/Popup/Pages/SettingsPage/index.tsx @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' import { Box, Label, Select } from 'theme-ui' -import setWebRtcPolicy from '../../utils/setWebRtcPolicy' +import setWebRtcPolicy from '../../../utils/setWebRtcPolicy' import SettingsCheckBox from './SettingsCheckBox' interface LocationPageProps { diff --git a/src/pages/Popup/UserAgentSelect.tsx b/src/Popup/Pages/UserAgentPage/UserAgentSelect.tsx similarity index 86% rename from src/pages/Popup/UserAgentSelect.tsx rename to src/Popup/Pages/UserAgentPage/UserAgentSelect.tsx index e4d1e2b..4420898 100644 --- a/src/pages/Popup/UserAgentSelect.tsx +++ b/src/Popup/Pages/UserAgentPage/UserAgentSelect.tsx @@ -1,7 +1,7 @@ -import React, { Dispatch, SetStateAction, ChangeEvent } from 'react' +import { Dispatch, SetStateAction, ChangeEvent } from 'react' import { Label, Select } from 'theme-ui' -import configurations from '../../utils/configurations' -import detachDebugger from '../../utils/detachDebugger' +import configurations from '../../../utils/configurations' +import detachDebugger from '../../../utils/detachDebugger' interface ConfigurationSelectProps { title: string diff --git a/src/pages/Popup/UserAgentPage.tsx b/src/Popup/Pages/UserAgentPage/index.tsx similarity index 95% rename from src/pages/Popup/UserAgentPage.tsx rename to src/Popup/Pages/UserAgentPage/index.tsx index 67d335d..196d318 100644 --- a/src/pages/Popup/UserAgentPage.tsx +++ b/src/Popup/Pages/UserAgentPage/index.tsx @@ -1,7 +1,7 @@ -import React, { useState, useEffect, ChangeEvent } from 'react' +import { useState, useEffect, ChangeEvent } from 'react' import { Box, Label, Radio, Flex, Input, Select } from 'theme-ui' -import userAgents from '../../utils/userAgents' -import detachDebugger from '../../utils/detachDebugger' +import userAgents from '../../../utils/userAgents' +import detachDebugger from '../../../utils/detachDebugger' interface UserAgentPageProps { tab: string diff --git a/src/pages/Popup/Popup.tsx b/src/Popup/Popup.tsx similarity index 70% rename from src/pages/Popup/Popup.tsx rename to src/Popup/Popup.tsx index 48c7c14..b416664 100644 --- a/src/pages/Popup/Popup.tsx +++ b/src/Popup/Popup.tsx @@ -1,11 +1,19 @@ import React, { useState } from 'react' import { ThemeProvider, Flex, Box, Text } from 'theme-ui' -import { theme } from '../../theme' -import { MapPin, Globe, Settings, ExternalLink } from 'react-feather' +import { theme } from '../theme' +import { + MapPin, + Home, + MessageSquare, + Globe, + Sliders, + Settings, + ExternalLink, +} from 'react-feather' import TabItem from './TabItem' -import LocationPage from './LocationPage' -import UserAgentPage from './UserAgentPage' -import SettingsPage from './SettingsPage' +import LocationPage from './Pages/LocationPage' +import UserAgentPage from './Pages/UserAgentPage' +import SettingsPage from './Pages/SettingsPage' const Popup = () => { const [tab, setTab] = useState('settings') @@ -32,7 +40,17 @@ const Popup = () => { onClick={() => setTab('location')} /> setTab('AdressAutofill')} + /> + setTab('WebRTC')} + /> + setTab('useragent')} /> @@ -50,7 +68,7 @@ const Popup = () => { - { }} > Current tab won't be fully spoofed until after 1st or 2nd reload. - + */} diff --git a/src/pages/Popup/TabItem.tsx b/src/Popup/TabItem.tsx similarity index 100% rename from src/pages/Popup/TabItem.tsx rename to src/Popup/TabItem.tsx diff --git a/src/pages/Popup/index.html b/src/Popup/index.html similarity index 100% rename from src/pages/Popup/index.html rename to src/Popup/index.html diff --git a/src/pages/Popup/index.jsx b/src/Popup/index.tsx similarity index 100% rename from src/pages/Popup/index.jsx rename to src/Popup/index.tsx diff --git a/src/manifest.json b/src/manifest.json index 8eeb120..e2b6017 100755 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "manifest_version": 3, - "name": "Vytal - Spoof Timezone, Geolocation, Locale and User Agent", + "name": "Vytal - VPN Companion", "version": "2.0.0", "description": "Spoof Timezone, Geolocation, Locale and User Agent.", "permissions": ["storage", "debugger", "activeTab", "privacy"], diff --git a/src/theme.ts b/src/theme.ts index b84a696..a0e58d6 100644 --- a/src/theme.ts +++ b/src/theme.ts @@ -22,6 +22,7 @@ export const theme: Theme = { fontFamily: "'Segoe UI', Tahoma, sans-serif", }, }, + forms: { label: { width: 'auto' }, input: { diff --git a/src/utils/setAutofillAddress.ts b/src/utils/setAutofillAddress.ts new file mode 100644 index 0000000..4de434a --- /dev/null +++ b/src/utils/setAutofillAddress.ts @@ -0,0 +1,34 @@ +const setAutofillAddress = () => { + chrome.storage.sync.get(['isWebRtcDisabled'], (storage) => { + const value = storage.isWebRtcDisabled + ? 'default' + : 'disable_non_proxied_udp' + + chrome.privacy.services.autofillAddressEnabled.clear({}, () => { + chrome.privacy.network.webRTCIPHandlingPolicy.set( + { + value, + }, + () => { + chrome.storage.sync.set({ + isWebRtcDisabled: !storage.isWebRtcDisabled, + }) + // chrome.privacy.network.webRTCIPHandlingPolicy.get({}, (s) => { + // // let path = 'data/icons/' + // // let title = 'WebRTC access is allowed' + // if (s.value !== value) { + // // path += 'red/' + // // title = + // console.log('WebRTC access cannot be changed. It is controlled by another extension') + // } else if (prefs.enabled === false) { + // path += 'disabled/' + // title = 'WebRTC access is blocked' + // } + // }) + } + ) + }) + }) +} + +export default setAutofillAddress diff --git a/tsconfig.json b/tsconfig.json index cd5277c..ed3cf46 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,6 +15,7 @@ "noEmit": false, "jsx": "react-jsx", "jsxImportSource": "theme-ui" + }, "include": ["src"], "exclude": ["build", "node_modules"] diff --git a/webpack.config.js b/webpack.config.js index df6e7fb..0b1834f 100755 --- a/webpack.config.js +++ b/webpack.config.js @@ -36,8 +36,8 @@ if (fileSystem.existsSync(secretsPath)) { var options = { mode: process.env.NODE_ENV || 'development', entry: { - popup: path.join(__dirname, 'src', 'pages', 'Popup', 'index.jsx'), - background: path.join(__dirname, 'src', 'pages', 'Background', 'index.js'), + popup: path.join(__dirname, 'src', 'Popup', 'index.tsx'), + background: path.join(__dirname, 'src', 'Background', 'index.ts'), }, chromeExtensionBoilerplate: { notHotReload: ['background'], @@ -147,7 +147,7 @@ var options = { ], }), new HtmlWebpackPlugin({ - template: path.join(__dirname, 'src', 'pages', 'Popup', 'index.html'), + template: path.join(__dirname, 'src', 'Popup', 'index.html'), filename: 'popup.html', chunks: ['popup'], cache: false, diff --git a/yarn.lock b/yarn.lock index bcec8ee..ad667e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1640,6 +1640,11 @@ dependencies: csstype "^3.0.2" +"@types/webpack-env@^1.18.0": + version "1.18.0" + resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.18.0.tgz#ed6ecaa8e5ed5dfe8b2b3d00181702c9925f13fb" + integrity sha512-56/MAlX5WMsPVbOg7tAxnYvNYMMWr/QJiIp6BxVSW3JJXUVzzOn64qW8TzQyMSqSUFM2+PVI4aUHcHOzIz/1tg== + "@types/ws@^8.5.1": version "8.5.3" resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d"