├── icons └── icon.svg ├── README.md ├── popup.js ├── manifest.json ├── popup.html └── background.js /icons/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | :hocho: 2 | 3 | Too-simple, opensource, needs no privileges web extension to proxy. 4 | -------------------------------------------------------------------------------- /popup.js: -------------------------------------------------------------------------------- 1 | document.addEventListener('DOMContentLoaded', function () { 2 | 3 | console.log("setting up proxy"); 4 | 5 | document.getElementById('set-proxy').addEventListener('click', function () { 6 | console.log("setting proxy"); 7 | browser.runtime.sendMessage({ 8 | action: 'setProxy', 9 | host: '127.0.0.1', 10 | port: 8080, 11 | }); 12 | }); 13 | 14 | document.getElementById('clear-proxy').addEventListener('click', function () { 15 | console.log("clearing proxy"); 16 | browser.runtime.sendMessage({ 17 | action: 'clearProxy', 18 | }); 19 | }); 20 | }); -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Hello World Extension", 4 | "version": "1.0", 5 | "description": "A simple Hello World Firefox extension", 6 | "icons": { 7 | "48": "icons/icon-48.png", 8 | "96": "icons/icon-96.png" 9 | }, 10 | "browser_action": { 11 | "default_popup": "popup.html", 12 | "default_title": "Hello World Extension" 13 | }, 14 | "background": { 15 | "scripts": ["background.js"] 16 | }, 17 | "permissions": [ 18 | "activeTab", 19 | "contextMenus", 20 | "proxy" 21 | ] 22 | } -------------------------------------------------------------------------------- /popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 56 | 57 | 58 |
59 |
60 |
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | // Background script for Hello World Extension 2 | 3 | // Listen for messages from popup 4 | browser.runtime.onMessage.addListener(async function(message, sender, sendResponse) { 5 | 6 | switch (message.action) { 7 | case 'setProxy': 8 | setProxy(message.host, message.port, "manual"); 9 | break; 10 | case "clearProxy": 11 | setProxy("127.0.0.1", "8080", "system"); 12 | break; 13 | default: 14 | console.error("Unknown action"); 15 | } 16 | 17 | sendResponse({ 18 | success: true, 19 | message: "Action completed" 20 | }); 21 | 22 | }); 23 | 24 | // Extension installation event 25 | browser.runtime.onInstalled.addListener(function(details) { 26 | if (details.reason === 'install') { 27 | console.log('Hello World Extension installed!'); 28 | 29 | // Set default badge text 30 | browser.browserAction.setBadgeText({ 31 | text: '1' 32 | }); 33 | 34 | browser.browserAction.setBadgeBackgroundColor({ 35 | color: '#4CAF50' 36 | }); 37 | } 38 | }); 39 | 40 | // Extension startup event 41 | browser.runtime.onStartup.addListener(function() { 42 | console.log('Hello World Extension started!'); 43 | }); 44 | 45 | // Optional: Add a context menu item 46 | browser.contextMenus.create({ 47 | id: 'hello-world-menu', 48 | title: 'Hello World!', 49 | contexts: ['page'] 50 | }); 51 | 52 | browser.contextMenus.onClicked.addListener(function(info, tab) { 53 | if (info.menuItemId === 'hello-world-menu') { 54 | browser.tabs.sendMessage(tab.id, { 55 | action: 'showHelloWorld' 56 | }).catch(function(error) { 57 | // If content script is not loaded, inject it 58 | browser.tabs.executeScript(tab.id, { 59 | code: 'alert("Hello World from context menu! 🌍");' 60 | }); 61 | }); 62 | } 63 | }); 64 | 65 | function setProxy(host, port, mode) { 66 | console.log(":thinking_face:", mode); 67 | 68 | browser.proxy.settings.set({ 69 | value: { 70 | proxyType: mode, 71 | ssl: `${host}:${port}`, 72 | http: `${host}:${port}`, 73 | httpProxyAll: true, 74 | passthrough: "localhost,127.0.0.1", 75 | } 76 | }).then(() => { 77 | console.log("Proxy set"); 78 | }).catch((error) => { 79 | console.error("Error setting proxy", error); 80 | }); 81 | 82 | console.log("Yayy"); 83 | } --------------------------------------------------------------------------------