diff --git a/Makefile b/Makefile index 06e1bec..abbf49e 100644 --- a/Makefile +++ b/Makefile @@ -26,6 +26,7 @@ uninstall: $(PREFIX)/share/webext/i2psetproxy.js@eyedeekay.github.io \ $(PREFIX)/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384} + ls: ls -lah $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io; \ ls -lah $(PREFIX)/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384} @@ -36,8 +37,8 @@ clean: ## EVEN RELEASES are AMO RELEASES ## ODD RELEASES are SELFHOSTED RELEASES -MOZ_VERSION=0.42 -VERSION=0.43 +MOZ_VERSION=0.44 +VERSION=0.45 #VERSION=$(MOZ_VERSION) #VERSION=1.27 @@ -86,7 +87,7 @@ zip: version --exclude="./.git" -r -FS ../i2psetproxy.js.zip * release: - cat desc | gothub release -p -u eyedeekay -r i2psetproxy.js -t $(VERSION) -n $(VERSION) -d - + cat desc debian/changelog | gothub release -p -u eyedeekay -r i2psetproxy.js -t $(VERSION) -n $(VERSION) -d - delete-release: gothub delete -u eyedeekay -r i2psetproxy.js -t $(VERSION); true @@ -105,19 +106,21 @@ WEB_EXT_API_SECRET=AMO_SECRET tk: echo $(WEB_EXT_API_KEY) +submit: moz-sign moz-submit + ##ODD NUMBERED, SELF-DISTRIBUTED VERSIONS HERE! -sign: version +moz-sign: version @echo "Using the 'sign' target to instantly sign an extension for self-distribution" @echo "requires a JWT API Key and Secret from addons.mozilla.org to be made available" @echo "to the Makefile under the variables WEB_EXT_API_KEY and WEB_EXT_API_SECRET." - web-ext sign --channel unlisted --config-discovery false --api-key $(WEB_EXT_API_KEY) --api-secret $(WEB_EXT_API_SECRET) + web-ext sign --channel unlisted --config-discovery false --api-key $(WEB_EXT_API_KEY) --api-secret $(WEB_EXT_API_SECRET); true ##EVEN NUMBERED, MOZILLA-DISTRIBUTED VERSIONS HERE! -submit: moz-version +moz-submit: moz-version @echo "Using the 'submit' target to instantly sign an extension for Mozilla distribution" @echo "requires a JWT API Key and Secret from addons.mozilla.org to be made available" @echo "to the Makefile under the variables WEB_EXT_API_KEY and WEB_EXT_API_SECRET." - web-ext sign --channel listed --config-discovery false --api-key $(WEB_EXT_API_KEY) --api-secret $(WEB_EXT_API_SECRET) + web-ext sign --channel listed --config-discovery false --api-key $(WEB_EXT_API_KEY) --api-secret $(WEB_EXT_API_SECRET); true upload-xpi: gothub upload -u eyedeekay -r i2psetproxy.js -t $(VERSION) -n "i2ppb@eyedeekay.github.io.xpi" -f "./i2ppb@eyedeekay.github.io.xpi" @@ -125,11 +128,6 @@ upload-xpi: upload-deb: gothub upload -u eyedeekay -r i2psetproxy.js -t $(VERSION) -n "i2psetproxy.js_$(VERSION)-1_amd64.deb" -f "../i2psetproxy.js_$(VERSION)-1_amd64.deb" -lib: libpolyfill - -libpolyfill: - wget -O chromium/browser-polyfill.js https://unpkg.com/webextension-polyfill/dist/browser-polyfill.js - fmt: cleancss -O1 all -O2 all --format beautify home.css -o .home.css && mv .home.css home.css cleancss -O1 all -O2 all --format beautify info.css -o .info.css && mv .info.css info.css diff --git a/README.md b/README.md index b1b2903..08fa7c7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ WebExtension that does extended configuration of a dedicated I2P browser. While needing to touch about:config and disables several fingerprinting/de-anonymization vectors on it's own. It is also the easiest way to configure an I2P browser on Android without requiring the user to root their -device. +device. It aims to be as similar to a fully-fledged I2P browser as possible and +borrows some code from I2P Rhizome(Which it is also compatible with). The Old Version --------------- diff --git a/background.js b/background.js index eeaebb6..230db28 100644 --- a/background.js +++ b/background.js @@ -90,6 +90,7 @@ if (!isDroid()) { chrome.windows.onRemoved.addListener(themeWindow); chrome.tabs.onUpdated.addListener(themeWindowByTab); chrome.tabs.onActivated.addListener(themeWindowByTab); +} else { } function themeWindowByTab(tabId) { diff --git a/chromium/LICENSE b/chromium/LICENSE deleted file mode 100644 index a612ad9..0000000 --- a/chromium/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/chromium/browser-polyfill.js b/chromium/browser-polyfill.js deleted file mode 100644 index 36d18b9..0000000 --- a/chromium/browser-polyfill.js +++ /dev/null @@ -1,1253 +0,0 @@ -(function(global, factory) { - if (typeof define === "function" && define.amd) { - define("webextension-polyfill", ["module"], factory); - } else if (typeof exports !== "undefined") { - factory(module); - } else { - var mod = { - exports: {} - }; - factory(mod); - global.browser = mod.exports; - } -})(this, function(module) { - /* webextension-polyfill - v0.5.0 - Thu Sep 26 2019 22:22:26 */ - /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ - /* vim: set sts=2 sw=2 et tw=80: */ - /* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - "use strict"; - - if ( - typeof browser === "undefined" || - Object.getPrototypeOf(browser) !== Object.prototype - ) { - const CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE = - "The message port closed before a response was received."; - const SEND_RESPONSE_DEPRECATION_WARNING = - "Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)"; - - /* Wrapping the bulk of this polyfill in a one-time-use function is a minor - optimization for Firefox. Since Spidermonkey does not fully parse the - contents of a function until the first time it's called, and since it will - never actually need to be called, this allows the polyfill to be included - in Firefox nearly for free. */ - const wrapAPIs = extensionAPIs => { - /* NOTE: apiMetadata is associated to the content of the api-metadata.json file - at build time by replacing the following "include" with the content of the - JSON file. */ - const apiMetadata = { - alarms: { - clear: { - minArgs: 0, - maxArgs: 1 - }, - clearAll: { - minArgs: 0, - maxArgs: 0 - }, - get: { - minArgs: 0, - maxArgs: 1 - }, - getAll: { - minArgs: 0, - maxArgs: 0 - } - }, - bookmarks: { - create: { - minArgs: 1, - maxArgs: 1 - }, - get: { - minArgs: 1, - maxArgs: 1 - }, - getChildren: { - minArgs: 1, - maxArgs: 1 - }, - getRecent: { - minArgs: 1, - maxArgs: 1 - }, - getSubTree: { - minArgs: 1, - maxArgs: 1 - }, - getTree: { - minArgs: 0, - maxArgs: 0 - }, - move: { - minArgs: 2, - maxArgs: 2 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - removeTree: { - minArgs: 1, - maxArgs: 1 - }, - search: { - minArgs: 1, - maxArgs: 1 - }, - update: { - minArgs: 2, - maxArgs: 2 - } - }, - browserAction: { - disable: { - minArgs: 0, - maxArgs: 1, - fallbackToNoCallback: true - }, - enable: { - minArgs: 0, - maxArgs: 1, - fallbackToNoCallback: true - }, - getBadgeBackgroundColor: { - minArgs: 1, - maxArgs: 1 - }, - getBadgeText: { - minArgs: 1, - maxArgs: 1 - }, - getPopup: { - minArgs: 1, - maxArgs: 1 - }, - getTitle: { - minArgs: 1, - maxArgs: 1 - }, - openPopup: { - minArgs: 0, - maxArgs: 0 - }, - setBadgeBackgroundColor: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - setBadgeText: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - setIcon: { - minArgs: 1, - maxArgs: 1 - }, - setPopup: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - setTitle: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - } - }, - browsingData: { - remove: { - minArgs: 2, - maxArgs: 2 - }, - removeCache: { - minArgs: 1, - maxArgs: 1 - }, - removeCookies: { - minArgs: 1, - maxArgs: 1 - }, - removeDownloads: { - minArgs: 1, - maxArgs: 1 - }, - removeFormData: { - minArgs: 1, - maxArgs: 1 - }, - removeHistory: { - minArgs: 1, - maxArgs: 1 - }, - removeLocalStorage: { - minArgs: 1, - maxArgs: 1 - }, - removePasswords: { - minArgs: 1, - maxArgs: 1 - }, - removePluginData: { - minArgs: 1, - maxArgs: 1 - }, - settings: { - minArgs: 0, - maxArgs: 0 - } - }, - commands: { - getAll: { - minArgs: 0, - maxArgs: 0 - } - }, - contextMenus: { - remove: { - minArgs: 1, - maxArgs: 1 - }, - removeAll: { - minArgs: 0, - maxArgs: 0 - }, - update: { - minArgs: 2, - maxArgs: 2 - } - }, - cookies: { - get: { - minArgs: 1, - maxArgs: 1 - }, - getAll: { - minArgs: 1, - maxArgs: 1 - }, - getAllCookieStores: { - minArgs: 0, - maxArgs: 0 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - set: { - minArgs: 1, - maxArgs: 1 - } - }, - devtools: { - inspectedWindow: { - eval: { - minArgs: 1, - maxArgs: 2, - singleCallbackArg: false - } - }, - panels: { - create: { - minArgs: 3, - maxArgs: 3, - singleCallbackArg: true - } - } - }, - downloads: { - cancel: { - minArgs: 1, - maxArgs: 1 - }, - download: { - minArgs: 1, - maxArgs: 1 - }, - erase: { - minArgs: 1, - maxArgs: 1 - }, - getFileIcon: { - minArgs: 1, - maxArgs: 2 - }, - open: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - pause: { - minArgs: 1, - maxArgs: 1 - }, - removeFile: { - minArgs: 1, - maxArgs: 1 - }, - resume: { - minArgs: 1, - maxArgs: 1 - }, - search: { - minArgs: 1, - maxArgs: 1 - }, - show: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - } - }, - extension: { - isAllowedFileSchemeAccess: { - minArgs: 0, - maxArgs: 0 - }, - isAllowedIncognitoAccess: { - minArgs: 0, - maxArgs: 0 - } - }, - history: { - addUrl: { - minArgs: 1, - maxArgs: 1 - }, - deleteAll: { - minArgs: 0, - maxArgs: 0 - }, - deleteRange: { - minArgs: 1, - maxArgs: 1 - }, - deleteUrl: { - minArgs: 1, - maxArgs: 1 - }, - getVisits: { - minArgs: 1, - maxArgs: 1 - }, - search: { - minArgs: 1, - maxArgs: 1 - } - }, - i18n: { - detectLanguage: { - minArgs: 1, - maxArgs: 1 - }, - getAcceptLanguages: { - minArgs: 0, - maxArgs: 0 - } - }, - identity: { - launchWebAuthFlow: { - minArgs: 1, - maxArgs: 1 - } - }, - idle: { - queryState: { - minArgs: 1, - maxArgs: 1 - } - }, - management: { - get: { - minArgs: 1, - maxArgs: 1 - }, - getAll: { - minArgs: 0, - maxArgs: 0 - }, - getSelf: { - minArgs: 0, - maxArgs: 0 - }, - setEnabled: { - minArgs: 2, - maxArgs: 2 - }, - uninstallSelf: { - minArgs: 0, - maxArgs: 1 - } - }, - notifications: { - clear: { - minArgs: 1, - maxArgs: 1 - }, - create: { - minArgs: 1, - maxArgs: 2 - }, - getAll: { - minArgs: 0, - maxArgs: 0 - }, - getPermissionLevel: { - minArgs: 0, - maxArgs: 0 - }, - update: { - minArgs: 2, - maxArgs: 2 - } - }, - pageAction: { - getPopup: { - minArgs: 1, - maxArgs: 1 - }, - getTitle: { - minArgs: 1, - maxArgs: 1 - }, - hide: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - setIcon: { - minArgs: 1, - maxArgs: 1 - }, - setPopup: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - setTitle: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - }, - show: { - minArgs: 1, - maxArgs: 1, - fallbackToNoCallback: true - } - }, - permissions: { - contains: { - minArgs: 1, - maxArgs: 1 - }, - getAll: { - minArgs: 0, - maxArgs: 0 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - request: { - minArgs: 1, - maxArgs: 1 - } - }, - runtime: { - getBackgroundPage: { - minArgs: 0, - maxArgs: 0 - }, - getPlatformInfo: { - minArgs: 0, - maxArgs: 0 - }, - openOptionsPage: { - minArgs: 0, - maxArgs: 0 - }, - requestUpdateCheck: { - minArgs: 0, - maxArgs: 0 - }, - sendMessage: { - minArgs: 1, - maxArgs: 3 - }, - sendNativeMessage: { - minArgs: 2, - maxArgs: 2 - }, - setUninstallURL: { - minArgs: 1, - maxArgs: 1 - } - }, - sessions: { - getDevices: { - minArgs: 0, - maxArgs: 1 - }, - getRecentlyClosed: { - minArgs: 0, - maxArgs: 1 - }, - restore: { - minArgs: 0, - maxArgs: 1 - } - }, - storage: { - local: { - clear: { - minArgs: 0, - maxArgs: 0 - }, - get: { - minArgs: 0, - maxArgs: 1 - }, - getBytesInUse: { - minArgs: 0, - maxArgs: 1 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - set: { - minArgs: 1, - maxArgs: 1 - } - }, - managed: { - get: { - minArgs: 0, - maxArgs: 1 - }, - getBytesInUse: { - minArgs: 0, - maxArgs: 1 - } - }, - sync: { - clear: { - minArgs: 0, - maxArgs: 0 - }, - get: { - minArgs: 0, - maxArgs: 1 - }, - getBytesInUse: { - minArgs: 0, - maxArgs: 1 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - set: { - minArgs: 1, - maxArgs: 1 - } - } - }, - tabs: { - captureVisibleTab: { - minArgs: 0, - maxArgs: 2 - }, - create: { - minArgs: 1, - maxArgs: 1 - }, - detectLanguage: { - minArgs: 0, - maxArgs: 1 - }, - discard: { - minArgs: 0, - maxArgs: 1 - }, - duplicate: { - minArgs: 1, - maxArgs: 1 - }, - executeScript: { - minArgs: 1, - maxArgs: 2 - }, - get: { - minArgs: 1, - maxArgs: 1 - }, - getCurrent: { - minArgs: 0, - maxArgs: 0 - }, - getZoom: { - minArgs: 0, - maxArgs: 1 - }, - getZoomSettings: { - minArgs: 0, - maxArgs: 1 - }, - highlight: { - minArgs: 1, - maxArgs: 1 - }, - insertCSS: { - minArgs: 1, - maxArgs: 2 - }, - move: { - minArgs: 2, - maxArgs: 2 - }, - query: { - minArgs: 1, - maxArgs: 1 - }, - reload: { - minArgs: 0, - maxArgs: 2 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - removeCSS: { - minArgs: 1, - maxArgs: 2 - }, - sendMessage: { - minArgs: 2, - maxArgs: 3 - }, - setZoom: { - minArgs: 1, - maxArgs: 2 - }, - setZoomSettings: { - minArgs: 1, - maxArgs: 2 - }, - update: { - minArgs: 1, - maxArgs: 2 - } - }, - topSites: { - get: { - minArgs: 0, - maxArgs: 0 - } - }, - webNavigation: { - getAllFrames: { - minArgs: 1, - maxArgs: 1 - }, - getFrame: { - minArgs: 1, - maxArgs: 1 - } - }, - webRequest: { - handlerBehaviorChanged: { - minArgs: 0, - maxArgs: 0 - } - }, - windows: { - create: { - minArgs: 0, - maxArgs: 1 - }, - get: { - minArgs: 1, - maxArgs: 2 - }, - getAll: { - minArgs: 0, - maxArgs: 1 - }, - getCurrent: { - minArgs: 0, - maxArgs: 1 - }, - getLastFocused: { - minArgs: 0, - maxArgs: 1 - }, - remove: { - minArgs: 1, - maxArgs: 1 - }, - update: { - minArgs: 2, - maxArgs: 2 - } - } - }; - - if (Object.keys(apiMetadata).length === 0) { - throw new Error( - "api-metadata.json has not been included in browser-polyfill" - ); - } - - /** - * A WeakMap subclass which creates and stores a value for any key which does - * not exist when accessed, but behaves exactly as an ordinary WeakMap - * otherwise. - * - * @param {function} createItem - * A function which will be called in order to create the value for any - * key which does not exist, the first time it is accessed. The - * function receives, as its only argument, the key being created. - */ - class DefaultWeakMap extends WeakMap { - constructor(createItem, items = undefined) { - super(items); - this.createItem = createItem; - } - - get(key) { - if (!this.has(key)) { - this.set(key, this.createItem(key)); - } - - return super.get(key); - } - } - - /** - * Returns true if the given object is an object with a `then` method, and can - * therefore be assumed to behave as a Promise. - * - * @param {*} value The value to test. - * @returns {boolean} True if the value is thenable. - */ - const isThenable = value => - value && typeof value === "object" && typeof value.then === "function"; - /** - * Creates and returns a function which, when called, will resolve or reject - * the given promise based on how it is called: - * - * - If, when called, `chrome.runtime.lastError` contains a non-null object, - * the promise is rejected with that value. - * - If the function is called with exactly one argument, the promise is - * resolved to that value. - * - Otherwise, the promise is resolved to an array containing all of the - * function's arguments. - * - * @param {object} promise - * An object containing the resolution and rejection functions of a - * promise. - * @param {function} promise.resolve - * The promise's resolution function. - * @param {function} promise.rejection - * The promise's rejection function. - * @param {object} metadata - * Metadata about the wrapped method which has created the callback. - * @param {integer} metadata.maxResolvedArgs - * The maximum number of arguments which may be passed to the - * callback created by the wrapped async function. - * - * @returns {function} - * The generated callback function. - */ - const makeCallback = (promise, metadata) => (...callbackArgs) => { - if (extensionAPIs.runtime.lastError) { - promise.reject(extensionAPIs.runtime.lastError); - } else if ( - metadata.singleCallbackArg || - (callbackArgs.length <= 1 && metadata.singleCallbackArg !== false) - ) { - promise.resolve(callbackArgs[0]); - } else { - promise.resolve(callbackArgs); - } - }; - - const pluralizeArguments = numArgs => - numArgs == 1 ? "argument" : "arguments"; - - /** - * Creates a wrapper function for a method with the given name and metadata. - * - * @param {string} name - * The name of the method which is being wrapped. - * @param {object} metadata - * Metadata about the method being wrapped. - * @param {integer} metadata.minArgs - * The minimum number of arguments which must be passed to the - * function. If called with fewer than this number of arguments, the - * wrapper will raise an exception. - * @param {integer} metadata.maxArgs - * The maximum number of arguments which may be passed to the - * function. If called with more than this number of arguments, the - * wrapper will raise an exception. - * @param {integer} metadata.maxResolvedArgs - * The maximum number of arguments which may be passed to the - * callback created by the wrapped async function. - * - * @returns {function(object, ...*)} - * The generated wrapper function. - */ - const wrapAsyncFunction = (name, metadata) => - function asyncFunctionWrapper(target, ...args) { - if (args.length < metadata.minArgs) { - throw new Error( - `Expected at least ${metadata.minArgs} ${pluralizeArguments( - metadata.minArgs - )} for ${name}(), got ${args.length}` - ); - } - - if (args.length > metadata.maxArgs) { - throw new Error( - `Expected at most ${metadata.maxArgs} ${pluralizeArguments( - metadata.maxArgs - )} for ${name}(), got ${args.length}` - ); - } - - return new Promise((resolve, reject) => { - if (metadata.fallbackToNoCallback) { - /* This API method has currently no callback on Chrome, but it return a promise on Firefox, - and so the polyfill will try to call it with a callback first, and it will fallback - to not passing the callback if the first call fails. */ - try { - target[name]( - ...args, - makeCallback({ resolve, reject }, metadata) - ); - } catch (cbError) { - console.warn( - `${name} API method doesn't seem to support the callback parameter, ` + - "falling back to call it without a callback: ", - cbError - ); - - target[name](...args); - - /* Update the API method metadata, so that the next API calls will not try to - use the unsupported callback anymore. */ - metadata.fallbackToNoCallback = false; - metadata.noCallback = true; - - resolve(); - } - } else if (metadata.noCallback) { - target[name](...args); - resolve(); - } else { - target[name]( - ...args, - makeCallback({ resolve, reject }, metadata) - ); - } - }); - }; - - /** - * Wraps an existing method of the target object, so that calls to it are - * intercepted by the given wrapper function. The wrapper function receives, - * as its first argument, the original `target` object, followed by each of - * the arguments passed to the original method. - * - * @param {object} target - * The original target object that the wrapped method belongs to. - * @param {function} method - * The method being wrapped. This is used as the target of the Proxy - * object which is created to wrap the method. - * @param {function} wrapper - * The wrapper function which is called in place of a direct invocation - * of the wrapped method. - * - * @returns {Proxy} - * A Proxy object for the given method, which invokes the given wrapper - * method in its place. - */ - const wrapMethod = (target, method, wrapper) => - new Proxy(method, { - apply(targetMethod, thisObj, args) { - return wrapper.call(thisObj, target, ...args); - } - }); - - let hasOwnProperty = Function.call.bind(Object.prototype.hasOwnProperty); - - /** - * Wraps an object in a Proxy which intercepts and wraps certain methods - * based on the given `wrappers` and `metadata` objects. - * - * @param {object} target - * The target object to wrap. - * - * @param {object} [wrappers = {}] - * An object tree containing wrapper functions for special cases. Any - * function present in this object tree is called in place of the - * method in the same location in the `target` object tree. These - * wrapper methods are invoked as described in {@see wrapMethod}. - * - * @param {object} [metadata = {}] - * An object tree containing metadata used to automatically generate - * Promise-based wrapper functions for asynchronous. Any function in - * the `target` object tree which has a corresponding metadata object - * in the same location in the `metadata` tree is replaced with an - * automatically-generated wrapper function, as described in - * {@see wrapAsyncFunction} - * - * @returns {Proxy} - */ - const wrapObject = (target, wrappers = {}, metadata = {}) => { - let cache = Object.create(null); - let handlers = { - has(proxyTarget, prop) { - return prop in target || prop in cache; - }, - - get(proxyTarget, prop, receiver) { - if (prop in cache) { - return cache[prop]; - } - - if (!(prop in target)) { - return undefined; - } - - let value = target[prop]; - - if (typeof value === "function") { - /* This is a method on the underlying object. Check if we need to do - any wrapping. */ - - if (typeof wrappers[prop] === "function") { - // We have a special-case wrapper for this method. - value = wrapMethod(target, target[prop], wrappers[prop]); - } else if (hasOwnProperty(metadata, prop)) { - /* This is an async method that we have metadata for. Create a - Promise wrapper for it. */ - let wrapper = wrapAsyncFunction(prop, metadata[prop]); - value = wrapMethod(target, target[prop], wrapper); - } else { - /* This is a method that we don't know or care about. Return the - original method, bound to the underlying object. */ - value = value.bind(target); - } - } else if ( - typeof value === "object" && - value !== null && - (hasOwnProperty(wrappers, prop) || hasOwnProperty(metadata, prop)) - ) { - /* This is an object that we need to do some wrapping for the children - of. Create a sub-object wrapper for it with the appropriate child - metadata. */ - value = wrapObject(value, wrappers[prop], metadata[prop]); - } else { - /* We don't need to do any wrapping for this property, - so just forward all access to the underlying object. */ - Object.defineProperty(cache, prop, { - configurable: true, - enumerable: true, - get() { - return target[prop]; - }, - set(value) { - target[prop] = value; - } - }); - - return value; - } - - cache[prop] = value; - return value; - }, - - set(proxyTarget, prop, value, receiver) { - if (prop in cache) { - cache[prop] = value; - } else { - target[prop] = value; - } - return true; - }, - - defineProperty(proxyTarget, prop, desc) { - return Reflect.defineProperty(cache, prop, desc); - }, - - deleteProperty(proxyTarget, prop) { - return Reflect.deleteProperty(cache, prop); - } - }; - - /* Per contract of the Proxy API, the "get" proxy handler must return the - original value of the target if that value is declared read-only and - non-configurable. For this reason, we create an object with the - prototype set to `target` instead of using `target` directly. - Otherwise we cannot return a custom object for APIs that - are declared read-only and non-configurable, such as `chrome.devtools`. - The proxy handlers themselves will still use the original `target` - instead of the `proxyTarget`, so that the methods and properties are - dereferenced via the original targets. */ - let proxyTarget = Object.create(target); - return new Proxy(proxyTarget, handlers); - }; - - /** - * Creates a set of wrapper functions for an event object, which handles - * wrapping of listener functions that those messages are passed. - * - * A single wrapper is created for each listener function, and stored in a - * map. Subsequent calls to `addListener`, `hasListener`, or `removeListener` - * retrieve the original wrapper, so that attempts to remove a - * previously-added listener work as expected. - * - * @param {DefaultWeakMap} wrapperMap - * A DefaultWeakMap object which will create the appropriate wrapper - * for a given listener function when one does not exist, and retrieve - * an existing one when it does. - * - * @returns {object} - */ - const wrapEvent = wrapperMap => ({ - addListener(target, listener, ...args) { - target.addListener(wrapperMap.get(listener), ...args); - }, - - hasListener(target, listener) { - return target.hasListener(wrapperMap.get(listener)); - }, - - removeListener(target, listener) { - target.removeListener(wrapperMap.get(listener)); - } - }); - - // Keep track if the deprecation warning has been logged at least once. - let loggedSendResponseDeprecationWarning = false; - - const onMessageWrappers = new DefaultWeakMap(listener => { - if (typeof listener !== "function") { - return listener; - } - - /** - * Wraps a message listener function so that it may send responses based on - * its return value, rather than by returning a sentinel value and calling a - * callback. If the listener function returns a Promise, the response is - * sent when the promise either resolves or rejects. - * - * @param {*} message - * The message sent by the other end of the channel. - * @param {object} sender - * Details about the sender of the message. - * @param {function(*)} sendResponse - * A callback which, when called with an arbitrary argument, sends - * that value as a response. - * @returns {boolean} - * True if the wrapped listener returned a Promise, which will later - * yield a response. False otherwise. - */ - return function onMessage(message, sender, sendResponse) { - let didCallSendResponse = false; - - let wrappedSendResponse; - let sendResponsePromise = new Promise(resolve => { - wrappedSendResponse = function(response) { - if (!loggedSendResponseDeprecationWarning) { - console.warn( - SEND_RESPONSE_DEPRECATION_WARNING, - new Error().stack - ); - loggedSendResponseDeprecationWarning = true; - } - didCallSendResponse = true; - resolve(response); - }; - }); - - let result; - try { - result = listener(message, sender, wrappedSendResponse); - } catch (err) { - result = Promise.reject(err); - } - - const isResultThenable = result !== true && isThenable(result); - - /* If the listener didn't returned true or a Promise, or called - wrappedSendResponse synchronously, we can exit earlier - because there will be no response sent from this listener. */ - if (result !== true && !isResultThenable && !didCallSendResponse) { - return false; - } - - /* A small helper to send the message if the promise resolves - and an error if the promise rejects (a wrapped sendMessage has - to translate the message into a resolved promise or a rejected - promise). */ - const sendPromisedResult = promise => { - promise - .then( - msg => { - // send the message value. - sendResponse(msg); - }, - error => { - /* Send a JSON representation of the error if the rejected value - is an instance of error, or the object itself otherwise. */ - let message; - if ( - error && - (error instanceof Error || - typeof error.message === "string") - ) { - message = error.message; - } else { - message = "An unexpected error occurred"; - } - - sendResponse({ - __mozWebExtensionPolyfillReject__: true, - message - }); - } - ) - .catch(err => { - // Print an error on the console if unable to send the response. - console.error("Failed to send onMessage rejected reply", err); - }); - }; - - /* If the listener returned a Promise, send the resolved value as a - result, otherwise wait the promise related to the wrappedSendResponse - callback to resolve and send it as a response. */ - if (isResultThenable) { - sendPromisedResult(result); - } else { - sendPromisedResult(sendResponsePromise); - } - - // Let Chrome know that the listener is replying. - return true; - }; - }); - - const wrappedSendMessageCallback = ({ reject, resolve }, reply) => { - if (extensionAPIs.runtime.lastError) { - /* Detect when none of the listeners replied to the sendMessage call and resolve - the promise to undefined as in Firefox. - See https://github.com/mozilla/webextension-polyfill/issues/130 */ - if ( - extensionAPIs.runtime.lastError.message === - CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE - ) { - resolve(); - } else { - reject(extensionAPIs.runtime.lastError); - } - } else if (reply && reply.__mozWebExtensionPolyfillReject__) { - /* Convert back the JSON representation of the error into - an Error instance. */ - reject(new Error(reply.message)); - } else { - resolve(reply); - } - }; - - const wrappedSendMessage = (name, metadata, apiNamespaceObj, ...args) => { - if (args.length < metadata.minArgs) { - throw new Error( - `Expected at least ${metadata.minArgs} ${pluralizeArguments( - metadata.minArgs - )} for ${name}(), got ${args.length}` - ); - } - - if (args.length > metadata.maxArgs) { - throw new Error( - `Expected at most ${metadata.maxArgs} ${pluralizeArguments( - metadata.maxArgs - )} for ${name}(), got ${args.length}` - ); - } - - return new Promise((resolve, reject) => { - const wrappedCb = wrappedSendMessageCallback.bind(null, { - resolve, - reject - }); - args.push(wrappedCb); - apiNamespaceObj.sendMessage(...args); - }); - }; - - const staticWrappers = { - runtime: { - onMessage: wrapEvent(onMessageWrappers), - onMessageExternal: wrapEvent(onMessageWrappers), - sendMessage: wrappedSendMessage.bind(null, "sendMessage", { - minArgs: 1, - maxArgs: 3 - }) - }, - tabs: { - sendMessage: wrappedSendMessage.bind(null, "sendMessage", { - minArgs: 2, - maxArgs: 3 - }) - } - }; - const settingMetadata = { - clear: { minArgs: 1, maxArgs: 1 }, - get: { minArgs: 1, maxArgs: 1 }, - set: { minArgs: 1, maxArgs: 1 } - }; - apiMetadata.privacy = { - network: { - networkPredictionEnabled: settingMetadata, - webRTCIPHandlingPolicy: settingMetadata - }, - services: { - passwordSavingEnabled: settingMetadata - }, - websites: { - hyperlinkAuditingEnabled: settingMetadata, - referrersEnabled: settingMetadata - } - }; - - return wrapObject(extensionAPIs, staticWrappers, apiMetadata); - }; - - if ( - typeof chrome != "object" || - !chrome || - !chrome.runtime || - !chrome.runtime.id - ) { - throw new Error( - "This script should only be loaded in a browser extension." - ); - } - - /* The build process adds a UMD wrapper around this file, which makes the - `module` variable available. */ - module.exports = wrapAPIs(chrome); - } else { - module.exports = browser; - } -}); -//# sourceMappingURL=browser-polyfill.js.map diff --git a/context.js b/context.js index 2b32f15..ad4a8b0 100644 --- a/context.js +++ b/context.js @@ -15,7 +15,7 @@ function onError(error) { function eventHandler(event) { if (event.target.dataset.action == "create") { - var creating = browser.windows.create({ + var creating = browser.tabs.create({ cookieStoreId: event.target.dataset.identity }); creating.then(onCreated, onError); diff --git a/debian/changelog b/debian/changelog index 5bf9229..11b6f36 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,22 @@ +i2psetproxy.js (0.47-1) UNRELEASED; urgency=low + + * Improve android compatibility + * Improve code organization + * Partial protocol handlers implementation + + -- idk Sat, 23 NOV 2019 18:53:11 -0400 + +i2psetproxy.js (0.45-1) UNRELEASED; urgency=low + + * Improve the user interface a whole bunch + + -- idk Fri, 22 NOV 2019 18:17:33 -0400 + i2psetproxy.js (0.43-1) UNRELEASED; urgency=low * Contextualize All the Things - -- idk Thu, 31 OCT 2019 12:41:33 -0400 + -- idk Mon, 11 OCT 2019 12:41:33 -0400 i2psetproxy.js (0.41-1) UNRELEASED; urgency=low diff --git a/handler.js b/handler.js new file mode 100644 index 0000000..7ea7943 --- /dev/null +++ b/handler.js @@ -0,0 +1,30 @@ +function identifyProtocolHandler(url) { + //console.log("looking for handler-able requests") + if (routerHost(url)) { + if (url.includes(encodeURIComponent("ext+rc:"))) { + return url.replace(encodeURIComponent("ext+rc:"), ""); + } else if (url.includes("ext+rc:")) { + return url.replace("ext+rc:", ""); + } + } else if (url.includes("ext+rc:")) { + return url; + } + return false; +} + +var handlerSetup = async function(requestDetails) { + //console.log("checking protocol handler listener") + var rwurl = identifyProtocolHandler(requestDetails.url); + if (rwurl != false) { + console.log("handler rewrite URL requested", rwurl); + requestDetails.redirectUrl = rwurl; + requestDetails.url = rwurl; + } + return requestDetails; +}; + +browser.webRequest.onBeforeRequest.addListener( + handlerSetup, + { urls: [""] }, + ["blocking"] +); diff --git a/home.css b/home.css index e9bdfe1..f2bdefe 100644 --- a/home.css +++ b/home.css @@ -282,4 +282,9 @@ li { img.readyness { height: 100%; width: auto +} +@media only screen and (max-width: 768px) { + .application-info { + display: none + } } \ No newline at end of file diff --git a/home.html b/home.html index e396117..5eb40f1 100644 --- a/home.html +++ b/home.html @@ -12,12 +12,12 @@
-

The Invisible Internet Browser

+

I2P In Private Browsing

-

The Invisible Internet Browser ( I2P Browser ) is preconfigured to get your content using the anonymous and private I2P network and to provide accessible, first-class access to I2P Peer-to-Peer applications.

-

This is a experimental sub-project of I2P. It is currently Beta software.

+

I2P in Private Browsing is a webextension to secure and enhance your I2P use in the browser.

+

This is an experimental product.

diff --git a/host.js b/host.js new file mode 100644 index 0000000..b2f7318 --- /dev/null +++ b/host.js @@ -0,0 +1,102 @@ +function proxyHost(url) { + let hostname = ""; + if (url.indexOf("://") > -1) { + hostname = url.split("/")[2]; + } else { + hostname = url.split("/")[0]; + } + if (hostname == "proxy.i2p") { + return true; + } + return false; +} + +function localHost(url) { + let hostname = ""; + if (url.indexOf("://") > -1) { + hostname = url.split("/")[2]; + } else { + hostname = url.split("/")[0]; + } + hostname = hostname.split(":")[0]; + if (hostname === "127.0.0.1") { + return true; + } else if (hostname === "localhost") { + return true; + } + + return false; +} + +function i2pHostName(url) { + let hostname = ""; + if (url.indexOf("://") > -1) { + hostname = url.split("/")[2]; + } else { + hostname = url.split("/")[0]; + } + return hostname; +} + +function i2pHost(url) { + let hostname = i2pHostName(url); + return hostname.endsWith(".i2p"); +} + +function routerHost(url) { + let hostname = ""; + let path = ""; + function pathcheck(str) { + if (str != undefined) { + let final = str.split("/")[0]; + if (final === "i2ptunnelmgr" || final === "i2ptunnel") { + console.log("(urlcheck) application path", final); + return "i2ptunnelmgr"; + } else if (final === "i2psnark" || final === "torrents") { + console.log("(urlcheck) application path", final); + return "i2psnark"; + } else if (final === "webmail" || final === "susimail") { + console.log("(urlcheck) application path", final); + return "webmail"; + } else if ( + final === "home" || + final === "console" || + final.startsWith("config") + ) { + console.log("(urlcheck) application path", final); + return "routerconsole"; + } + } + return true; + } + if (url.indexOf("://") > -1) { + hostname = url.split("/")[2]; + prefix = url.substr(0, url.indexOf("://") + 3); + path = url.replace(prefix + hostname + "/", ""); + } else if (identifyProtocolHandler(url)) { + url = identifyProtocolHandler(url); + return routerHost(url); + } else { + hostname = url.split("/")[0]; + path = url.replace(hostname + "/", ""); + } + if (hostname === "127.0.0.1:7657") { + return pathcheck(path); + } else if (hostname === "localhost:7657") { + return pathcheck(path); + } + + if (hostname === "127.0.0.1:7647") { + return pathcheck(path); + } else if (hostname === "localhost:7647") { + return pathcheck(path); + } + + if (hostname === "127.0.0.1:7070") { + return pathcheck(path); + } else if (hostname === "localhost:7070") { + return pathcheck(path); + } + + return false; +} diff --git a/info.css b/info.css index 313864e..c079180 100644 --- a/info.css +++ b/info.css @@ -51,4 +51,4 @@ img.readyness { } #consoleOn { min-height: 2rem -} +} \ No newline at end of file diff --git a/info.js b/info.js index c3c2f5f..6f54122 100644 --- a/info.js +++ b/info.js @@ -8,7 +8,7 @@ document.addEventListener("click", e => { type: "panel", incognito: true }; - let creating = browser.windows.create(createData); + let creating = browser.tabs.create(createData); creating.then(() => { console.log("The help panel has been created"); }); @@ -17,7 +17,7 @@ document.addEventListener("click", e => { type: "panel", incognito: true }; - let creating = browser.windows.create(createData); + let creating = browser.tabs.create(createData); creating.then(() => { console.log("The news panel has been created"); }); @@ -73,11 +73,27 @@ function proxyReadiness() { } function goHome() { - let createData = { - url: "home.html" - }; - console.log("visiting homepage"); - let creating = browser.tabs.create(createData); + function gotProxyInfo(info) { + let host = info.value.http.split(":")[0]; + let port = info.value.http.split(":")[1]; + if (port == "7644") { + let createData = { + url: "about:I2p" + }; + console.log("visiting homepage"); + let creating = browser.tabs.create(createData); + } else { + let createData = { + url: "home.html" + }; + console.log("visiting homepage"); + let creating = browser.tabs.create(createData); + } + console.log("(bookmarks) adding home page bookmark"); + } + console.log("(bookmarks) checking if we're running in an I2P Browser"); + var gettingInfo = browser.proxy.settings.get({}); + gettingInfo.then(gotProxyInfo); } function goTunnel() { diff --git a/manifest.json b/manifest.json index 719e3cd..1ab370d 100644 --- a/manifest.json +++ b/manifest.json @@ -24,7 +24,7 @@ ], "manifest_version": 2, "name": "__MSG_extensionName__", - "version": "0.43", + "version": "0.47", "description": "__MSG_extensionDescription__", "homepage_url": "https://github.com/eyedeekay/i2psetproxy.js", "icons": { @@ -44,6 +44,8 @@ "privacy.js", "platform.js", "background.js", + "host.js", + "handler.js", "proxy.js", "info.js", "home.js", @@ -53,9 +55,14 @@ ] }, "protocol_handlers": [{ - "protocol": "web+rc", + "protocol": "ext+rc", "name": "RouterConsole", - "uriTemplate": "http://router.console/?%s" + "uriTemplate": "http://127.0.0.1:7657/%s" + }, + { + "protocol": "magnet", + "name": "I2PTorrent", + "uriTemplate": "http://127.0.0.1:7657/i2psnark/?nofilter_newURL=%s&action=Add&foo=Add+torrent" }], "default_locale": "en" } diff --git a/scrub.js b/scrub.js index 39de3d7..d3bdc6a 100644 --- a/scrub.js +++ b/scrub.js @@ -393,7 +393,7 @@ var contextSetup = async function(requestDetails) { } } else { var tab = tabGet(requestDetails.tabId); - var mtab = tab.then(anyTabFind); + var mtab = tab.then(routerTabFind); return requestDetails; } } @@ -405,102 +405,6 @@ var contextSetup = async function(requestDetails) { } }; -function i2pHostName(url) { - let hostname = ""; - if (url.indexOf("://") > -1) { - hostname = url.split("/")[2]; - } else { - hostname = url.split("/")[0]; - } - return hostname; -} - -function i2pHost(url) { - let hostname = i2pHostName(url); - return hostname.endsWith(".i2p"); -} - -function proxyHost(url) { - let hostname = ""; - if (url.indexOf("://") > -1) { - hostname = url.split("/")[2]; - } else { - hostname = url.split("/")[0]; - } - if (hostname == "proxy.i2p") { - return true; - } - return false; -} - -function localHost(url) { - let hostname = ""; - if (url.indexOf("://") > -1) { - hostname = url.split("/")[2]; - } else { - hostname = url.split("/")[0]; - } - hostname = hostname.split(":")[0]; - if (hostname === "127.0.0.1") { - return true; - } else if (hostname === "localhost") { - return true; - } - - return false; -} - -function routerHost(url) { - let hostname = ""; - let path = ""; - function pathcheck(str) { - if (str != undefined) { - let final = str.split("/")[0]; - if (final === "i2ptunnelmgr" || final === "i2ptunnel") { - console.log("(urlcheck) application path", final); - return "i2ptunnelmgr"; - } else if (final === "i2psnark" || final === "torrents") { - console.log("(urlcheck) application path", final); - return "i2psnark"; - } else if (final === "webmail" || final === "susimail") { - console.log("(urlcheck) application path", final); - return "webmail"; - } else if (final == "") { - console.log("(urlcheck) application path", final); - return "routerconsole"; - } - } - return true; - } - if (url.indexOf("://") > -1) { - hostname = url.split("/")[2]; - prefix = url.substr(0, url.indexOf("://") + 3); - path = url.replace(prefix + hostname + "/", ""); - } else { - hostname = url.split("/")[0]; - path = url.replace(hostname + "/", ""); - } - if (hostname === "127.0.0.1:7657") { - return pathcheck(path); - } else if (hostname === "localhost:7657") { - return pathcheck(path); - } - - if (hostname === "127.0.0.1:7647") { - return pathcheck(path); - } else if (hostname === "localhost:7647") { - return pathcheck(path); - } - - if (hostname === "127.0.0.1:7070") { - return pathcheck(path); - } else if (hostname === "localhost:7070") { - return pathcheck(path); - } - - return false; -} - browser.webRequest.onBeforeRequest.addListener( contextSetup, { urls: [""] },