This commit is contained in:
parent
bfbef78977
commit
4de38e6f80
4 changed files with 41 additions and 12 deletions
22
LICENSE
Normal file
22
LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -15,6 +15,8 @@
|
||||||
<input type="text" id="proxyHost">
|
<input type="text" id="proxyHost">
|
||||||
<label for="proxyPort">Port:</label>
|
<label for="proxyPort">Port:</label>
|
||||||
<input type="number" id="proxyPort">
|
<input type="number" id="proxyPort">
|
||||||
|
<label for="proxyBypass">Bypass for sites:</label>
|
||||||
|
<textarea id="proxyBypass"></textarea>
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" value="Save">
|
<input type="submit" value="Save">
|
||||||
</form>
|
</form>
|
||||||
|
|
20
options.ts
20
options.ts
|
@ -1,16 +1,17 @@
|
||||||
function setProxy() {
|
function setProxy() {
|
||||||
let active = (document.getElementById('proxyActive') as HTMLInputElement).checked;
|
let active = (document.getElementById("proxyActive") as HTMLInputElement).checked;
|
||||||
const host = (document.getElementById('proxyHost') as HTMLInputElement).value;
|
const host = (document.getElementById("proxyHost") as HTMLInputElement).value;
|
||||||
const port = (document.getElementById('proxyPort') as HTMLInputElement).value;
|
const port = (document.getElementById("proxyPort") as HTMLInputElement).value;
|
||||||
|
const bypass = (document.getElementById("proxyBypass") as HTMLInputElement).value;
|
||||||
if (!host || !port) {
|
if (!host || !port) {
|
||||||
active = false;
|
active = false;
|
||||||
(document.getElementById('proxyActive') as HTMLInputElement).checked = false;
|
(document.getElementById("proxyActive") as HTMLInputElement).checked = false;
|
||||||
}
|
}
|
||||||
chrome.storage.local.set({ active: active, host: host, port: Number(port) });
|
chrome.storage.local.set({ active: active, host: host, port: Number(port), bypass: bypass.split("\n") });
|
||||||
}
|
}
|
||||||
window.addEventListener('DOMContentLoaded', async () => {
|
window.addEventListener("DOMContentLoaded", async () => {
|
||||||
(document.getElementById("proxySettings") as HTMLInputElement).addEventListener('submit', setProxy);
|
(document.getElementById("proxySettings") as HTMLInputElement).addEventListener("submit", setProxy);
|
||||||
const { active, host, port } = await chrome.storage.local.get(["active", "host", "port"]);
|
const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]);
|
||||||
if (active) {
|
if (active) {
|
||||||
(document.getElementById("proxyActive") as HTMLInputElement).checked = active;
|
(document.getElementById("proxyActive") as HTMLInputElement).checked = active;
|
||||||
}
|
}
|
||||||
|
@ -20,4 +21,7 @@ window.addEventListener('DOMContentLoaded', async () => {
|
||||||
if (port) {
|
if (port) {
|
||||||
(document.getElementById("proxyPort") as HTMLInputElement).value = port;
|
(document.getElementById("proxyPort") as HTMLInputElement).value = port;
|
||||||
}
|
}
|
||||||
|
if (bypass) {
|
||||||
|
(document.getElementById("proxyBypass") as HTMLInputElement).value = bypass.join("\n");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
async function apply_proxy() {
|
async function apply_proxy() {
|
||||||
const { active, host, port } = await chrome.storage.local.get(["active", "host", "port"]);
|
const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]);
|
||||||
if (!active) {
|
if (!active) {
|
||||||
chrome.proxy.settings.clear({ scope: 'regular' }, function () { });
|
chrome.proxy.settings.clear({ scope: "regular" }, function () { });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const config = {
|
const config = {
|
||||||
|
@ -11,10 +11,11 @@ async function apply_proxy() {
|
||||||
scheme: "socks5",
|
scheme: "socks5",
|
||||||
host: host,
|
host: host,
|
||||||
port: port
|
port: port
|
||||||
}
|
},
|
||||||
|
bypassList: bypass
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
chrome.proxy.settings.set({ value: config, scope: 'regular' }, function () { });
|
chrome.proxy.settings.set({ value: config, scope: "regular" }, function () { });
|
||||||
}
|
}
|
||||||
apply_proxy();
|
apply_proxy();
|
||||||
chrome.storage.onChanged.addListener(apply_proxy);
|
chrome.storage.onChanged.addListener(apply_proxy);
|
||||||
|
|
Loading…
Add table
Reference in a new issue