Initial commit
This commit is contained in:
commit
7a2bf53a77
8 changed files with 157 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
*.js
|
15
manifest.json
Normal file
15
manifest.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"manifest_version": 3,
|
||||||
|
"name": "Proxy Settings",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"action": {
|
||||||
|
"default_popup": "options.html"
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"service_worker": "worker.js"
|
||||||
|
},
|
||||||
|
"permissions": [
|
||||||
|
"proxy",
|
||||||
|
"storage"
|
||||||
|
]
|
||||||
|
}
|
23
options.html
Normal file
23
options.html
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>Proxy Settings</title>
|
||||||
|
<script src="options.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form id="proxySettings">
|
||||||
|
<label>Active:</label>
|
||||||
|
<input type="checkbox" id="proxyActive">
|
||||||
|
<br>
|
||||||
|
<label>Host:</label>
|
||||||
|
<input type="text" id="proxyHost">
|
||||||
|
<label>Port:</label>
|
||||||
|
<input type="number" id="proxyPort">
|
||||||
|
<br>
|
||||||
|
<input type="submit" value="Save">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
23
options.ts
Normal file
23
options.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
function setProxy() {
|
||||||
|
let active = (document.getElementById('proxyActive') as HTMLInputElement).checked;
|
||||||
|
const host = (document.getElementById('proxyHost') as HTMLInputElement).value;
|
||||||
|
const port = (document.getElementById('proxyPort') as HTMLInputElement).value;
|
||||||
|
if (!host || !port) {
|
||||||
|
active = false;
|
||||||
|
(document.getElementById('proxyActive') as HTMLInputElement).checked = false;
|
||||||
|
}
|
||||||
|
chrome.storage.local.set({ active: active, host: host, port: Number(port) });
|
||||||
|
}
|
||||||
|
window.addEventListener('DOMContentLoaded', async () => {
|
||||||
|
(document.getElementById("proxySettings") as HTMLInputElement).addEventListener('submit', setProxy);
|
||||||
|
const { active, host, port } = await chrome.storage.local.get(["active", "host", "port"]);
|
||||||
|
if (active) {
|
||||||
|
(document.getElementById("proxyActive") as HTMLInputElement).checked = active;
|
||||||
|
}
|
||||||
|
if (host) {
|
||||||
|
(document.getElementById("proxyHost") as HTMLInputElement).value = host;
|
||||||
|
}
|
||||||
|
if (port) {
|
||||||
|
(document.getElementById("proxyPort") as HTMLInputElement).value = port;
|
||||||
|
}
|
||||||
|
});
|
60
package-lock.json
generated
Normal file
60
package-lock.json
generated
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{
|
||||||
|
"name": "chromium-proxy-settings",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "chromium-proxy-settings",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/chrome": "^0.0.260",
|
||||||
|
"typescript": "^5.3.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/chrome": {
|
||||||
|
"version": "0.0.260",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.260.tgz",
|
||||||
|
"integrity": "sha512-lX6QpgfsZRTDpNcCJ+3vzfFnFXq9bScFRTlfhbK5oecSAjamsno+ejFTCbNtc5O/TPnVK9Tja/PyecvWQe0F2w==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/filesystem": "*",
|
||||||
|
"@types/har-format": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/filesystem": {
|
||||||
|
"version": "0.0.35",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.35.tgz",
|
||||||
|
"integrity": "sha512-1eKvCaIBdrD2mmMgy5dwh564rVvfEhZTWVQQGRNn0Nt4ZEnJ0C8oSUCzvMKRA4lGde5oEVo+q2MrTTbV/GHDCQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@types/filewriter": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@types/filewriter": {
|
||||||
|
"version": "0.0.33",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.33.tgz",
|
||||||
|
"integrity": "sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/@types/har-format": {
|
||||||
|
"version": "1.2.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.15.tgz",
|
||||||
|
"integrity": "sha512-RpQH4rXLuvTXKR0zqHq3go0RVXYv/YVqv4TnPH95VbwUxZdQlK1EtcMvQvMpDngHbt13Csh9Z4qT9AbkiQH5BA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"node_modules/typescript": {
|
||||||
|
"version": "5.3.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz",
|
||||||
|
"integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"tsc": "bin/tsc",
|
||||||
|
"tsserver": "bin/tsserver"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14.17"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
package.json
Normal file
8
package.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "chromium-proxy-settings",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/chrome": "^0.0.260",
|
||||||
|
"typescript": "^5.3.3"
|
||||||
|
}
|
||||||
|
}
|
6
tsconfig.json
Normal file
6
tsconfig.json
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2022",
|
||||||
|
"strict": true
|
||||||
|
}
|
||||||
|
}
|
20
worker.ts
Normal file
20
worker.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
async function apply_proxy() {
|
||||||
|
const { active, host, port } = await chrome.storage.local.get(["active", "host", "port"]);
|
||||||
|
if (!active) {
|
||||||
|
chrome.proxy.settings.clear({ scope: 'regular' }, function () { });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const config = {
|
||||||
|
mode: "fixed_servers",
|
||||||
|
rules: {
|
||||||
|
singleProxy: {
|
||||||
|
scheme: "socks5",
|
||||||
|
host: host,
|
||||||
|
port: port
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
chrome.proxy.settings.set({ value: config, scope: 'regular' }, function () { });
|
||||||
|
}
|
||||||
|
apply_proxy();
|
||||||
|
chrome.storage.onChanged.addListener(apply_proxy);
|
Loading…
Add table
Reference in a new issue