commit 1ee06a5f6c1008abb3f6ad8d916f598d6844fe75 Author: DeBros Date: Sun Feb 9 17:58:17 2025 +0200 Add files via upload diff --git a/README.md b/README.md new file mode 100644 index 0000000..a21d725 --- /dev/null +++ b/README.md @@ -0,0 +1,174 @@ +# ANyONe Extension - Manage Socks5 Proxy Settings + +## Overview +The ANyONe Proxy Extension is a powerful Chromium-based browser extension designed to help users manage and switch between different proxy settings effortlessly. It offers quick access through the browser's toolbar and detailed control via an options page. Additionally, the extension features a dApp Store, enabling users to access decentralized applications directly from the extension, ensuring secure and private browsing. This extension was created by DeBros and is not an official product from ANyONe; it's a community-driven project. + +## +

+Alt Text +

+ +## Features + +### 1. Quick Proxy Toggle +- **Enable/Disable Proxy**: A toggle switch in the popup allows users to quickly turn the proxy on or off. +- **Public Proxies**: + - **Default Activation**: Automatically uses community-contributed public proxy servers when no custom settings are applied. + - **Dynamic List**: Easily update the proxy list with a dedicated button within the extension. + +### 2. Custom Proxy Settings via Options Page + +- **Access Custom Settings**: Users can configure custom proxies by navigating to the options page. +- **Host and Port**: Specify the host IP and port number for your custom proxy. +- **No Proxy Exceptions**: Define specific websites or local addresses where the proxy should not be applied. +- **Detailed Configuration**: The options page allows for: + - Setting up custom proxy configurations. + - Managing exceptions to proxy use. + - Saving and applying changes for a tailored browsing experience. + +### 3. Proxy Status Indication +- **Status Messages**: The extension provides clear feedback on the current proxy status both in the popup and options page, including: + - Whether a proxy is enabled or disabled. + - The type of proxy in use (public or custom). + - The specific host and port being routed through. + +### 4. External Links +- **Check ANyONe**: A button to directly check the external IP and proxy status via the ANyONe service. +- **Credits**: Links to the developer's website and the GitHub repository for the extension. +- **Popup**: Links to the developer's website, X account, GitHub repository for the extension, and ANyONe website. + +## Usage + +### Enabling/Disabling Proxy +- Click the extension icon to open the popup. +- Use the toggle switch to enable or disable the proxy. +- The status message will update to reflect the current state. + +### Public Proxies: + +- **Default Usage**: When no custom settings are specified, the extension automatically uses public proxy servers, which are contributed and maintained by the ANyONe community. +- **Update Mechanism**: You can easily refresh the proxy list directly within the extension using an update button. +- **View Proxies**: To see the current list of community-powered public proxies, visit [https://github.com/DeBrosOfficial/ANyONe-Proxy-List](https://github.com/DeBrosOfficial/ANyONe-Proxy-List). + +### Setting a Custom Proxy +- Navigate to the options page by clicking the "Custom Settings" button in the popup. +- Enter the Host IP and Port for your custom proxy. +- Optionally, specify IP addresses or domains that should bypass the proxy in the "No Proxy for" field. +- Click "Save & Enable" to apply your settings. + +### Disabling the Proxy +- From the options page, click "Disable" to turn off the proxy settings, or from the popup, turn the toggle off. + +### Accessing the dApp Store +- Click the "dApp Store" button in the popup to open the dApp Store page. +- The dApp Store page will display available decentralized applications. + +## Installation + +### 1. Clone or Download the Repository +You have two options to get the extension on your system: + +- **Option A: Clone with Git** + ```bash + git clone "https://github.com/DeBrosOfficial/ANyONe-Extension.git" + ``` + +- **Option B: [Download ZIP](https://github.com/DeBrosOfficial/ANyONe-Extension/archive/refs/heads/main.zip)** + +### 2. Load Unpacked Extension in Chromium-based Browser +- Open your browser and navigate to the extensions page. +- Enable "Developer mode". +- Depending on your method in step 1: + - If you cloned the repository, click "Load unpacked" and select the cloned directory containing the `manifest.json` file. + - If you downloaded and unpacked, drag and drop the unpacked folder into the extensions window. + +## Contribution +Contributions are welcome! Please fork the repository and submit pull requests for any enhancements or bug fixes. + +For questions or further discussion, reach out to us on Telegram + +--- + +# Optional: Enhancing Security with Custom DNS Configuration + +Manually configuring your network's DNS can significantly boost your online privacy and security. Below, you'll find a selection of well-regarded, secure DNS servers that provide enhanced protection and privacy features: + +## Cloudflare DNS (1.1.1.1) + +- **IPv4**: 1.1.1.1 and 1.0.0.1 +- **IPv6**: 2606:4700:4700::1111 and 2606:4700:4700::1001 +- **Features**: Fast performance, does not log DNS queries, supports DNS over HTTPS (DoH) and DNS over TLS (DoT). +- **Website**: [https://1.1.1.1/dns](https://1.1.1.1/dns) + +## Quad9 (9.9.9.9) + +- **IPv4**: 9.9.9.9 and 149.112.112.112 +- **IPv6**: 2620:fe::9 and 2620:fe::fe:9 +- **Features**: Offers protection against malware and phishing, privacy with no logging of DNS queries. Supports DoT. +- **Website**: [https://quad9.net](https://quad9.net) + +## Mullvad DNS + +- **IPv4**: 194.242.2.1 and 194.242.2.2 +- **IPv6**: 2a07:e340::1 and 2a07:e340::2 +- **Features**: Complete privacy with no logging, supports DoH and DoT. Ideal for users concerned with anonymity. +- **Website**: [https://mullvad.net/en](https://mullvad.net/en) + +## AdGuard DNS + +- **IPv4**: 94.140.14.14 and 94.140.15.15 (without filters), 176.103.130.130 and 176.103.130.131 (with filters) +- **IPv6**: 2a10:50c0::ad1:ff and 2a10:50c0::ad2:ff (without filters), 2a10:50c0::bad1:ff and 2a10:50c0::bad2:ff (with filters) +- **Features**: Provides protection against ads, trackers, and phishing, as well as privacy with no logging. +- **Website**: [https://adguard-dns.io](https://adguard-dns.io) + +## How to Configure: + +- **For Windows**: Go to "Settings" > "Network & Internet" > "Change adapter options", right-click on your connection, select "Properties", then select "Internet Protocol Version 4 (TCP/IPv4)" or "Internet Protocol Version 6 (TCP/IPv6)" and enter the DNS addresses you want. +- **For macOS**: Navigate to "System Preferences" > "Network", select your connection, click on the "Advanced" button, go to the "DNS" tab, and add your DNS addresses. +- **For Linux**: Depending on the distribution, you can usually modify the `/etc/resolv.conf` file to add DNS addresses. +- **For Routers**: You'll typically find DNS settings in the advanced settings of your router. This will change the DNS for all devices connected to the network. + +--- + +# ANyONe Protocol: Connection and Setup Guide + +**About ANyONe Protocol**: ANyONe is a decentralized network protocol focused on providing privacy, security, and freedom on the internet. Whether you're looking to browse anonymously or secure your online communications, ANyONe offers versatile solutions for different needs. + +Explore multiple ways to interact with the ANyONe, whether you're connecting directly from your OS, setting up your own relay for personalized control, or using dedicated hardware for an optimized experience. Here's your guide: + +- **Linux**: Enjoy a seamless one-click setup. Learn more in the [Linux Connection Guide](https://docs.anyone.io/connect/connecting-to-linux). +- **macOS**: Connect easily with or without npm. Check the [macOS Connection Guide](https://docs.anyone.io/connect/connecting-to-macos). +- **Windows**: Benefit from a straightforward one-click setup. See the [Windows Connection Guide](https://docs.anyone.io/connect/connecting-to-windows). + +**Setting Up Your Own Relay**: For those interested in customizing your network participation or contributing to the ANyONe ecosystem, follow the [Relay Setup Guide](https://docs.anyone.io/relay). + +**Dedicated Hardware**: For a user-friendly, plug-and-play experience, ANyONe offers specialized hardware like the Anyone Router. This hardware is designed for non-technical users to contribute to and use the network seamlessly, offering: + + - **Ease of Use**: Power on, connect to Wi-Fi or Ethernet, and earn tokens for contributing your bandwidth. + - **Security**: Includes custom components like encryption chips similar to those in hardware wallets. + - **Diversity**: Enhances network coverage across various ISPs and introduces more independent operators. + + Check out the [Hardware Setup Guide](https://docs.anyone.io/hardware) or visit [Anyone Hardware](https://www.anyone.io/hardware) to learn more and pre-order. + +--- + +### + +
+ +
+ + linktree logo + + + twitter logo + + + telegram logo + + + youtube logo + +
+ +### diff --git a/html/options.html b/html/options.html new file mode 100644 index 0000000..1dac9e5 --- /dev/null +++ b/html/options.html @@ -0,0 +1,253 @@ + + + + Proxy Settings + + + +
+ +

My Socks5 Proxy Settings

+ + + + +
+ + +
+ +
+ + + +
+

+ + +
+ + + \ No newline at end of file diff --git a/html/popup.html b/html/popup.html new file mode 100644 index 0000000..7d3ef9b --- /dev/null +++ b/html/popup.html @@ -0,0 +1,217 @@ + + + + ANyONe Network Gateway + + + + +

ANyONe Proxy

+ + + +

+ +
+ + +
+ +
+ + +
+ + + + + + \ No newline at end of file diff --git a/html/store.html b/html/store.html new file mode 100644 index 0000000..7137157 --- /dev/null +++ b/html/store.html @@ -0,0 +1,46 @@ + + + + dApp Store + + + + Coming Soon Background +
Coming Soon
+ + + \ No newline at end of file diff --git a/icons/icon128.png b/icons/icon128.png new file mode 100644 index 0000000..8891ff8 Binary files /dev/null and b/icons/icon128.png differ diff --git a/icons/icon16.png b/icons/icon16.png new file mode 100644 index 0000000..8891ff8 Binary files /dev/null and b/icons/icon16.png differ diff --git a/icons/icon48.png b/icons/icon48.png new file mode 100644 index 0000000..8891ff8 Binary files /dev/null and b/icons/icon48.png differ diff --git a/images/anonlogo.png b/images/anonlogo.png new file mode 100644 index 0000000..49b856c Binary files /dev/null and b/images/anonlogo.png differ diff --git a/images/comingsoon.png b/images/comingsoon.png new file mode 100644 index 0000000..2f474ab Binary files /dev/null and b/images/comingsoon.png differ diff --git a/images/debroslogo.png b/images/debroslogo.png new file mode 100644 index 0000000..fe4aa0c Binary files /dev/null and b/images/debroslogo.png differ diff --git a/images/github.png b/images/github.png new file mode 100644 index 0000000..4f31862 Binary files /dev/null and b/images/github.png differ diff --git a/images/optionsback.png b/images/optionsback.png new file mode 100644 index 0000000..6f988af Binary files /dev/null and b/images/optionsback.png differ diff --git a/images/popupback.png b/images/popupback.png new file mode 100644 index 0000000..f3caaae Binary files /dev/null and b/images/popupback.png differ diff --git a/images/screenshot.jpg b/images/screenshot.jpg new file mode 100644 index 0000000..fa5b8ba Binary files /dev/null and b/images/screenshot.jpg differ diff --git a/images/x.png b/images/x.png new file mode 100644 index 0000000..3be7371 Binary files /dev/null and b/images/x.png differ diff --git a/js/background.js b/js/background.js new file mode 100644 index 0000000..4076544 --- /dev/null +++ b/js/background.js @@ -0,0 +1,265 @@ +let proxies = []; // Initially empty, will be populated from local storage or fetched from the server + +let currentProxyIndex = 0; // Start with the first proxy +let proxyEnabled = false; + +console.log("background.js is running"); + +function applyProxySettings(host, port, exceptions = []) { + const proxyConfig = { + mode: "fixed_servers", + rules: { + singleProxy: { + scheme: "socks5", + host, + port, + }, + bypassList: exceptions.concat([""]), + }, + }; + + chrome.proxy.settings.set({ value: proxyConfig, scope: "regular" }, () => { + const lastError = chrome.runtime.lastError; + if (lastError) { + console.error("Error applying proxy settings:", lastError); + fallbackToNextProxy(); // Move to the next proxy if the current one fails + } else { + console.log(`Proxy applied: ${host}:${port}`); + proxyEnabled = true; + } + }); +} + +function clearProxySettings() { + chrome.proxy.settings.clear({}, () => { + const lastError = chrome.runtime.lastError; + if (lastError) { + console.error("Error clearing proxy settings:", lastError); + } else { + console.log("Proxy settings cleared."); + proxyEnabled = false; + currentProxyIndex = 0; // Reset to the first proxy + } + }); +} + +function fallbackToNextProxy() { + currentProxyIndex = (currentProxyIndex + 1) % proxies.length; // Move to the next proxy in the list + if (proxies.length > 0) { + const { host, port } = proxies[currentProxyIndex]; + console.log(`Falling back to proxy: ${host}:${port}`); + applyProxySettings(host, port); + } else { + console.error("No proxies available to fall back to."); + } +} + +function checkProxyFunctionality(proxy, callback) { + const proxyConfig = { + mode: "fixed_servers", + rules: { + singleProxy: { + scheme: "socks5", + host: proxy.host, + port: proxy.port + }, + bypassList: [""] + } + }; + + chrome.proxy.settings.set({ value: proxyConfig, scope: "regular" }, () => { + if (chrome.runtime.lastError) { + console.error("Error setting proxy for check:", chrome.runtime.lastError); + callback(false); + return; + } + + // Use Mullvad's DNS server for privacy check + fetch('https://doh.mullvad.net/dns-query?dns=q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB', { + mode: 'no-cors', + headers: { 'accept': 'application/dns-message' } + }) + .then(response => { + if (response.ok) { + console.log("Proxy check successful"); + callback(true); // Connection successful + } else { + console.log("Proxy check failed"); + callback(false); // Connection failed + } + }) + .catch(error => { + console.error("Error in proxy check:", error); + callback(false); + }); + }); +} + +function enableFirstWorkingProxy(callback) { + let index = 0; + + function tryNextProxy() { + if (index >= proxies.length) { + console.log("No working proxy found"); + callback(false); + return; + } + + const proxy = proxies[index]; + console.log("Checking proxy:", proxy.host + ":" + proxy.port); + checkProxyFunctionality(proxy, (isWorking) => { + if (isWorking) { + currentProxyIndex = index; // Update currentProxyIndex + console.log("Found working proxy:", proxy.host + ":" + proxy.port); + applyProxySettings(proxy.host, proxy.port); + chrome.storage.local.set({ proxyEnabled: true, currentProxy: proxy }); + callback(true); + } else { + index++; + tryNextProxy(); + } + }); + } + + tryNextProxy(); +} + +function fetchProxies() { + console.log("Starting to fetch proxies..."); + return fetch('https://raw.githubusercontent.com/DeBrosOfficial/ANyONe-Proxy-List/main/anonproxies.json') // list of public proxies + .then(response => { + console.log("Response status:", response.status); + if (!response.ok) { + console.error("Response not OK"); + throw new Error('Network response was not ok'); + } + return response.json(); + }) + .then(data => { + console.log("Data received:", data); + proxies = data; + // Save the proxies to local storage + chrome.storage.local.set({ 'proxyList': proxies }, () => { + console.log('Proxies updated and saved:', proxies); + }); + }) + .catch(error => { + console.error('Failed to fetch proxies:', error); + }); +} + +// Load proxies from storage on extension startup if they exist +chrome.storage.local.get('proxyList', function(result) { + if (result.proxyList) { + proxies = result.proxyList; + console.log('Loaded proxies from storage:', proxies); + } else { + console.log('No proxies found in local storage, fetch required.'); + } +}); + +// This event listener runs when the extension is first installed or updated +chrome.runtime.onInstalled.addListener((details) => { + if (details.reason === "install") { + console.log("Extension installed for the first time. Fetching proxies..."); + // Fetch proxies automatically on first install but don't enable them + fetchProxies().then(() => { + console.log("Proxies updated on first install."); + // Don't enable proxy automatically, just fetch and store it + }); + } +}); + +chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { + console.log("Received message in background:", message); + if (message.action === "enableProxy") { + console.log("Enabling proxy..."); + chrome.runtime.sendMessage({ action: "showLoadingMessage", message: "Please wait..." }); + enableFirstWorkingProxy((success) => { + if (success) { + console.log("Proxy enabled successfully"); + sendResponse({ status: "enabled", proxy: proxies[currentProxyIndex] }); + } else { + console.log("Failed to enable proxy"); + sendResponse({ status: "error", message: "No public proxy available at this moment. Please configure a custom proxy in the settings." }); + } + }); + } else if (message.action === "disableProxy") { + console.log("Disabling proxy..."); + clearProxySettings(); + chrome.storage.local.set({ proxyEnabled: false, proxyType: null }); + sendResponse({ status: "disabled" }); + chrome.tabs.query({}, function(tabs) { + for (let tab of tabs) { + chrome.tabs.sendMessage(tab.id, {action: "disableProxy"}, function(response) { + if (chrome.runtime.lastError) { + console.warn("Warning: Could not send message to tab " + tab.id + ". Tab might have been closed.", chrome.runtime.lastError.message); + } + }); + } + }); + } else if (message.action === "updateProxy") { + console.log("Updating proxy settings..."); + if (message.type === "custom") { + // Custom proxy enable + applyProxySettings(message.proxy.host, parseInt(message.proxy.port), message.exceptions || []); + chrome.storage.local.set({ + proxyEnabled: true, + proxyType: "custom", + proxyIP: message.proxy.host, + proxyPort: message.proxy.port + }); + sendResponse({ status: "enabled", proxy: message.proxy }); + chrome.tabs.query({}, function(tabs) { + for (let tab of tabs) { + chrome.tabs.sendMessage(tab.id, {action: "updatePopupState"}, function(response) { + if (chrome.runtime.lastError) { + console.warn("Warning: Could not send message to tab " + tab.id + ". Tab might have been closed.", chrome.runtime.lastError.message); + } + }); + } + }); + } else if (message.type === "public") { + // Public proxy enable + chrome.runtime.sendMessage({ action: "showLoadingMessage", message: "Please wait..." }); + enableFirstWorkingProxy((success) => { + if (success) { + console.log("Public proxy enabled successfully"); + sendResponse({ status: "enabled", proxy: proxies[currentProxyIndex] }); + } else { + console.log("Failed to enable public proxy"); + sendResponse({ status: "error", message: "No public proxy available at this moment. Please configure a custom proxy in the settings." }); + } + }); + } else if (message.type === "disabled") { + clearProxySettings(); + chrome.storage.local.set({ proxyEnabled: false, proxyType: null }); + sendResponse({ status: "disabled" }); + chrome.tabs.query({}, function(tabs) { + for (let tab of tabs) { + chrome.tabs.sendMessage(tab.id, {action: "disableProxy"}, function(response) { + if (chrome.runtime.lastError) { + console.warn("Warning: Could not send message to tab " + tab.id + ". Tab might have been closed.", chrome.runtime.lastError.message); + } + }); + } + }); + } + } else if (message.action === "updateProxies") { + console.log("Attempting to update proxies..."); + fetchProxies().then(() => { + console.log("Proxies fetched successfully"); + sendResponse({success: true, proxies: proxies}); + chrome.runtime.sendMessage({ action: "updateStatus", message: "Proxy list updated successfully!", color: "#2ecc71" }); + }).catch(error => { + console.error("Failed to fetch proxies:", error); + sendResponse({success: false, message: "Failed to update proxy list."}); + chrome.runtime.sendMessage({ action: "updateStatus", message: "Failed to update proxy list.", color: "#e74c3c" }); + }); + return true; // Indicates this is an async response + } else { + console.log("Unknown action received:", message.action); + sendResponse({ status: "error", message: "Unknown action." }); + } + return true; +}); \ No newline at end of file diff --git a/js/options.js b/js/options.js new file mode 100644 index 0000000..f29be5b --- /dev/null +++ b/js/options.js @@ -0,0 +1,214 @@ +const proxyIP = document.getElementById("proxyIP"); +const proxyPort = document.getElementById("proxyPort"); +const noProxyFor = document.getElementById("noProxyFor"); +const saveSettings = document.getElementById("saveSettings"); +const disableProxy = document.getElementById("disableProxy"); +const statusMessage = document.getElementById("statusMessage"); +const checkAnyoneButton = document.getElementById('checkAnyoneButton'); + +// Validate IP address +function isValidIP(ip) { + const ipRegex = /^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]{1,2})$/; + return ipRegex.test(ip); +} + +// Validate port number +function isValidPort(port) { + const num = parseInt(port, 10); + return num > 0 && num <= 65535; +} + +// Load saved settings on page load +chrome.storage.local.get(["proxyIP", "proxyPort", "proxyType", "noProxyFor"], (settings) => { + if (chrome.runtime.lastError) { + console.error("Error retrieving settings:", chrome.runtime.lastError); + return; + } + proxyIP.value = settings.proxyIP || ""; + proxyPort.value = settings.proxyPort || ""; + noProxyFor.value = settings.noProxyFor || ""; +}); + +// Function to check internet connectivity +function checkInternetConnection(host, port) { + return new Promise((resolve, reject) => { + const proxyConfig = { + mode: "fixed_servers", + rules: { + singleProxy: { + scheme: "socks5", + host: host, + port: parseInt(port, 10) + }, + bypassList: [""] + } + }; + + chrome.proxy.settings.set({ value: proxyConfig, scope: "regular" }, () => { + if (chrome.runtime.lastError) { + reject(chrome.runtime.lastError.message); + return; + } + + fetch('https://doh.mullvad.net/dns-query?dns=q80BAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB', { + method: 'GET', + mode: 'no-cors', + headers: { 'accept': 'application/dns-message' } + }) + .then(response => { + if (response.ok) { + resolve(true); // Connection successful + } else { + reject("Failed to connect via proxy"); // Connection failed + } + }) + .catch(error => { + reject(error.message || "Network error encountered"); + }); + }); + }); +} + +// Function to apply Proxy Settings after saving +function applyProxySettings(host, port, exceptions = []) { + const proxyConfig = { + mode: "fixed_servers", + rules: { + singleProxy: { + scheme: "socks5", + host: host, + port: parseInt(port, 10) + }, + bypassList: exceptions.concat([""]) + } + }; + + chrome.proxy.settings.set({ value: proxyConfig, scope: "regular" }, () => { + if (chrome.runtime.lastError) { + statusMessage.textContent = "Error applying proxy: " + chrome.runtime.lastError.message; + statusMessage.style.color = "red"; + statusMessage.style.fontSize = "14px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + } else { + console.log(`Proxy applied: ${host}:${port}`); + statusMessage.textContent = `Proxy applied: ${host}:${port}`; + statusMessage.style.color = "#2ecc71"; + statusMessage.style.fontSize = "16px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + clearStatusMessage(); + } + }); +} + +// Function to clear status message after a delay +function clearStatusMessage() { + setTimeout(() => { + statusMessage.textContent = ""; + }, 5000); // Clear message after 5 seconds (5000 milliseconds) +} + +// Save settings when clicking "Save Settings" +saveSettings.addEventListener("click", () => { + if (!isValidIP(proxyIP.value)) { + statusMessage.textContent = "Invalid IP address."; + statusMessage.style.color = "red"; + statusMessage.style.fontSize = "16px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + return; + } + if (!isValidPort(proxyPort.value)) { + statusMessage.textContent = "Invalid port number. Must be between 1 and 65535."; + statusMessage.style.color = "red"; + statusMessage.style.fontSize = "14px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + return; + } + + statusMessage.textContent = "Please wait..."; + statusMessage.style.color = "#f39c12"; + statusMessage.style.fontSize = "16px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + + const noProxyExceptions = noProxyFor.value.split(',').map(ex => ex.trim()); + const filteredExceptions = noProxyExceptions.filter(ex => ex !== ''); + + checkInternetConnection(proxyIP.value, proxyPort.value) + .then(() => { + chrome.storage.local.set({ + proxyIP: proxyIP.value, + proxyPort: proxyPort.value, + proxyType: "custom", + noProxyFor: filteredExceptions.join(", "), + proxyEnabled: true + }, () => { + if (chrome.runtime.lastError) { + statusMessage.textContent = "Error saving settings: " + chrome.runtime.lastError.message; + statusMessage.style.color = "red"; + statusMessage.style.fontSize = "14px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + } else { + statusMessage.textContent = "Proxy settings saved and connection verified!"; + statusMessage.style.color = "#2ecc71"; + statusMessage.style.fontSize = "16px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + applyProxySettings(proxyIP.value, proxyPort.value, filteredExceptions); + chrome.runtime.sendMessage({ action: "updateProxy", type: "custom", proxy: { host: proxyIP.value, port: parseInt(proxyPort.value) }, exceptions: filteredExceptions }); + clearStatusMessage(); + } + }); + }) + .catch((error) => { + statusMessage.textContent = `Proxy connection failed: ${error}. Settings not applied.`; + statusMessage.style.color = "red"; + statusMessage.style.fontSize = "14px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + chrome.proxy.settings.clear({}); + }); +}); + +disableProxy.addEventListener("click", () => { + chrome.proxy.settings.clear({}, () => { + if (chrome.runtime.lastError) { + statusMessage.textContent = "Error disabling proxy: " + chrome.runtime.lastError.message; + statusMessage.style.color = "red"; + statusMessage.style.fontSize = "14px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + } else { + statusMessage.textContent = "Proxy has been disabled!"; + statusMessage.style.color = "#e74c3c"; + statusMessage.style.fontSize = "16px"; + statusMessage.style.fontFamily = "Arial"; + statusMessage.style.fontWeight = "bold"; + clearStatusMessage(); + console.log("Proxy settings disabled."); + chrome.storage.local.get(["noProxyFor"], (result) => { + chrome.storage.local.set({ + proxyType: null, + noProxyFor: result.noProxyFor, + proxyEnabled: false + }, () => { + if (chrome.runtime.lastError) { + console.error("Error updating storage:", chrome.runtime.lastError); + } else { + chrome.runtime.sendMessage({ action: "disableProxy" }); + } + }); + }); + clearStatusMessage(); + } + }); +}); + +// Open Check Anyone page +checkAnyoneButton.addEventListener("click", () => { + window.open("https://check.en.anyone.tech/", "_blank"); +}); \ No newline at end of file diff --git a/js/popup.js b/js/popup.js new file mode 100644 index 0000000..ffb3083 --- /dev/null +++ b/js/popup.js @@ -0,0 +1,179 @@ +document.addEventListener("DOMContentLoaded", () => { + const proxyToggle = document.getElementById("proxyToggle"); + const statusMessage = document.getElementById("statusMessage"); + const optionsButton = document.getElementById("optionsButton"); + const checkAnyoneButton = document.getElementById("checkAnyoneButton"); + const dappStoreButton = document.getElementById("dappStoreButton"); + const updateProxiesButton = document.getElementById("updateProxiesButton"); + + if (!checkAnyoneButton) { + checkAnyoneButton = document.createElement("button"); + checkAnyoneButton.id = "checkAnyoneButton"; + checkAnyoneButton.textContent = "Check ANyONe"; + checkAnyoneButton.style.marginBottom = "10px"; + checkAnyoneButton.addEventListener("click", () => { + window.open("https://check.en.anyone.tech/", "_blank"); + }); + } + + if (!dappStoreButton) { + dappStoreButton = document.createElement("button"); + dappStoreButton.id = "dappStoreButton"; + dappStoreButton.textContent = "dApp Store"; + dappStoreButton.style.marginBottom = "10px"; + dappStoreButton.addEventListener("click", () => { + const storeUrl = chrome.runtime.getURL("store.html"); + chrome.tabs.create({ url: storeUrl }); + }); + } + + if (updateProxiesButton) { + updateProxiesButton.addEventListener("click", () => { + console.log("Update Proxies button clicked in popup.js"); + statusMessage.textContent = "Updating proxies..."; + statusMessage.style.color = "#f39c12"; // Orange for loading + chrome.runtime.sendMessage({ action: "updateProxies" }, (response) => { + if (response && response.success) { + console.log('Proxy list update was successful'); + statusMessage.textContent = 'Proxies updated successfully!'; + statusMessage.style.color = "#2ecc71"; // Green for success + } else { + console.log('Proxy list update failed'); + statusMessage.textContent = 'Failed to update proxies.'; + statusMessage.style.color = "#e74c3c"; // Red for failure + } + // Clear the update message after 3 seconds and reinitialize the UI + setTimeout(() => { + initializeUI(); + }, 3000); + }); + }); + } + + const buttonContainer = document.querySelector(".button-container"); + if (buttonContainer) { + buttonContainer.innerHTML = ''; + buttonContainer.appendChild(optionsButton); + buttonContainer.appendChild(dappStoreButton); + buttonContainer.appendChild(updateProxiesButton); + } + + if (statusMessage && !checkAnyoneButton.parentNode) { + statusMessage.parentNode.insertBefore(checkAnyoneButton, statusMessage.nextSibling); + } + + function updateStatusMessage(isEnabled, proxyType, proxy) { + if (isEnabled) { + if (proxyType === "custom") { + statusMessage.textContent = `Custom Proxy is ENABLED and routing through ${proxy.host}:${proxy.port}`; + statusMessage.style.color = "#2ecc71"; // Green for custom + } else { + statusMessage.textContent = `Public Proxy is ENABLED and routing through ${proxy.host}:${proxy.port}`; + statusMessage.style.color = "#03bdc5"; // Blue for public + } + } else { + statusMessage.textContent = "Proxy is DISABLED"; + statusMessage.style.color = "#e74c3c"; + } + } + + function updateUI(isEnabled, proxyType, proxy) { + proxyToggle.checked = isEnabled; + updateStatusMessage(isEnabled, proxyType, proxy); + } + + function updateStatusFromBackground(data) { + statusMessage.textContent = data.message; + statusMessage.style.color = data.color; + setTimeout(() => { + statusMessage.textContent = ""; + initializeUI(); // Reinitialize the UI to show the current status + }, 3000); + } + + // Initialize the toggle state + function initializeUI() { + chrome.storage.local.get(["proxyEnabled", "proxyType", "currentProxy", "proxyIP", "proxyPort"], (data) => { + const isEnabled = data.proxyEnabled || false; + const proxyType = data.proxyType || "public"; + const currentProxy = proxyType === "custom" + ? { host: data.proxyIP || "127.0.0.1", port: data.proxyPort || 9050 } + : (data.currentProxy || { host: "51.75.175.24", port: 9052 }); // Default public Proxy + + updateUI(isEnabled, proxyType, currentProxy); + }); + } + + initializeUI(); + + proxyToggle.addEventListener("change", () => { + const isEnabled = proxyToggle.checked; + + if (isEnabled) { + chrome.storage.local.get(["proxyType"], (data) => { + if (data.proxyType === "custom") { + chrome.storage.local.get(["proxyIP", "proxyPort"], (settings) => { + chrome.runtime.sendMessage({ action: "updateProxy", type: "custom", proxy: { host: settings.proxyIP, port: settings.proxyPort } }, (response) => { + if (response && response.status === "enabled") { + updateUI(true, "custom", { host: settings.proxyIP, port: settings.proxyPort }); + } else { + alert("Failed to enable custom proxy. Please try again."); + proxyToggle.checked = false; + initializeUI(); + } + }); + }); + } else { + chrome.runtime.sendMessage({ action: "enableProxy" }, (response) => { + if (response && response.status === "enabled" && response.proxy) { + chrome.storage.local.set({ proxyEnabled: true, currentProxy: response.proxy, proxyType: "public" }); + updateUI(true, "public", response.proxy); + } else { + alert(response.message || "Failed to enable public proxy. Please try again."); + proxyToggle.checked = false; + initializeUI(); + } + }); + } + }); + } else { + chrome.runtime.sendMessage({ action: "disableProxy" }, (response) => { + if (response && response.status === "disabled") { + chrome.storage.local.set({ proxyEnabled: false, proxyType: null }); + updateUI(false); + } else { + alert("Failed to disable proxy. Please try again."); + proxyToggle.checked = true; + initializeUI(); + } + }); + } + }); + + chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { + if (message.action === "updatePopupState" || message.action === "disableProxy") { + initializeUI(); + } else if (message.action === "showLoadingMessage") { + statusMessage.textContent = message.message; + statusMessage.style.color = "#f39c12"; // Orange for loading + } else if (message.action === "updateStatus") { + updateStatusFromBackground(message); + } + }); + + // Open options page + optionsButton.addEventListener("click", () => { + chrome.runtime.openOptionsPage(); + }); + + // Open Check Anyone page + checkAnyoneButton.addEventListener("click", () => { + window.open("https://check.en.anyone.tech/", "_blank"); + }); + + // Open dApp Store page + dappStoreButton.addEventListener("click", () => { + const storeUrl = chrome.runtime.getURL("html/store.html"); + chrome.tabs.create({ url: storeUrl }); + }); +}); \ No newline at end of file diff --git a/js/store.js b/js/store.js new file mode 100644 index 0000000..39059b9 --- /dev/null +++ b/js/store.js @@ -0,0 +1,27 @@ +document.addEventListener("DOMContentLoaded", () => { + const comingSoonText = document.getElementById("comingSoon"); + const comingSoonImage = document.getElementById("fullScreenImage"); + + // Check if the domain is working + fetch('https://store.debros.io', { method: 'HEAD', mode: 'no-cors' }) + .then(response => { + if (response.ok) { + window.location.href = 'https://store.debros.io'; + } else { + showComingSoonMessage(); + } + }) + .catch(() => { + showComingSoonMessage(); + }); + + function showComingSoonMessage() { + setTimeout(() => { + comingSoonImage.style.opacity = 1; + }, 200); + + setTimeout(() => { + comingSoonText.style.opacity = 1; + }, 1000); + } +}); \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..6683492 --- /dev/null +++ b/manifest.json @@ -0,0 +1,32 @@ +{ + "manifest_version": 3, + "name": "ANyONe Extension", + "version": "1.0.2", + "description": "Manage Socks5 proxy settings", + "permissions": [ + "proxy", + "storage", + "tabs", + "scripting" + ], + "host_permissions": [""], + "background": { + "service_worker": "js/background.js" + }, + "action": { + "default_popup": "html/popup.html", + "default_title": "Proxy Settings" + }, + "options_ui": { + "page": "html/options.html", + "open_in_tab": true + }, + "icons": { + "16": "icons/icon16.png", + "48": "icons/icon48.png", + "128": "icons/icon128.png" + }, + "content_security_policy": { + "extension_pages": "script-src 'self'; object-src 'self'" + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a5b6202 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "ANyONe-Extension", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}