diff options
Diffstat (limited to 'works/ProxyChanger/popup')
-rw-r--r-- | works/ProxyChanger/popup/popup.css | 28 | ||||
-rw-r--r-- | works/ProxyChanger/popup/popup.html | 17 | ||||
-rw-r--r-- | works/ProxyChanger/popup/popup.js | 58 |
3 files changed, 0 insertions, 103 deletions
diff --git a/works/ProxyChanger/popup/popup.css b/works/ProxyChanger/popup/popup.css deleted file mode 100644 index 97601c2..0000000 --- a/works/ProxyChanger/popup/popup.css +++ /dev/null @@ -1,28 +0,0 @@ -html,
-body {
- width: 200px;
-}
-
-body {
- margin: 0;
-}
-
-.button {
- margin: 0;
- padding: 4px 20px;
- text-align: center;
- font-size: 1.5em;
- cursor: pointer;
-}
-
-.button:hover {
- background: #97c4ff;
-}
-
-.selected {
- background: #4294ff;
-}
-
-.selected:hover {
- background: #4294ff;
-}
diff --git a/works/ProxyChanger/popup/popup.html b/works/ProxyChanger/popup/popup.html deleted file mode 100644 index 16e4bd0..0000000 --- a/works/ProxyChanger/popup/popup.html +++ /dev/null @@ -1,17 +0,0 @@ -<!DOCTYPE html>
-
-<html>
- <head>
- <meta charset="utf-8" />
- <link rel="stylesheet" href="popup.css" />
- </head>
-
- <body>
- <div id="direct_button" class="button">Direct</div>
- <div id="system_button" class="button">System</div>
- <div id="proxy_button" class="button">Proxy</div>
- <hr />
- <div id="settings_button" class="button">Settings</div>
- <script src="popup.js"></script>
- </body>
-</html>
diff --git a/works/ProxyChanger/popup/popup.js b/works/ProxyChanger/popup/popup.js deleted file mode 100644 index 0615035..0000000 --- a/works/ProxyChanger/popup/popup.js +++ /dev/null @@ -1,58 +0,0 @@ -const buttons = {
- direct: document.getElementById("direct_button"),
- system: document.getElementById("system_button"),
- proxy: document.getElementById("proxy_button"),
-};
-
-function setSelectedButton(button) {
- for (const key in buttons) {
- buttons[key].classList.remove("selected");
- }
- buttons[button].classList.add("selected");
-}
-
-browser.proxy.settings.get({}).then(({ value }) => {
- console.log("current proxy settings: ", value);
- if (value.proxyType === "none") {
- setSelectedButton("direct");
- } else if (value.proxyType === "system") {
- setSelectedButton("system");
- } else if (value.proxyType === "manual") {
- setSelectedButton("proxy");
- }
-});
-
-browser.storage.local.get("proxyUrl").then(({ proxyUrl }) => {
- console.log("Saved proxy url is ", proxyUrl);
-
- const proxyConfigs = {
- direct: {
- proxyType: "none",
- },
- system: {
- proxyType: "system",
- },
- proxy: {
- proxyType: "manual",
- http: proxyUrl,
- httpProxyAll: true,
- },
- };
-
- for (const key in buttons) {
- buttons[key].addEventListener("click", () => {
- console.log("Try to set proxy to ", proxyConfigs[key]);
- browser.proxy.settings
- .set({ value: proxyConfigs[key] })
- .then((success) => {
- if (success) {
- setSelectedButton(key);
- }
- });
- });
- }
-});
-
-document.getElementById("settings_button").addEventListener("click", () => {
- browser.runtime.openOptionsPage();
-});
|