diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-12 15:55:21 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-12 16:11:46 +0800 |
commit | 1e1ca99bde2d398ac5527cc74e6a3f8a2a70345f (patch) | |
tree | b92b591084f21d43812a1e8aff36ab2a7d12f0a5 | |
parent | 77e6cdc863d2cbd9df578a665804daf28d8593fe (diff) | |
parent | d3fb8fae17f451c2c018c6c97eccc17c844c9f46 (diff) | |
download | crupest-1e1ca99bde2d398ac5527cc74e6a3f8a2a70345f.tar.gz crupest-1e1ca99bde2d398ac5527cc74e6a3f8a2a70345f.tar.bz2 crupest-1e1ca99bde2d398ac5527cc74e6a3f8a2a70345f.zip |
import(ProxyChanger): IMPORT crupest/ProxyChanger COMPLETE.
-rw-r--r-- | works/ProxyChanger/.gitignore | 1 | ||||
-rw-r--r-- | works/ProxyChanger/README.md | 5 | ||||
-rw-r--r-- | works/ProxyChanger/art/circle.kra | bin | 0 -> 456167 bytes | |||
-rw-r--r-- | works/ProxyChanger/icons/black_circle.png | bin | 0 -> 16533 bytes | |||
-rw-r--r-- | works/ProxyChanger/manifest.json | 21 | ||||
-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 | ||||
-rw-r--r-- | works/ProxyChanger/settings/settings.css | 9 | ||||
-rw-r--r-- | works/ProxyChanger/settings/settings.html | 30 | ||||
-rw-r--r-- | works/ProxyChanger/settings/settings.js | 14 |
11 files changed, 183 insertions, 0 deletions
diff --git a/works/ProxyChanger/.gitignore b/works/ProxyChanger/.gitignore new file mode 100644 index 0000000..db63815 --- /dev/null +++ b/works/ProxyChanger/.gitignore @@ -0,0 +1 @@ +web-ext-artifacts
diff --git a/works/ProxyChanger/README.md b/works/ProxyChanger/README.md new file mode 100644 index 0000000..939f079 --- /dev/null +++ b/works/ProxyChanger/README.md @@ -0,0 +1,5 @@ +Finally I create an extension of Firefox to change proxy.
+
+It is **extremely dumb and stupid**!
+
+No webpack, no node, no npm. What you write is what you finally use!
diff --git a/works/ProxyChanger/art/circle.kra b/works/ProxyChanger/art/circle.kra Binary files differnew file mode 100644 index 0000000..d7632a8 --- /dev/null +++ b/works/ProxyChanger/art/circle.kra diff --git a/works/ProxyChanger/icons/black_circle.png b/works/ProxyChanger/icons/black_circle.png Binary files differnew file mode 100644 index 0000000..311762a --- /dev/null +++ b/works/ProxyChanger/icons/black_circle.png diff --git a/works/ProxyChanger/manifest.json b/works/ProxyChanger/manifest.json new file mode 100644 index 0000000..878cf8e --- /dev/null +++ b/works/ProxyChanger/manifest.json @@ -0,0 +1,21 @@ +{
+ "manifest_version": 2,
+ "name": "Proxy Changer",
+ "version": "1.0",
+ "description": "A proxy changer.",
+ "permissions": ["proxy", "storage"],
+ "browser_action": {
+ "default_icon": "icons/black_circle.png",
+ "default_title": "Change proxy.",
+ "default_popup": "popup/popup.html"
+ },
+ "options_ui": {
+ "page": "settings/settings.html",
+ "browser_style": true
+ },
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "proxy-changer@crupest.life"
+ }
+ }
+}
diff --git a/works/ProxyChanger/popup/popup.css b/works/ProxyChanger/popup/popup.css new file mode 100644 index 0000000..97601c2 --- /dev/null +++ b/works/ProxyChanger/popup/popup.css @@ -0,0 +1,28 @@ +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 new file mode 100644 index 0000000..16e4bd0 --- /dev/null +++ b/works/ProxyChanger/popup/popup.html @@ -0,0 +1,17 @@ +<!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 new file mode 100644 index 0000000..0615035 --- /dev/null +++ b/works/ProxyChanger/popup/popup.js @@ -0,0 +1,58 @@ +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();
+});
diff --git a/works/ProxyChanger/settings/settings.css b/works/ProxyChanger/settings/settings.css new file mode 100644 index 0000000..50ee923 --- /dev/null +++ b/works/ProxyChanger/settings/settings.css @@ -0,0 +1,9 @@ +.proxy-url-div {
+ display: flex;
+ align-items: center;
+}
+
+.proxy-url-div input {
+ margin-left: 1em;
+ flex: 1 1 auto;
+}
diff --git a/works/ProxyChanger/settings/settings.html b/works/ProxyChanger/settings/settings.html new file mode 100644 index 0000000..1883a2a --- /dev/null +++ b/works/ProxyChanger/settings/settings.html @@ -0,0 +1,30 @@ +<!DOCTYPE html>
+
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <link rel="stylesheet" href="settings.css" />
+ <link rel="stylesheet" href="chrome://browser/content/extension.css" />
+ </head>
+
+ <body>
+ <p>
+ If this proxy does not work, go to settings page and allow it to access
+ private windows. That is a must for setting proxy for extensions.
+ </p>
+ <p>
+ Input your custom manual proxy server. Feel free to make a XSS attack. If
+ you succeed to do that, report a bug to me, or maybe mozilla!
+ </p>
+ <p>
+ After input, re-click the button in popup in toolbar to activate it! I bet
+ you don't change this frequently so it's not a pain.
+ </p>
+ <p>Do at your own risk if you input an invalid url!</p>
+ <div class="browser-style proxy-url-div">
+ <label for="proxy_url">http_proxy</label>
+ <input id="proxy_url" type="text" />
+ </div>
+ <script src="settings.js"></script>
+ </body>
+</html>
diff --git a/works/ProxyChanger/settings/settings.js b/works/ProxyChanger/settings/settings.js new file mode 100644 index 0000000..ec10c0c --- /dev/null +++ b/works/ProxyChanger/settings/settings.js @@ -0,0 +1,14 @@ +browser.storage.local.get("proxyUrl").then(({ proxyUrl }) => {
+ console.log("Saved proxy url is", proxyUrl);
+ document.getElementById("proxy_url").value = proxyUrl;
+ document.getElementById("proxy_url").addEventListener("input", (e) => {
+ const { value } = e.currentTarget;
+ browser.storage.local
+ .set({
+ proxyUrl: value,
+ })
+ .then(() => {
+ console.log("New proxy url saved!", value);
+ });
+ });
+});
|