Add proxy bypass
All checks were successful
Build / build (push) Successful in 21s

This commit is contained in:
Mathieu Strypsteen 2024-02-18 10:27:44 +01:00
parent bfbef78977
commit 4de38e6f80
4 changed files with 41 additions and 12 deletions

22
LICENSE Normal file
View 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.

View file

@ -15,6 +15,8 @@
<input type="text" id="proxyHost">
<label for="proxyPort">Port:</label>
<input type="number" id="proxyPort">
<label for="proxyBypass">Bypass for sites:</label>
<textarea id="proxyBypass"></textarea>
<br>
<input type="submit" value="Save">
</form>

View file

@ -1,16 +1,17 @@
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;
let active = (document.getElementById("proxyActive") as HTMLInputElement).checked;
const host = (document.getElementById("proxyHost") as HTMLInputElement).value;
const port = (document.getElementById("proxyPort") as HTMLInputElement).value;
const bypass = (document.getElementById("proxyBypass") as HTMLInputElement).value;
if (!host || !port) {
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 () => {
(document.getElementById("proxySettings") as HTMLInputElement).addEventListener('submit', setProxy);
const { active, host, port } = await chrome.storage.local.get(["active", "host", "port"]);
window.addEventListener("DOMContentLoaded", async () => {
(document.getElementById("proxySettings") as HTMLInputElement).addEventListener("submit", setProxy);
const { active, host, port, bypass } = await chrome.storage.local.get(["active", "host", "port", "bypass"]);
if (active) {
(document.getElementById("proxyActive") as HTMLInputElement).checked = active;
}
@ -20,4 +21,7 @@ window.addEventListener('DOMContentLoaded', async () => {
if (port) {
(document.getElementById("proxyPort") as HTMLInputElement).value = port;
}
if (bypass) {
(document.getElementById("proxyBypass") as HTMLInputElement).value = bypass.join("\n");
}
});

View file

@ -1,7 +1,7 @@
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) {
chrome.proxy.settings.clear({ scope: 'regular' }, function () { });
chrome.proxy.settings.clear({ scope: "regular" }, function () { });
return;
}
const config = {
@ -11,10 +11,11 @@ async function apply_proxy() {
scheme: "socks5",
host: host,
port: port
}
},
bypassList: bypass
}
};
chrome.proxy.settings.set({ value: config, scope: 'regular' }, function () { });
chrome.proxy.settings.set({ value: config, scope: "regular" }, function () { });
}
apply_proxy();
chrome.storage.onChanged.addListener(apply_proxy);