Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f233972323 | ||
![]() |
f27a59c193 | ||
![]() |
b9200a4313 | ||
![]() |
b7ebbd5b79 | ||
![]() |
e631c82363 | ||
![]() |
43e6818324 | ||
![]() |
fc019c58bb | ||
![]() |
2e8a61de2e | ||
![]() |
d770abcce8 | ||
![]() |
ecda2d7102 | ||
![]() |
f670bef983 | ||
![]() |
aa71f917a6 | ||
![]() |
33cfbc324a | ||
![]() |
38d5dcb929 | ||
![]() |
994b021a95 | ||
![]() |
c2f321b26b | ||
![]() |
04d58b33be | ||
![]() |
a7562fd66e | ||
![]() |
595f02c01b | ||
![]() |
3d4a49827f | ||
![]() |
fa579b8586 | ||
![]() |
58b91e1a80 | ||
![]() |
997689806b | ||
![]() |
df4d9e93a6 | ||
![]() |
6cd37b51c0 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
||||
README.md.asc
|
||||
|
||||
node_modules/
|
||||
|
52
Makefile
52
Makefile
@@ -4,12 +4,14 @@ default: zip
|
||||
|
||||
install: uninstall
|
||||
mkdir -p $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io \
|
||||
$(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol \
|
||||
$(PREFIX)/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
||||
cp -r ./chromium/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp -r ./icons/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp -r ./_locales/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp -r ./options/ $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./*.js $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./i2pcontrol/i2pcontrol.js $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol/i2pcontrol.js
|
||||
cp ./*.html $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./*.css $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./*.md $(PREFIX)/share/webext/i2ppb@eyedeekay.github.io/
|
||||
@@ -29,19 +31,42 @@ ls:
|
||||
ls -lah $(PREFIX)/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
||||
|
||||
clean:
|
||||
rm -f ../i2psetproxy.js.zip ../i2p_proxy*.xpi
|
||||
rm -fr ../i2psetproxy.js.zip ../i2p_proxy*.xpi ../i2p*.xpi #../i2psetproxy.js_*.*
|
||||
|
||||
## EVEN RELEASES are AMO RELEASES
|
||||
## ODD RELEASES are SELFHOSTED RELEASES
|
||||
|
||||
MOZ_VERSION=0.36
|
||||
VERSION=0.36
|
||||
MOZ_VERSION=0.40
|
||||
VERSION=0.41
|
||||
#VERSION=$(MOZ_VERSION)
|
||||
#VERSION=1.27
|
||||
|
||||
YELLOW=F7E59A
|
||||
ORANGE=FFC56D
|
||||
GREY=D9D9D6
|
||||
BLUE=A4C8E1
|
||||
PURPLE=A48fE1
|
||||
|
||||
colors:
|
||||
@echo " yellow $(YELLOW) \n orange $(ORANGE) \n grey $(GREY) \n blue $(BLUE) \n purple $(PURPLE)"
|
||||
|
||||
amo-readme:
|
||||
markdown README.md | \
|
||||
sed 's|<p>||g' | \
|
||||
sed 's|</p>||g' | \
|
||||
sed 's|<h1>|<strong>|g' | \
|
||||
sed 's|</h1>|</strong>|g' | \
|
||||
sed 's|<h2>|<strong>|g' | \
|
||||
sed 's|</h2>|</strong>|g' | \
|
||||
sed 's|<h3>|<strong>|g' | \
|
||||
sed 's|</h3>|</strong>|g' | \
|
||||
grep -v '<img' > index.html
|
||||
|
||||
xpi:
|
||||
wget -O ../i2ppb@eyedeekay.github.io.xpi \
|
||||
https://addons.mozilla.org/firefox/downloads/file/3419789/i2psetproxyjs-$(MOZ_VERSION)-an+fx.xpi
|
||||
cp ../i2ppb@eyedeekay.github.io.xpi ./i2ppb@eyedeekay.github.io.xpi
|
||||
#wget -O ../i2ppb@eyedeekay.github.io.xpi \
|
||||
#https://addons.mozilla.org/firefox/downloads/file/3419789/i2psetproxyjs-$(MOZ_VERSION)-an+fx.xpi
|
||||
#cp ../i2ppb@eyedeekay.github.io.xpi ./i2ppb@eyedeekay.github.io.xpi
|
||||
cp ~/Downloads/i2p_in_private_browsing-$(VERSION)-an+fx.xpi ./i2ppb@eyedeekay.github.io.xpi
|
||||
|
||||
version:
|
||||
sed -i 's|$(shell grep "\"version\": " manifest.json)| \"version\": \"$(VERSION)\",|g' manifest.json
|
||||
@@ -77,10 +102,19 @@ libpolyfill:
|
||||
fmt:
|
||||
find . -path ./node_modules -prune -o -name '*.js' -exec prettier --write {} \;
|
||||
|
||||
lint:
|
||||
eslint --fix *.js
|
||||
|
||||
deborig:
|
||||
rm -rfv ../i2psetproxy.js-$(VERSION)
|
||||
cp -rv . ../i2psetproxy.js-$(VERSION)
|
||||
tar --exclude='./.git' --exclude="./node_modules" -cvzf ../i2psetproxy.js_$(VERSION).orig.tar.gz .
|
||||
rm -rf ../i2psetproxy.js-$(VERSION)
|
||||
cp -r . ../i2psetproxy.js-$(VERSION)
|
||||
tar \
|
||||
-cvz \
|
||||
--exclude=.git \
|
||||
--exclude=i2psetproxy.js.gif \
|
||||
--exclude=node_modules \
|
||||
-f ../i2psetproxy.js_$(VERSION).orig.tar.gz \
|
||||
.
|
||||
|
||||
deb: deborig
|
||||
cd ../i2psetproxy.js-$(VERSION) && debuild -us -uc -rfakeroot
|
||||
|
70
PLAN.md
Normal file
70
PLAN.md
Normal file
@@ -0,0 +1,70 @@
|
||||
The I2P Browser has made strides at improving users anonymity when browsing
|
||||
the anonymous web inside of I2P. However, it has in many ways simply re-hashed
|
||||
the existing work of Tor on the Tor Browser. This is mostly a good thing, but it
|
||||
is unfortunate because in a sense we have failed to add I2P specific features
|
||||
that could improve the user experience and set us apart from the Tor Browser.
|
||||
|
||||
I think that moving forward, we should try to extend the functionality of I2P
|
||||
Browser into more I2P-specific realms and make an effort to make those things
|
||||
more accessible and highlight that they are in use. I don't really know how to
|
||||
explain what I mean without describing what I want to do, so
|
||||
|
||||
Let's avoid *adding* features to i2pbutton
|
||||
------------------------------------------
|
||||
|
||||
i2pbutton contains alot of code from Tor which even they don't really want to
|
||||
maintain. It's dying the same long, slow death it's always been dying, since
|
||||
back before there was a Tor Browser and torbutton was just an easy way to
|
||||
configure Tor in your Firefox browser. I don't relish the thought of being one
|
||||
the last two groups on the planet maintaining an XUL extension, so I think that
|
||||
we should always be trying to do less with i2pbutton and more with a modern
|
||||
extension. Other advantages of modern extensions are better debugging tools
|
||||
and easier-to-use, more understandable API's for doing the following other
|
||||
things.
|
||||
|
||||
Contexts for Security and Placing Router Applications under their own Origin
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
It is possible, however unlikely, for an attack on a local service or a router
|
||||
plugin to leak information about what's going on on the router console because
|
||||
they will share the same origin. We can resolve this issue, though, by placing
|
||||
applications each into their own origin under a so-called "Container Tab,"
|
||||
completely separating eepWeb traffic and Router Console administration. The
|
||||
origin of the application will be the same as the part of the application URL
|
||||
*after* localhost:7657, so for instance "http://localhost:7657/torrents"
|
||||
would become just "torrents" in the URL bar and have that origin.
|
||||
|
||||
Dynamic Themes
|
||||
--------------
|
||||
|
||||
Since I2P Browsing and Router Console Administration are going to be separated
|
||||
to their own contextual identities, we can manipulate the appearance of the
|
||||
Firefox browser to accomplish 2 things: We can indicate which context we are in
|
||||
both by manipulating the UI text and color, and manipulate UI elements based on
|
||||
what context we're in or even what URL(In the router console) we're on. We can
|
||||
use this to make router console applications appear more tightly integrated with
|
||||
the functionality of the browser. It's kind of obliquely like how many
|
||||
applications are written with user-interfaces that are actually just
|
||||
browsers(Including Mattermost), but with us using the whole browser,
|
||||
acknowledging it's presence and utility but quite literally highlighting(in
|
||||
color) our unique features. So for instance, when the user is using snark it
|
||||
could change color to match snark and change text to say "Torrent Client."
|
||||
|
||||
Application Integration - Torrents
|
||||
----------------------------------
|
||||
|
||||
I2P's strengths are in it's applications, but many users never even make it to
|
||||
the applications, and even if they do, the I2P applications often lack the
|
||||
familiar workflows that people are used to. For instance, when one downloads
|
||||
a torrent on the non-anonymous internet, you simply click a link and the browser
|
||||
"Handles" the link, automatically launching the torrent client, adding the
|
||||
torrent, and sometimes prompting the user for more actions. This isn't possible
|
||||
yet with i2psnark and an external browser, but in I2P browser we can write a
|
||||
"Protocol Handler" which talks to snark-rpc, replicating the ease of just
|
||||
clicking a torrent link to automatically add it to a torrent client. Of course
|
||||
that does require us to bundle the snark-rpc plugin. Besides that, once we've
|
||||
added the torrent, we can keep talking to snark-rpc to keep track of the
|
||||
download progress and display information about that in the already-available
|
||||
Firefox downloads menu that users are already familiar with, so that they can
|
||||
keep track of the files they are downloading after navigating away from the
|
||||
snark interface, or perhaps even without needing to interact with snark at all.
|
38
README.md
38
README.md
@@ -15,10 +15,15 @@ New versions of this extension create an I2P in Private Browsing mode instead.
|
||||
Since this is a drastic change to the behavior of the old plugin, a new entry
|
||||
for the new plugin has been made at a new location on addons.mozilla.org.
|
||||
|
||||
* This is the new version: [[link]](https://addons.mozilla.org/en-US/firefox/addon/i2p-in-private-browsing/)
|
||||
|
||||
* This is the old version: [[link]](https://addons.mozilla.org/en-US/firefox/addon/I2P-Proxy/)
|
||||
|
||||
Android usage:
|
||||
--------------
|
||||
|
||||
Open the following link [Github Releases Version](https://github.com/eyedeekay/i2psetproxy.js/releases/download/1.26/i2psetproxy.js@eyedeekay.github.io.xpi)
|
||||
Open the following link
|
||||
[Github Releases Version](https://github.com/eyedeekay/i2psetproxy.js/releases/)
|
||||
in the browser you want to use for I2P. Firefox will warn you that it is about
|
||||
to install an extension and indicate the permissions required. Read them over
|
||||
and when you're ready, accept them. That's all it should take, your browser is
|
||||
@@ -27,13 +32,23 @@ now configured to use I2P.
|
||||
### addons.mozilla.org
|
||||
|
||||
If you would prefer to recieve automatic updates from AMO, the correct product
|
||||
page for this plugin is [I2P-proxy](https://addons.mozilla.org/en-US/firefox/addon/I2P-proxy/).
|
||||
page for this plugin is
|
||||
[I2P In Private Browsing](https://addons.mozilla.org/en-US/firefox/addon/i2p-in-private-browsing/).
|
||||
This absolutely requires a working outproxy. If you want to avoid the use of AMO
|
||||
for updates, you can download the identical plugin from this repository's
|
||||
releases page. The latest AMO Plugin will always be identical to the latest
|
||||
github release, except for the version number, which must be incremented for
|
||||
submission to AMO.
|
||||
|
||||
Debian usage:
|
||||
-------------
|
||||
|
||||
Should you prefer, it is possible to install this extension system-wide by
|
||||
side-loading it into Debian. You can generate your own deb file by running the
|
||||
command:
|
||||
|
||||
make deb
|
||||
|
||||
### Features
|
||||
|
||||
* [done] **Provide** a way to launch into an I2P-Specific contextual identity
|
||||
@@ -48,12 +63,19 @@ submission to AMO.
|
||||
isolating HTTP)
|
||||
* [done/wip] **Disable** risky webRTC features/offer the option to re-enable
|
||||
them with the proxy enforced.
|
||||
* [done] **Change** the color of the browser window to indicate that I2P is in use
|
||||
* [done-ish] **Reset** the HTTP Proxy tunnel to generate a new destination on-demand
|
||||
* it does this by working in conjunction with this [standalone HTTP proxy](https://github.com/eyedeekay/httptunnel), currently disabled*.
|
||||
* [done] **Change** the color of the browser window to indicate that I2P is in
|
||||
use
|
||||
* [done-ish] **Reset** the HTTP Proxy tunnel to generate a new destination
|
||||
on-demand
|
||||
* it does this by working in conjunction with this
|
||||
[standalone HTTP proxy](https://github.com/eyedeekay/httptunnel), currently
|
||||
disabled*.
|
||||
* [ready] **Provide** help in a variety of languages.
|
||||
* [wip] **Monitor** the health and readiness of the I2P router it is
|
||||
instructed to use.
|
||||
instructed to use. Currently the plugin checks whether the HTTP Proxy is
|
||||
working by fetching an image from "http://proxy.i2p" and displaying a result.
|
||||
A work-in-progress binding to i2pcontrol is available in ./i2pcontrol, it is
|
||||
inert at this time.
|
||||
* [1/2] **Handle** router console applications under their own origins and
|
||||
within their own contextual identity. (1) The router console is automatically
|
||||
confined to it's own container tab. (2) Use a custom protocol handler to
|
||||
@@ -67,6 +89,10 @@ submission to AMO.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
Super Extra Important Background Info:
|
||||
|
257
background.js
257
background.js
@@ -5,38 +5,64 @@ function onGot(contexts) {
|
||||
ids.push(context.name);
|
||||
}
|
||||
console.log("Checking new contexts");
|
||||
if (ids.indexOf("i2pbrowser") == -1) {
|
||||
function onCreated(context) {
|
||||
console.log(`New identity's ID: ${context.cookieStoreId}.`);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (ids.indexOf("I2P Browsing") == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "i2pbrowser",
|
||||
color: "purple",
|
||||
name: "I2P Browsing",
|
||||
color: "orange",
|
||||
icon: "fingerprint"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
if (ids.indexOf("routerconsole") == -1) {
|
||||
function onCreated(context) {
|
||||
console.log(`New identity's ID: ${context.cookieStoreId}.`);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (ids.indexOf("Web Browsing") == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "routerconsole",
|
||||
color: "turquoise",
|
||||
name: "Web Browsing",
|
||||
color: "red",
|
||||
icon: "circle"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
if (ids.indexOf("Router Console") == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "Router Console",
|
||||
color: "blue",
|
||||
icon: "briefcase"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
if (ids.indexOf("Hidden Services Manager") == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "Hidden Services Manager",
|
||||
color: "green",
|
||||
icon: "tree"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
if (ids.indexOf("Web Mail") == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "Web Mail",
|
||||
color: "yellow",
|
||||
icon: "briefcase"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
if (ids.indexOf("Bittorrent") == -1) {
|
||||
browser.contextualIdentities
|
||||
.create({
|
||||
name: "Bittorrent",
|
||||
color: "purple",
|
||||
icon: "chill"
|
||||
})
|
||||
.then(onCreated, onError);
|
||||
}
|
||||
}
|
||||
|
||||
function onCreated(context) {
|
||||
console.log(`New identity's ID: ${context.cookieStoreId}.`);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
@@ -47,6 +73,8 @@ browser.contextualIdentities.query({}).then(onGot, onError);
|
||||
|
||||
if (!isDroid()) {
|
||||
chrome.windows.onCreated.addListener(themeWindow);
|
||||
chrome.windows.onFocusChanged.addListener(themeWindow);
|
||||
chrome.windows.onRemoved.addListener(themeWindow);
|
||||
chrome.tabs.onUpdated.addListener(themeWindowByTab);
|
||||
chrome.tabs.onActivated.addListener(themeWindowByTab);
|
||||
}
|
||||
@@ -54,60 +82,117 @@ if (!isDroid()) {
|
||||
var titlepref = chrome.i18n.getMessage("titlePreface");
|
||||
var titleprefpriv = chrome.i18n.getMessage("titlePrefacePrivate");
|
||||
|
||||
function themeWindowByTab(tab) {
|
||||
getwindow = browser.windows.get(tab.windowId);
|
||||
getwindow.then(themeWindow);
|
||||
function themeWindowByTab(tabId) {
|
||||
function tabWindow(tab) {
|
||||
getwindow = browser.windows.get(tab.windowId);
|
||||
getwindow.then(themeWindow);
|
||||
}
|
||||
if (typeof tabId === "number") {
|
||||
tab = browser.tabs.get(tabId);
|
||||
tab.then(tabWindow);
|
||||
} else {
|
||||
tabWindow(tabId);
|
||||
}
|
||||
}
|
||||
|
||||
function themeWindow(window) {
|
||||
// Check if the window is in private browsing
|
||||
function logTabs(tabInfo) {
|
||||
console.log(tabInfo);
|
||||
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
if (context.name == "I2P Browsing") {
|
||||
console.log("Active in I2P window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#2D4470",
|
||||
toolbar: "#2D4470"
|
||||
frame: "#FFC56D",
|
||||
toolbar: "#FFC56D"
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#9DABD5",
|
||||
toolbar: "#9DABD5"
|
||||
frame: "#FFC56D",
|
||||
toolbar: "#FFC56D"
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (context.name == "routerconsole") {
|
||||
console.log("Active in I2P window");
|
||||
} else if (context.name == "Router Console") {
|
||||
console.log("Active in Router Console window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#00CED1",
|
||||
toolbar: "#00CED1"
|
||||
frame: "#A4C8E1",
|
||||
toolbar: "#A4C8E1"
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#40E0D0",
|
||||
toolbar: "#40E0D0"
|
||||
frame: "#A4C8E1",
|
||||
toolbar: "#A4C8E1"
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Hidden Services Manager") {
|
||||
console.log("Active in Hidden Services Manager window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#D9D9D6",
|
||||
toolbar: "#D9D9D6"
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#D9D9D6",
|
||||
toolbar: "#D9D9D6"
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Web Mail") {
|
||||
console.log("Active in Web Mail window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#F7E59A",
|
||||
toolbar: "#F7E59A"
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#F7E59A",
|
||||
toolbar: "#F7E59A"
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Bittorrent") {
|
||||
console.log("Active in Bittorrent window");
|
||||
if (window.incognito) {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#A48FE1",
|
||||
toolbar: "#A48FE1"
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chrome.theme.update(window.id, {
|
||||
colors: {
|
||||
frame: "#A48FE1",
|
||||
toolbar: "#A48FE1"
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log("Not active in I2P window");
|
||||
chrome.theme.reset(window.id);
|
||||
}
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default") {
|
||||
if (
|
||||
tabInfo[0].cookieStoreId != "firefox-default" &&
|
||||
tabInfo[0].cookieStoreId != "firefox-private"
|
||||
) {
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onGot, onError);
|
||||
@@ -116,9 +201,6 @@ function themeWindow(window) {
|
||||
}
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
@@ -131,10 +213,69 @@ function setTitle(window) {
|
||||
console.log(tabInfo);
|
||||
|
||||
function onGot(context) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
if (context.name == "I2P Browsing") {
|
||||
console.log("Active in I2P window");
|
||||
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Web Browsing") {
|
||||
console.log("Active in Web window");
|
||||
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Router Console") {
|
||||
console.log("Active in Router Console window");
|
||||
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Hidden Services Manager") {
|
||||
console.log("Active in Hidden Services Manager window");
|
||||
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Web Mail") {
|
||||
console.log("Active in Web Mail window");
|
||||
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titlepref
|
||||
});
|
||||
}
|
||||
} else if (context.name == "Bittorrent") {
|
||||
console.log("Active in I2P window");
|
||||
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: titleprefpriv
|
||||
@@ -147,18 +288,26 @@ function setTitle(window) {
|
||||
}
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
if (tabInfo[0].cookieStoreId != "firefox-default")
|
||||
if (
|
||||
tabInfo[0].cookieStoreId != "firefox-default" &&
|
||||
tabInfo[0].cookieStoreId != "firefox-private"
|
||||
) {
|
||||
browser.contextualIdentities
|
||||
.get(tabInfo[0].cookieStoreId)
|
||||
.then(onGot, onError);
|
||||
} else {
|
||||
if (window.incognito) {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: ""
|
||||
});
|
||||
} else {
|
||||
chrome.windows.update(window.id, {
|
||||
titlePreface: ""
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var querying = browser.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
@@ -167,8 +316,8 @@ function setTitle(window) {
|
||||
}
|
||||
|
||||
chrome.windows.onCreated.addListener(() => {
|
||||
//var gettingStoredSettings = chrome.storage.local.get();
|
||||
//gettingStoredSettings.then(setupProxy, onError);
|
||||
/* var gettingStoredSettings = chrome.storage.local.get();
|
||||
gettingStoredSettings.then(setupProxy, onError); */
|
||||
chrome.storage.local.get(function(got) {
|
||||
setupProxy();
|
||||
});
|
||||
|
@@ -17,6 +17,7 @@
|
||||
/* 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 (
|
||||
@@ -28,15 +29,15 @@
|
||||
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.
|
||||
/* 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.
|
||||
/* 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: {
|
||||
@@ -734,12 +735,8 @@
|
||||
* @param {*} value The value to test.
|
||||
* @returns {boolean} True if the value is thenable.
|
||||
*/
|
||||
const isThenable = value => {
|
||||
return (
|
||||
value && typeof value === "object" && typeof value.then === "function"
|
||||
);
|
||||
};
|
||||
|
||||
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:
|
||||
@@ -767,19 +764,17 @@
|
||||
* @returns {function}
|
||||
* The generated callback function.
|
||||
*/
|
||||
const makeCallback = (promise, metadata) => {
|
||||
return (...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 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 =>
|
||||
@@ -807,8 +802,8 @@
|
||||
* @returns {function(object, ...*)}
|
||||
* The generated wrapper function.
|
||||
*/
|
||||
const wrapAsyncFunction = (name, metadata) => {
|
||||
return function asyncFunctionWrapper(target, ...args) {
|
||||
const wrapAsyncFunction = (name, metadata) =>
|
||||
function asyncFunctionWrapper(target, ...args) {
|
||||
if (args.length < metadata.minArgs) {
|
||||
throw new Error(
|
||||
`Expected at least ${metadata.minArgs} ${pluralizeArguments(
|
||||
@@ -827,9 +822,9 @@
|
||||
|
||||
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.
|
||||
/* 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,
|
||||
@@ -844,8 +839,8 @@
|
||||
|
||||
target[name](...args);
|
||||
|
||||
// Update the API method metadata, so that the next API calls will not try to
|
||||
// use the unsupported callback anymore.
|
||||
/* 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;
|
||||
|
||||
@@ -862,7 +857,6 @@
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps an existing method of the target object, so that calls to it are
|
||||
@@ -883,13 +877,12 @@
|
||||
* A Proxy object for the given method, which invokes the given wrapper
|
||||
* method in its place.
|
||||
*/
|
||||
const wrapMethod = (target, method, wrapper) => {
|
||||
return new Proxy(method, {
|
||||
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);
|
||||
|
||||
@@ -935,20 +928,20 @@
|
||||
let value = target[prop];
|
||||
|
||||
if (typeof value === "function") {
|
||||
// This is a method on the underlying object. Check if we need to do
|
||||
// any wrapping.
|
||||
/* 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.
|
||||
/* 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.
|
||||
/* 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 (
|
||||
@@ -956,13 +949,13 @@
|
||||
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.
|
||||
/* 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.
|
||||
/* 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,
|
||||
@@ -999,16 +992,15 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 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.
|
||||
/* 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);
|
||||
};
|
||||
@@ -1095,17 +1087,17 @@
|
||||
|
||||
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 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).
|
||||
/* 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(
|
||||
@@ -1114,8 +1106,8 @@
|
||||
sendResponse(msg);
|
||||
},
|
||||
error => {
|
||||
// Send a JSON representation of the error if the rejected value
|
||||
// is an instance of error, or the object itself otherwise.
|
||||
/* 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 &&
|
||||
@@ -1139,9 +1131,9 @@
|
||||
});
|
||||
};
|
||||
|
||||
// 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 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 {
|
||||
@@ -1155,9 +1147,9 @@
|
||||
|
||||
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
|
||||
/* 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
|
||||
@@ -1167,8 +1159,8 @@
|
||||
reject(extensionAPIs.runtime.lastError);
|
||||
}
|
||||
} else if (reply && reply.__mozWebExtensionPolyfillReject__) {
|
||||
// Convert back the JSON representation of the error into
|
||||
// an Error instance.
|
||||
/* Convert back the JSON representation of the error into
|
||||
an Error instance. */
|
||||
reject(new Error(reply.message));
|
||||
} else {
|
||||
resolve(reply);
|
||||
@@ -1251,8 +1243,8 @@
|
||||
);
|
||||
}
|
||||
|
||||
// The build process adds a UMD wrapper around this file, which makes the
|
||||
// `module` variable available.
|
||||
/* The build process adds a UMD wrapper around this file, which makes the
|
||||
`module` variable available. */
|
||||
module.exports = wrapAPIs(chrome);
|
||||
} else {
|
||||
module.exports = browser;
|
||||
|
BIN
clearweb.png
Normal file
BIN
clearweb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 169 KiB |
19
content.js
19
content.js
@@ -15,3 +15,22 @@ newsMessage.textContent = chrome.i18n.getMessage("newsMessage");
|
||||
|
||||
var clearData = document.getElementById("clear-browser-data");
|
||||
clearData.textContent = chrome.i18n.getMessage("clearData");
|
||||
/*
|
||||
document.addEventListener("click", e => {
|
||||
browser.runtime.sendMessage({ url: "http://proxy.i2p" });
|
||||
});
|
||||
|
||||
function proxyContent(message) {
|
||||
var proxyData = document.getElementById("proxy-health");
|
||||
proxyData.textContent = message;
|
||||
console.log("Event occurred", message);
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(proxyContent);
|
||||
*/
|
||||
|
||||
/*
|
||||
function signalWebRTC(val){
|
||||
console.log("signal", val)
|
||||
}
|
||||
*/
|
||||
|
27
context.js
27
context.js
@@ -1,19 +1,20 @@
|
||||
//var windowIds = []
|
||||
|
||||
function onCreated(windowInfo) {
|
||||
console.log(`Created window: ${windowInfo.id}`);
|
||||
browser.tabs.create({
|
||||
windowId: windowInfo.id,
|
||||
url: "about:blank",
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
});
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
function eventHandler(event) {
|
||||
if (event.target.dataset.action == "create") {
|
||||
function onCreated(windowInfo) {
|
||||
console.log(`Created window: ${windowInfo.id}`);
|
||||
browser.tabs.create({
|
||||
windowId: windowInfo.id,
|
||||
url: "about:blank",
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
});
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var creating = browser.windows.create({
|
||||
cookieStoreId: event.target.dataset.identity
|
||||
});
|
||||
@@ -51,7 +52,7 @@ if (browser.contextualIdentities === undefined) {
|
||||
} else {
|
||||
browser.contextualIdentities
|
||||
.query({
|
||||
name: "i2pbrowser"
|
||||
name: "I2P Browsing"
|
||||
})
|
||||
.then(identities => {
|
||||
if (!identities.length) {
|
||||
|
14
debian/changelog
vendored
14
debian/changelog
vendored
@@ -1,10 +1,22 @@
|
||||
i2psetproxy.js (0.41-1) UNRELEASED; urgency=low
|
||||
|
||||
* Only open tabs, not windows
|
||||
* Optionally enable WebRTC
|
||||
|
||||
-- idk <hankhill19580@gmail.com> Thu, 31 OCT 2019 12:41:33 -0400
|
||||
|
||||
i2psetproxy.js (0.37-1) UNRELEASED; urgency=low
|
||||
|
||||
* Honor contextual ID when deleting history
|
||||
|
||||
-- idk <hankhill19580@gmail.com> Thu, 17 OCT 2019 00:52:19 -0400
|
||||
|
||||
i2psetproxy.js (0.35-1) UNRELEASED; urgency=low
|
||||
|
||||
* Automatically activate contexts
|
||||
|
||||
-- idk <hankhill19580@gmail.com> Thu, 01 Aug 2019 00:32:39 -0400
|
||||
|
||||
|
||||
i2psetproxy.js (0.31-1) UNRELEASED; urgency=low
|
||||
|
||||
* Initial release. Closes: #nnnn
|
||||
|
2
debian/rules
vendored
2
debian/rules
vendored
@@ -5,12 +5,14 @@
|
||||
|
||||
override_dh_auto_install:
|
||||
mkdir -p $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io \
|
||||
$$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol \
|
||||
$$(pwd)/debian/i2psetproxy.js/usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
|
||||
cp -r ./chromium/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp -r ./icons/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp -r ./options/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp -r ./_locales/ $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./*.js $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./i2pcontrol/i2pcontrol.js $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/i2pcontrol/
|
||||
cp ./*.html $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./*.css $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
cp ./*.md $$(pwd)/debian/i2psetproxy.js/usr/share/webext/i2ppb@eyedeekay.github.io/
|
||||
|
47
i2pcontrol/i2pcontrol.js
Normal file
47
i2pcontrol/i2pcontrol.js
Normal file
@@ -0,0 +1,47 @@
|
||||
function send(json) {
|
||||
const Http = new XMLHttpRequest();
|
||||
Http.withCredentials = false;
|
||||
const url = "http://" + "127.0.0.1" + ":" + "7650";
|
||||
Http.open("POST", url);
|
||||
Http.send(json);
|
||||
//console.log(Http);
|
||||
return Http;
|
||||
}
|
||||
|
||||
function authenticate(user, password) {
|
||||
var json = {
|
||||
jsonrpc: "2.0",
|
||||
id: user,
|
||||
method: "Authenticate",
|
||||
params: {
|
||||
API: 1,
|
||||
Password: password
|
||||
}
|
||||
};
|
||||
return send(json);
|
||||
}
|
||||
|
||||
var username = "";
|
||||
var password = "";
|
||||
|
||||
function echo(string, section) {
|
||||
var xhr = authenticate(username, password);
|
||||
console.log("(i2pcontrol) echo", xhr);
|
||||
xhr.onload = function() {
|
||||
resp = JSON.Parse(xhr.responseText);
|
||||
json = {
|
||||
jsonrpc: "2.0",
|
||||
id: username,
|
||||
method: "Echo",
|
||||
params: {
|
||||
Token: resp.Token,
|
||||
Echo: string
|
||||
}
|
||||
};
|
||||
var controlMessage = document.getElementById(section);
|
||||
console.log("(i2pcontrol) reply", xhr.responseText);
|
||||
infoMessage.textContent = xhr.responseText;
|
||||
};
|
||||
}
|
||||
|
||||
echo("test", "test");
|
4
info.css
4
info.css
@@ -16,3 +16,7 @@ span.identity {
|
||||
display: inline-block;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
display: inline;
|
||||
}
|
55
info.js
55
info.js
@@ -8,7 +8,7 @@ document.addEventListener("click", e => {
|
||||
type: "panel",
|
||||
incognito: true
|
||||
};
|
||||
let creating = chrome.windows.create(createData);
|
||||
let creating = browser.windows.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 = chrome.windows.create(createData);
|
||||
let creating = browser.windows.create(createData);
|
||||
creating.then(() => {
|
||||
console.log("The news panel has been created");
|
||||
});
|
||||
@@ -44,7 +44,58 @@ document.addEventListener("click", e => {
|
||||
forgetBrowsingData();
|
||||
} else if (e.target.id === "check-i2p-control") {
|
||||
echo("I2P Router Detected", "panel-section-i2pcontrol-check");
|
||||
} else if (e.target.id === "enable-web-rtc") {
|
||||
if (e.target.checked) {
|
||||
browser.runtime.sendMessage({ rtc: "enableWebRTC" });
|
||||
} else {
|
||||
browser.runtime.sendMessage({ rtc: "disableWebRTC" });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
function proxyReadiness() {
|
||||
console.log(this.responseText);
|
||||
}
|
||||
|
||||
//document.addEventListener("onpageshow", e => {
|
||||
console.log("(Check) Checking Proxy Readiness");
|
||||
const Http = new XMLHttpRequest();
|
||||
Http.addEventListener("load", proxyReadiness);
|
||||
const url = "http://proxy.i2p"; ///themes/console/images/favicon.ico";
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
//});
|
||||
|
||||
function transferComplete(evt) {
|
||||
console.log(
|
||||
"The transfer is complete.",
|
||||
this.status,
|
||||
this.statusText,
|
||||
this.responseText
|
||||
);
|
||||
}
|
||||
|
||||
function transferFailed(evt) {
|
||||
console.log(
|
||||
"An error occurred while transferring the file.",
|
||||
this.status,
|
||||
this.statusText,
|
||||
this.responseText
|
||||
);
|
||||
}
|
||||
|
||||
function transferCanceled(evt) {
|
||||
console.log(
|
||||
"The transfer has been canceled by the user.",
|
||||
this.status,
|
||||
this.statusText,
|
||||
this.responseText
|
||||
);
|
||||
}
|
||||
|
||||
Http.addEventListener("load", transferComplete);
|
||||
Http.addEventListener("error", transferFailed);
|
||||
Http.addEventListener("abort", transferCanceled);
|
||||
|
@@ -5,9 +5,13 @@
|
||||
"strict_min_version": "60.0"
|
||||
}
|
||||
},
|
||||
"chrome_settings_overrides": {
|
||||
"homepage": "home.html"
|
||||
},
|
||||
"permissions": [
|
||||
"theme",
|
||||
"browsingData",
|
||||
"bookmarks",
|
||||
"notifications",
|
||||
"proxy",
|
||||
"privacy",
|
||||
@@ -22,7 +26,7 @@
|
||||
],
|
||||
"manifest_version": 2,
|
||||
"name": "__MSG_extensionName__",
|
||||
"version": "0.36",
|
||||
"version": "0.41",
|
||||
"description": "__MSG_extensionDescription__",
|
||||
"homepage_url": "https://github.com/eyedeekay/i2psetproxy.js",
|
||||
"icons": {
|
||||
@@ -39,14 +43,14 @@
|
||||
},
|
||||
"background": {
|
||||
"scripts": [
|
||||
"chromium/browser-polyfill.js",
|
||||
"privacy.js",
|
||||
"platform.js",
|
||||
"background.js",
|
||||
"proxy.js",
|
||||
"info.js",
|
||||
"i2pcontrol.js",
|
||||
"scrub.js"
|
||||
"i2pcontrol/i2pcontrol.js",
|
||||
"scrub.js",
|
||||
"bookmarks.js"
|
||||
]
|
||||
},
|
||||
"protocol_handlers": [{
|
||||
|
@@ -24,47 +24,172 @@ function SetControlHostText() {
|
||||
controlhostid.textContent = chrome.i18n.getMessage("controlHostText");
|
||||
}
|
||||
|
||||
var handleContextProxyRequest = async function(requestDetails) {
|
||||
console.log("(proxy)Searching for proxy by context");
|
||||
try {
|
||||
var handleProxyRequest = function(context) {
|
||||
proxy = {
|
||||
failoverTimeout: 0,
|
||||
proxyDns: false
|
||||
};
|
||||
if (context != undefined) {
|
||||
if (context.name == "i2pbrowser") {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
} else if (context.name == "routerconsole") {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
return proxy;
|
||||
} else if (!routerHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: "http",
|
||||
host: "localhost",
|
||||
port: "65535"
|
||||
};
|
||||
}
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
} else if (context.name == "fenced-default") {
|
||||
if (localHost(requestDetails.url)) {
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: "http",
|
||||
host: "localhost",
|
||||
port: "65535"
|
||||
};
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: "http",
|
||||
host: "localhost",
|
||||
port: "65535"
|
||||
};
|
||||
} else if (i2pHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
}
|
||||
return proxy;
|
||||
};
|
||||
var contextGet = async function(tabInfo) {
|
||||
try {
|
||||
console.log("(proxy)Tab info from Function", tabInfo);
|
||||
context = await browser.contextualIdentities.get(tabInfo.cookieStoreId);
|
||||
return context;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Context Error", error);
|
||||
}
|
||||
};
|
||||
var tabFind = async function(tabId) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.query({
|
||||
name: "i2pbrowser"
|
||||
});
|
||||
tabId.cookieStoreId = context[0].cookieStoreId;
|
||||
console.log("(proxy) forcing context", tabId.cookieStoreId);
|
||||
return tabId;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Context Error", error);
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(proxy)Tab ID from Request", tabId);
|
||||
let tabInfo = await browser.tabs.get(tabId);
|
||||
return tabInfo;
|
||||
} catch (error) {
|
||||
console.log("(proxy)Tab error", error);
|
||||
}
|
||||
};
|
||||
|
||||
if (requestDetails.tabId > 0) {
|
||||
if (proxyHost(requestDetails.url)) {
|
||||
console.log("(Proxy)I2P Proxy test URL detected, ", requestDetails.url);
|
||||
return {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
} else if (i2pHost(requestDetails.url)) {
|
||||
console.log("(Proxy)I2P URL detected, ");
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(tabFind);
|
||||
requestDetails.tabId = mtab;
|
||||
var context = mtab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
} else {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var context = tab.then(contextGet);
|
||||
var proxy = await context.then(handleProxyRequest);
|
||||
console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(proxy)Not using I2P Proxy.", error);
|
||||
}
|
||||
};
|
||||
|
||||
function setupProxy() {
|
||||
var controlHost = getControlHost();
|
||||
var controlPort = getControlPort();
|
||||
var Host = getHost();
|
||||
var Port = getPort();
|
||||
var Scheme = getScheme();
|
||||
if (!getChrome()) {
|
||||
function handleProxyRequest(requestInfo) {
|
||||
console.log("proxying request via listener");
|
||||
console.log(" ", Scheme, Host, ":", Port);
|
||||
return {
|
||||
type: Scheme,
|
||||
host: Host,
|
||||
port: Port,
|
||||
proxyDns: true
|
||||
};
|
||||
}
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
rules: {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port)
|
||||
}
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set(
|
||||
{
|
||||
value: config,
|
||||
scope: "regular"
|
||||
},
|
||||
function() {}
|
||||
);
|
||||
}
|
||||
|
||||
/**/
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
/**/
|
||||
}
|
||||
|
||||
function SetControlPortText() {
|
||||
@@ -126,23 +251,77 @@ function getControlPort() {
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http";
|
||||
function gotProxyInfo(info) {
|
||||
let defaultSettings = {};
|
||||
let host = info.value.http.split(":")[0];
|
||||
let port = info.value.http.split(":")[1];
|
||||
console.log("proxy", "'" + host + "'", ":", port);
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http";
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
if (host == "") {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1";
|
||||
} else {
|
||||
defaultSettings["proxy_host"] = host;
|
||||
}
|
||||
} else {
|
||||
if (host != "") {
|
||||
defaultSettings["proxy_host"] = host;
|
||||
} else {
|
||||
defaultSettings["proxy_host"] = storedSettings.proxy_host;
|
||||
}
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
if (port == undefined) {
|
||||
defaultSettings["proxy_port"] = 4444;
|
||||
} else {
|
||||
defaultSettings["proxy_port"] = port;
|
||||
}
|
||||
} else {
|
||||
if (port != undefined) {
|
||||
defaultSettings["proxy_port"] = port;
|
||||
} else {
|
||||
defaultSettings["proxy_port"] = storedSettings.proxy_port;
|
||||
}
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
if (host == "") {
|
||||
defaultSettings["control_host"] = "127.0.0.1";
|
||||
} else {
|
||||
defaultSettings["control_host"] = host;
|
||||
}
|
||||
} else {
|
||||
if (host != "") {
|
||||
defaultSettings["control_host"] = host;
|
||||
} else {
|
||||
defaultSettings["control_host"] = storedSettings.control_host;
|
||||
}
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
if (port == undefined) {
|
||||
defaultSettings["control_port"] = 4444;
|
||||
} else {
|
||||
defaultSettings["control_port"] = port;
|
||||
}
|
||||
} else {
|
||||
if (port != undefined) {
|
||||
defaultSettings["control_port"] = port;
|
||||
} else {
|
||||
defaultSettings["control_port"] = storedSettings.control_port;
|
||||
}
|
||||
}
|
||||
console.log("(browserinfo) NATIVE PROXYSETTINGS", info.value);
|
||||
console.log(
|
||||
defaultSettings["proxy_host"],
|
||||
defaultSettings["proxy_port"],
|
||||
defaultSettings["control_host"],
|
||||
defaultSettings["control_port"]
|
||||
);
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444;
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444;
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
var gettingInfo = browser.proxy.settings.get({});
|
||||
gettingInfo.then(gotProxyInfo);
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
|
30
platform.js
30
platform.js
@@ -1,23 +1,13 @@
|
||||
function getChrome() {
|
||||
if (browser.runtime.getBrowserInfo == undefined) {
|
||||
console.log("Running in Chrome detected");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isDroid() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
if (got.os == "android") {
|
||||
console.log("Running in Android detected");
|
||||
return true;
|
||||
} else {
|
||||
console.log("Running in Desktop detected");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
if (got.os == "android") {
|
||||
console.log("Running in Android detected");
|
||||
return true;
|
||||
} else {
|
||||
console.log("Running in Desktop detected");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
238
privacy.js
238
privacy.js
@@ -1,10 +1,3 @@
|
||||
function getChrome() {
|
||||
if (chrome.runtime.getBrowserInfo == undefined) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onSet(result) {
|
||||
if (result) {
|
||||
console.log("->: Value was updated");
|
||||
@@ -13,55 +6,49 @@ function onSet(result) {
|
||||
}
|
||||
}
|
||||
|
||||
// This disables queries to centralized databases of bad URLs to screen for
|
||||
// risky sites in your browser
|
||||
/* This disables queries to centralized databases of bad URLs to screen for
|
||||
risky sites in your browser */
|
||||
function disableHyperlinkAuditing() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling hyperlink auditing/val=", {
|
||||
value: false
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling hyperlink auditing/val=", {
|
||||
value: false
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
|
||||
// This enables first-party isolation
|
||||
function enableFirstPartyIsolation() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling first party isolation/val=", {
|
||||
value: true
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
var setting = browser.privacy.websites.firstPartyIsolate.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling first party isolation/val=", {
|
||||
value: true
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
|
||||
// This rejects tracking cookies and third-party cookies but it
|
||||
// LEAVES "Persistent" Cookies unmodified in favor of an option in the content
|
||||
// interface for now
|
||||
/* This rejects tracking cookies and third-party cookies but it
|
||||
LEAVES "Persistent" Cookies unmodified in favor of an option in the content
|
||||
interface for now */
|
||||
function disableEvilCookies() {
|
||||
if (!getChrome()) {
|
||||
var getting = browser.privacy.websites.cookieConfig.get({});
|
||||
getting.then(got => {
|
||||
var setting = browser.privacy.websites.cookieConfig.set({
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
console.log("Setting cookie behavior/val=", {
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
setting.then(onSet);
|
||||
var getting = browser.privacy.websites.cookieConfig.get({});
|
||||
getting.then(got => {
|
||||
var setting = browser.privacy.websites.cookieConfig.set({
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log("Setting cookie behavior/val=", {
|
||||
value: {
|
||||
behavior: "reject_third_party",
|
||||
nonPersistentCookies: got.value.nonPersistentCookies
|
||||
}
|
||||
});
|
||||
setting.then(onSet);
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure that they're gone
|
||||
@@ -77,63 +64,55 @@ function disableEvilCookies() {
|
||||
|
||||
// this disables the use of referrer headers
|
||||
function disableReferrers() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling referrer headers/val=", {
|
||||
value: false
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Disabling referrer headers/val=", {
|
||||
value: false
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
|
||||
// enable fingerprinting resistent features(letterboxing and stuff)
|
||||
function enableResistFingerprinting() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling resist fingerprinting/val=", {
|
||||
value: true
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
var setting = browser.privacy.websites.referrersEnabled.set({
|
||||
value: true
|
||||
});
|
||||
console.log("Enabling resist fingerprinting/val=", {
|
||||
value: true
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
|
||||
// This is essentially a blocklist of clearnet web-sites known to do bad tracking
|
||||
function enableTrackingProtection() {
|
||||
if (!getChrome()) {
|
||||
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
||||
value: "always"
|
||||
});
|
||||
console.log("Enabling tracking protection/val=", {
|
||||
value: "always"
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
var setting = browser.privacy.websites.trackingProtectionMode.set({
|
||||
value: "always"
|
||||
});
|
||||
console.log("Enabling tracking protection/val=", {
|
||||
value: "always"
|
||||
});
|
||||
setting.then(onSet);
|
||||
}
|
||||
|
||||
// This disables protected content, which is a form of digital restrictions
|
||||
// management dependent on identifying information
|
||||
/* This disables protected content, which is a form of digital restrictions
|
||||
management dependent on identifying information */
|
||||
function disableDigitalRestrictionsManagement() {
|
||||
if (!getChrome()) {
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
if (got.os == "win") {
|
||||
var setting = browser.privacy.websites.protectedContentEnabled.set({
|
||||
var gettingInfo = browser.runtime.getPlatformInfo();
|
||||
gettingInfo.then(got => {
|
||||
if (got.os == "win") {
|
||||
var setting = browser.privacy.websites.protectedContentEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log(
|
||||
"Setting Protected Content(Digital Restrictions Management) false/val=",
|
||||
{
|
||||
value: false
|
||||
});
|
||||
console.log(
|
||||
"Setting Protected Content(Digital Restrictions Management) false/val=",
|
||||
{
|
||||
value: false
|
||||
}
|
||||
);
|
||||
setting.then(onSet);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
setting.then(onSet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setAllPrivacy() {
|
||||
@@ -149,14 +128,12 @@ function setAllPrivacy() {
|
||||
setAllPrivacy();
|
||||
|
||||
function ResetPeerConnection() {
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
@@ -164,14 +141,12 @@ function ResetPeerConnection() {
|
||||
}
|
||||
|
||||
function EnablePeerConnection() {
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
}
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: true
|
||||
});
|
||||
browser.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
chrome.privacy.network.webRTCIPHandlingPolicy.set({
|
||||
value: "disable_non_proxied_udp"
|
||||
});
|
||||
@@ -214,10 +189,8 @@ function checkStoredSettings(storedSettings) {
|
||||
chrome.storage.local.set(appSettings);
|
||||
}
|
||||
|
||||
if (!getChrome()) {
|
||||
const gettingStoredSettings = browser.storage.local.get();
|
||||
gettingStoredSettings.then(checkStoredSettings, onError);
|
||||
}
|
||||
const gettingStoredSettings = browser.storage.local.get();
|
||||
gettingStoredSettings.then(checkStoredSettings, onError);
|
||||
|
||||
function clearCookiesContext(cookieStoreId) {}
|
||||
|
||||
@@ -228,15 +201,9 @@ function forgetBrowsingData(storedSettings) {
|
||||
}
|
||||
|
||||
const times = {
|
||||
hour: () => {
|
||||
return 1000 * 60 * 60;
|
||||
},
|
||||
day: () => {
|
||||
return 1000 * 60 * 60 * 24;
|
||||
},
|
||||
week: () => {
|
||||
return 1000 * 60 * 60 * 24 * 7;
|
||||
}
|
||||
hour: () => 1000 * 60 * 60,
|
||||
day: () => 1000 * 60 * 60 * 24,
|
||||
week: () => 1000 * 60 * 60 * 24 * 7
|
||||
};
|
||||
|
||||
const sinceMilliseconds = times[selectedSince].call();
|
||||
@@ -260,7 +227,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
browser.notifications.create({
|
||||
type: "basic",
|
||||
title: "Removed browsing data",
|
||||
message: `Removed ${dataTypesString}\n for i2pbrowser`
|
||||
message: `Removed ${dataTypesString}\n for I2P Browsing`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -276,34 +243,34 @@ function forgetBrowsingData(storedSettings) {
|
||||
browser.browsingData
|
||||
.removePasswords({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since: since
|
||||
since
|
||||
})
|
||||
.then(onGot);
|
||||
console.log("cleared Passwords");
|
||||
browser.browsingData
|
||||
.removeDownloads({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since: since
|
||||
since
|
||||
})
|
||||
.then(onGot);
|
||||
console.log("cleared Downloads");
|
||||
browser.browsingData
|
||||
.removeFormData({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since: since
|
||||
since
|
||||
})
|
||||
.then(onGot);
|
||||
console.log("cleared Form Data");
|
||||
browser.browsingData
|
||||
.removeLocalStorage({
|
||||
hostnames: [i2pHostName(item.url)],
|
||||
since: since
|
||||
since
|
||||
})
|
||||
.then(onGot);
|
||||
console.log("cleared Local Storage");
|
||||
|
||||
contexts = browser.contextualIdentities.query({
|
||||
name: "i2pbrowser"
|
||||
name: "I2P Browsing"
|
||||
});
|
||||
|
||||
function deepCleanCookies(cookies) {
|
||||
@@ -315,7 +282,7 @@ function forgetBrowsingData(storedSettings) {
|
||||
});
|
||||
removing.then(onGot, onError);
|
||||
}
|
||||
console.log("Cleared cookies")
|
||||
console.log("Cleared cookies");
|
||||
}
|
||||
|
||||
function deepCleanContext(cookieStoreIds) {
|
||||
@@ -368,8 +335,15 @@ function onGot(contexts) {
|
||||
}
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.error(e);
|
||||
}
|
||||
browser.runtime.onMessage.addListener(message);
|
||||
|
||||
//browser.contextualIdentities.query("i2pbrowser").then(clearCookiesContext, onError);
|
||||
function message(message) {
|
||||
console.log(message);
|
||||
if (message.rtc === "enableWebRTC") {
|
||||
console.log("enableWebRTC");
|
||||
EnablePeerConnection();
|
||||
} else {
|
||||
console.log("disableWebRTC");
|
||||
ResetPeerConnection();
|
||||
}
|
||||
}
|
||||
|
234
proxy.js
234
proxy.js
@@ -1,9 +1,7 @@
|
||||
if (!getChrome()) {
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Preliminarily disabled WebRTC.");
|
||||
}
|
||||
browser.privacy.network.peerConnectionEnabled.set({
|
||||
value: false
|
||||
});
|
||||
console.log("Preliminarily disabled WebRTC.");
|
||||
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
value: false
|
||||
@@ -22,22 +20,87 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
var handleProxyRequest = function(context) {
|
||||
proxy = {
|
||||
failoverTimeout: 0,
|
||||
type: "direct",
|
||||
proxyDns: false
|
||||
};
|
||||
if (context.name == "i2pbrowser") {
|
||||
if (context != undefined) {
|
||||
if (context.name == "I2P Browsing") {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
} else if (context.name == "Router Console") {
|
||||
if (routerHost(requestDetails.url)) {
|
||||
return proxy;
|
||||
} else if (!routerHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: "http",
|
||||
host: "localhost",
|
||||
port: "65535"
|
||||
};
|
||||
}
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
} else if (context.name == "Web Browsing") {
|
||||
if (localHost(requestDetails.url)) {
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: "http",
|
||||
host: "localhost",
|
||||
port: "65535"
|
||||
};
|
||||
}
|
||||
}
|
||||
console.log(
|
||||
"(proxy)",
|
||||
context.name,
|
||||
"Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
if (!routerHost(requestDetails.url)) {
|
||||
if (localHost(requestDetails.url)) {
|
||||
console.log(
|
||||
"(proxy) non-routerconsole localhost url, dropping",
|
||||
requestDetails.url
|
||||
);
|
||||
proxy = {
|
||||
type: "http",
|
||||
host: "localhost",
|
||||
port: "65535"
|
||||
};
|
||||
}
|
||||
} else if (i2pHost(requestDetails.url)) {
|
||||
proxy = {
|
||||
type: getScheme(),
|
||||
host: getHost(),
|
||||
port: getPort()
|
||||
};
|
||||
console.log(
|
||||
"(proxy)Using",
|
||||
proxy.type,
|
||||
"proxy ",
|
||||
proxy.host + ":" + proxy.port
|
||||
);
|
||||
return proxy;
|
||||
}
|
||||
return proxy;
|
||||
};
|
||||
@@ -52,10 +115,6 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
};
|
||||
var tabFind = async function(tabId) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.query({
|
||||
name: "i2pbrowser"
|
||||
});
|
||||
tabId.cookieStoreId = context[0].cookieStoreId;
|
||||
console.log("(proxy) forcing context", tabId.cookieStoreId);
|
||||
return tabId;
|
||||
} catch (error) {
|
||||
@@ -89,6 +148,9 @@ var handleContextProxyRequest = async function(requestDetails) {
|
||||
console.log("(proxy)Returning I2P Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
proxy = {};
|
||||
console.log("(proxy)Returning unset Proxy", proxy);
|
||||
return proxy;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(proxy)Not using I2P Proxy.", error);
|
||||
@@ -160,55 +222,97 @@ function setupProxy() {
|
||||
var Host = getHost();
|
||||
var Port = getPort();
|
||||
var Scheme = getScheme();
|
||||
if (!getChrome()) {
|
||||
/**/
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
/**/
|
||||
} else {
|
||||
var config = {
|
||||
mode: "fixed_servers",
|
||||
rules: {
|
||||
singleProxy: {
|
||||
scheme: Scheme,
|
||||
host: Host,
|
||||
port: parseInt(Port)
|
||||
}
|
||||
}
|
||||
};
|
||||
chrome.proxy.settings.set(
|
||||
{
|
||||
value: config,
|
||||
scope: "regular"
|
||||
},
|
||||
function() {}
|
||||
);
|
||||
}
|
||||
|
||||
/**/
|
||||
console.log("Setting up Firefox WebExtension proxy");
|
||||
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
console.log("i2p settings created for WebExtension Proxy");
|
||||
/**/
|
||||
}
|
||||
|
||||
function checkStoredSettings(storedSettings) {
|
||||
let defaultSettings = {};
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http";
|
||||
function gotProxyInfo(info) {
|
||||
let defaultSettings = {};
|
||||
let host = info.value.http.split(":")[0];
|
||||
let port = info.value.http.split(":")[1];
|
||||
console.log("proxy", "'" + host + "'", ":", port);
|
||||
if (!storedSettings.proxy_scheme) {
|
||||
defaultSettings["proxy_scheme"] = "http";
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
if (host == "") {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1";
|
||||
} else {
|
||||
defaultSettings["proxy_host"] = host;
|
||||
}
|
||||
} else {
|
||||
if (host != "") {
|
||||
defaultSettings["proxy_host"] = host;
|
||||
} else {
|
||||
defaultSettings["proxy_host"] = storedSettings.proxy_host;
|
||||
}
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
if (port == undefined) {
|
||||
defaultSettings["proxy_port"] = 4444;
|
||||
} else {
|
||||
defaultSettings["proxy_port"] = port;
|
||||
}
|
||||
} else {
|
||||
if (port != undefined) {
|
||||
defaultSettings["proxy_port"] = port;
|
||||
} else {
|
||||
defaultSettings["proxy_port"] = storedSettings.proxy_port;
|
||||
}
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
if (host == "") {
|
||||
defaultSettings["control_host"] = "127.0.0.1";
|
||||
} else {
|
||||
defaultSettings["control_host"] = host;
|
||||
}
|
||||
} else {
|
||||
if (host != "") {
|
||||
defaultSettings["control_host"] = host;
|
||||
} else {
|
||||
defaultSettings["control_host"] = storedSettings.control_host;
|
||||
}
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
if (port == undefined) {
|
||||
defaultSettings["control_port"] = 4444;
|
||||
} else {
|
||||
defaultSettings["control_port"] = port;
|
||||
}
|
||||
} else {
|
||||
if (port != undefined) {
|
||||
defaultSettings["control_port"] = port;
|
||||
} else {
|
||||
defaultSettings["control_port"] = storedSettings.control_port;
|
||||
}
|
||||
}
|
||||
console.log("(browserinfo) NATIVE PROXYSETTINGS", info.value);
|
||||
console.log(
|
||||
defaultSettings["proxy_host"],
|
||||
defaultSettings["proxy_port"],
|
||||
defaultSettings["control_host"],
|
||||
defaultSettings["control_port"]
|
||||
);
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
}
|
||||
if (!storedSettings.proxy_host) {
|
||||
defaultSettings["proxy_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.proxy_port) {
|
||||
defaultSettings["proxy_port"] = 4444;
|
||||
}
|
||||
if (!storedSettings.control_host) {
|
||||
defaultSettings["control_host"] = "127.0.0.1";
|
||||
}
|
||||
if (!storedSettings.control_port) {
|
||||
defaultSettings["control_port"] = 4444;
|
||||
}
|
||||
chrome.storage.local.set(defaultSettings);
|
||||
var gettingInfo = browser.proxy.settings.get({});
|
||||
gettingInfo.then(gotProxyInfo);
|
||||
}
|
||||
|
||||
//function gotProxyInfo(info) {
|
||||
//console.log("(browserinfo)", info.value);
|
||||
//}
|
||||
|
||||
//var gettingInfo = browser.proxy.settings.get({});
|
||||
//gettingInfo.then(gotProxyInfo);
|
||||
|
||||
function update(restoredSettings) {
|
||||
proxy_scheme = restoredSettings.proxy_scheme;
|
||||
console.log("restoring proxy scheme:", proxy_scheme);
|
||||
@@ -229,8 +333,6 @@ chrome.storage.local.get(function(got) {
|
||||
});
|
||||
|
||||
// Theme all currently open windows
|
||||
if (!getChrome()) {
|
||||
if (!isDroid()) {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
}
|
||||
if (!isDroid()) {
|
||||
browser.windows.getAll().then(wins => wins.forEach(themeWindow));
|
||||
}
|
||||
|
BIN
routerconsole.png
Normal file
BIN
routerconsole.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 696 KiB |
365
scrub.js
365
scrub.js
@@ -4,21 +4,33 @@ var contextScrub = async function(requestDetails) {
|
||||
var headerScrub = function(context) {
|
||||
if (!context) {
|
||||
console.error("Context not found");
|
||||
} else {
|
||||
if ((context.name = "i2pbrowser")) {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
if (i2pHost(requestUrl.url)) {
|
||||
for (var header of requestDetails.requestHeaders) {
|
||||
if (header.name.toLowerCase() === "user-agent") {
|
||||
header.value = ua;
|
||||
console.log("(scrub)User-Agent header modified", header.value);
|
||||
}
|
||||
} else if (context.name == "I2P Browsing") {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
for (var header of requestDetails.requestHeaders) {
|
||||
if (header.name.toLowerCase() === "user-agent") {
|
||||
header.value = ua;
|
||||
console.log("(scrub)User-Agent header modified", header.value);
|
||||
}
|
||||
}
|
||||
return {
|
||||
requestHeaders: requestDetails.requestHeaders
|
||||
};
|
||||
}
|
||||
return {
|
||||
requestHeaders: requestDetails.requestHeaders
|
||||
};
|
||||
} else if (context.name == "Router Console") {
|
||||
var ua = "MYOB/6.66 (AN/ON)";
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
for (var header of requestDetails.requestHeaders) {
|
||||
if (header.name.toLowerCase() === "user-agent") {
|
||||
header.value = ua;
|
||||
console.log("(scrub)User-Agent header modified", header.value);
|
||||
}
|
||||
}
|
||||
} else if (routerHost(requestDetails.url)) {
|
||||
}
|
||||
return {
|
||||
requestHeaders: requestDetails.requestHeaders
|
||||
};
|
||||
}
|
||||
};
|
||||
var contextGet = async function(tabInfo) {
|
||||
@@ -33,7 +45,7 @@ var contextScrub = async function(requestDetails) {
|
||||
var tabFind = async function(tabId) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.query({
|
||||
name: "i2pbrowser"
|
||||
name: "I2P Browsing"
|
||||
});
|
||||
tabId.cookieStoreId = context[0].cookieStoreId;
|
||||
console.log("(scrub) forcing context", tabId.cookieStoreId);
|
||||
@@ -52,22 +64,26 @@ var contextScrub = async function(requestDetails) {
|
||||
}
|
||||
};
|
||||
if (requestDetails.tabId > 0) {
|
||||
var tab = {};
|
||||
var context = {};
|
||||
var req = {};
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
console.log("(Proxy)I2P URL detected, ");
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(tabFind);
|
||||
requestDetails.tabId = mtab;
|
||||
var context = mtab.then(contextGet);
|
||||
var req = await context.then(headerScrub);
|
||||
context = mtab.then(contextGet);
|
||||
req = await context.then(headerScrub);
|
||||
console.log("(scrub)Scrubbing I2P Request", req);
|
||||
return req;
|
||||
} else {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var context = tab.then(contextGet);
|
||||
var req = await context.then(headerScrub);
|
||||
console.log("(scrub)Scrubbing I2P Request", req);
|
||||
} else if (routerHost(requestDetails.url)) {
|
||||
tab = tabGet(requestDetails.tabId);
|
||||
context = tab.then(contextGet);
|
||||
req = await context.then(headerScrub);
|
||||
console.log("(scrub)Scrubbing non-I2P Request", req);
|
||||
return req;
|
||||
}
|
||||
return req;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(scrub)Not scrubbing non-I2P request.", error);
|
||||
@@ -79,12 +95,12 @@ var contextSetup = async function(requestDetails) {
|
||||
try {
|
||||
var tabFind = async function(tabId) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.query({
|
||||
name: "i2pbrowser"
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: "I2P Browsing"
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log(
|
||||
"(isolate) forcing",
|
||||
"(isolate) forcing I2P Browsing",
|
||||
requestDetails.url,
|
||||
" context",
|
||||
tabId.cookieStoreId,
|
||||
@@ -92,14 +108,14 @@ var contextSetup = async function(requestDetails) {
|
||||
);
|
||||
function Create(window) {
|
||||
function onCreated(tab) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
console.log("(isolate) Closing old, un-isolated tab", window);
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.remove(window.tabs[0].id);
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
created = browser.tabs.create({
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url,
|
||||
@@ -107,7 +123,7 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
getting = browser.windows.create();
|
||||
var getting = browser.windows.getCurrent();
|
||||
getting.then(Create);
|
||||
return tabId;
|
||||
}
|
||||
@@ -117,12 +133,12 @@ var contextSetup = async function(requestDetails) {
|
||||
};
|
||||
var routerTabFind = async function(tabId) {
|
||||
try {
|
||||
context = await browser.contextualIdentities.query({
|
||||
name: "routerconsole"
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: "Router Console"
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log(
|
||||
"(isolate) forcing",
|
||||
"(isolate) forcing Router Console",
|
||||
requestDetails.url,
|
||||
" context",
|
||||
tabId.cookieStoreId,
|
||||
@@ -137,7 +153,7 @@ var contextSetup = async function(requestDetails) {
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
created = browser.tabs.create({
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url,
|
||||
@@ -145,7 +161,7 @@ var contextSetup = async function(requestDetails) {
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
getting = browser.windows.create();
|
||||
var getting = browser.windows.getCurrent();
|
||||
getting.then(Create);
|
||||
return tabId;
|
||||
}
|
||||
@@ -153,6 +169,166 @@ var contextSetup = async function(requestDetails) {
|
||||
console.log("(isolate)Context Error", error);
|
||||
}
|
||||
};
|
||||
var i2ptunnelTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: "Hidden Services Manager"
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log(
|
||||
"(isolate) forcing HSM context",
|
||||
requestDetails.url,
|
||||
" context",
|
||||
tabId.cookieStoreId,
|
||||
context[0].cookieStoreId
|
||||
);
|
||||
function Create(window) {
|
||||
function onCreated(tab) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
if (window != undefined) {
|
||||
browser.tabs.remove(window.tabs[0].id);
|
||||
}
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url,
|
||||
windowId: window.id
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.windows.getCurrent();
|
||||
getting.then(Create);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(isolate)Context Error", error);
|
||||
}
|
||||
};
|
||||
var snarkTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: "Bittorrent"
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log(
|
||||
"(isolate) forcing Bittorrent",
|
||||
requestDetails.url,
|
||||
" context",
|
||||
tabId.cookieStoreId,
|
||||
context[0].cookieStoreId
|
||||
);
|
||||
function Create(window) {
|
||||
function onCreated(tab) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.remove(window.tabs[0].id);
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url,
|
||||
windowId: window.id
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.windows.getCurrent();
|
||||
getting.then(Create);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(isolate)Context Error", error);
|
||||
}
|
||||
};
|
||||
var mailTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: "Web Mail"
|
||||
});
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log(
|
||||
"(isolate) forcing Web Mail",
|
||||
requestDetails.url,
|
||||
" context",
|
||||
tabId.cookieStoreId,
|
||||
context[0].cookieStoreId
|
||||
);
|
||||
function Create(window) {
|
||||
function onCreated(tab) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.remove(window.tabs[0].id);
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url,
|
||||
windowId: window.id
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.windows.getCurrent();
|
||||
getting.then(Create);
|
||||
return tabId;
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(isolate)Context Error", error);
|
||||
}
|
||||
};
|
||||
var anyTabFind = async function(tabId) {
|
||||
try {
|
||||
var context = await browser.contextualIdentities.query({
|
||||
name: "Web Browsing"
|
||||
});
|
||||
console.log("(ISOLATE)", tabId.cookieStoreId);
|
||||
if (
|
||||
tabId.cookieStoreId == "firefox-default" ||
|
||||
tabId.cookieStoreId == "firefox-private"
|
||||
) {
|
||||
if (tabId.cookieStoreId != context[0].cookieStoreId) {
|
||||
console.log(
|
||||
"(isolate) forcing Web Browsing",
|
||||
requestDetails.url,
|
||||
" context",
|
||||
tabId.cookieStoreId,
|
||||
context[0].cookieStoreId
|
||||
);
|
||||
function Create(window) {
|
||||
function onCreated(tab) {
|
||||
console.log("(isolate) Closing old, un-isolated tab");
|
||||
browser.tabs.remove(tabId.id);
|
||||
browser.tabs.remove(window.tabs[0].id);
|
||||
}
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
var created = browser.tabs.create({
|
||||
active: true,
|
||||
cookieStoreId: context[0].cookieStoreId,
|
||||
url: requestDetails.url,
|
||||
windowId: window.id
|
||||
});
|
||||
created.then(onCreated, onError);
|
||||
}
|
||||
var getting = browser.windows.getCurrent();
|
||||
getting.then(Create);
|
||||
return tabId;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("(isolate)Context Error", error);
|
||||
}
|
||||
};
|
||||
var tabGet = async function(tabId) {
|
||||
try {
|
||||
console.log("(isolate)Tab ID from Request", tabId);
|
||||
@@ -163,22 +339,44 @@ var contextSetup = async function(requestDetails) {
|
||||
}
|
||||
};
|
||||
if (requestDetails.tabId > 0) {
|
||||
if (proxyHost(requestDetails.url)) {
|
||||
return requestDetails;
|
||||
}
|
||||
if (i2pHost(requestDetails.url)) {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(tabFind);
|
||||
return requestDetails;
|
||||
}
|
||||
if (routerHost(requestDetails.url)) {
|
||||
let routerhost = routerHost(requestDetails.url);
|
||||
if (routerhost) {
|
||||
if (routerhost === "i2ptunnelmgr") {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(i2ptunnelTabFind);
|
||||
return requestDetails;
|
||||
} else if (routerhost === "i2psnark") {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(snarkTabFind);
|
||||
return requestDetails;
|
||||
} else if (routerhost === "webmail") {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(mailTabFind);
|
||||
return requestDetails;
|
||||
} else if (routerhost === "routerconsole") {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(routerTabFind);
|
||||
return requestDetails;
|
||||
}
|
||||
} else {
|
||||
var tab = tabGet(requestDetails.tabId);
|
||||
var mtab = tab.then(routerTabFind);
|
||||
var mtab = tab.then(anyTabFind);
|
||||
return requestDetails;
|
||||
}
|
||||
}
|
||||
//var tab = tabGet(requestDetails.tabId);
|
||||
//var mtab = tab.then(anyTabFind);
|
||||
return requestDetails;
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"(isolate)Not an I2P request, no need to force into alternate cookiestore.",
|
||||
error
|
||||
);
|
||||
console.log("(isolate)Not an I2P request, blackholing", error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,23 +395,82 @@ function i2pHost(url) {
|
||||
return hostname.endsWith(".i2p");
|
||||
}
|
||||
|
||||
function routerHost(url) {
|
||||
function proxyHost(url) {
|
||||
let hostname = "";
|
||||
if (url.indexOf("://") > -1) {
|
||||
hostname = url.split("/")[2];
|
||||
} else {
|
||||
hostname = url.split("/")[0];
|
||||
}
|
||||
if (hostname === "127.0.0.1:7657") {
|
||||
if (hostname == "proxy.i2p") {
|
||||
return true;
|
||||
} else if (hostname === "localhost:7657") {
|
||||
}
|
||||
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") {
|
||||
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 true;
|
||||
return pathcheck(path);
|
||||
} else if (hostname === "localhost:7070") {
|
||||
return true;
|
||||
return pathcheck(path);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -230,3 +487,25 @@ browser.webRequest.onBeforeSendHeaders.addListener(
|
||||
{ urls: ["<all_urls>"] },
|
||||
["blocking", "requestHeaders"]
|
||||
);
|
||||
|
||||
/*
|
||||
function notify(message) {
|
||||
var response = await fetch('https://proxy.i2p', {
|
||||
credentials: 'include'
|
||||
});
|
||||
const myJson = await response.json();
|
||||
console.log(JSON.stringify(myJson));
|
||||
|
||||
console.log(message);
|
||||
const Http = new XMLHttpRequest();
|
||||
Http.mozAnon = true;
|
||||
Http.withCredentials = true;
|
||||
const url = "http://proxy.i2p";
|
||||
Http.open("GET", url);
|
||||
Http.send();
|
||||
Http.onreadystatechange = e => {
|
||||
console.log(Http.responseText);
|
||||
browser.runtime.sendMessage(Http.responseText);
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
17
window.html
17
window.html
@@ -27,26 +27,31 @@
|
||||
<!-- <a href="#" id="generate-fresh-tunnel> Generate a Fresh Tunnel</a>"-->
|
||||
<!-- -->
|
||||
<strong><a href="#" id="clear-browser-data">Clear all browsing data</a></strong><br>
|
||||
<!--<strong><a href="#" id="temp-enable-webrtc">Temporarily enable WebRTC</a></strong><br>-->
|
||||
<div class="panel-section-separator"></div>
|
||||
<a href="http://i2pforum.i2p" id="window-create-forum-panel">Visit the I2P Forums</a><br>
|
||||
<a href="http://i2p-projekt.i2p/blog" id="window-create-news-panel">Get the latest I2P News</a><br>
|
||||
<div class="panel-section-separator"></div>
|
||||
<a href="#" id="check-i2p-control">Check I2P Router Health</a><div id="panel-section-i2pcontrol-check"></div>
|
||||
<!--<div id="proxy-health">Proxy is:</div>-->
|
||||
<input type="checkbox" id="enable-web-rtc" name="enablewebrtc" value="webrtc">
|
||||
<label for="enable-web-rtc">Enable WebRTC <strong>with Proxy?</strong></label>
|
||||
<div class="panel-section-separator"></div>
|
||||
<!--<a href="#" id="check-i2p-control">Check I2P Router Health</a><div id="panel-section-i2pcontrol-check"></div>-->
|
||||
<figure>
|
||||
<img src="http://proxy.i2p/themes/console/images/favicon.ico" id="panel-proxy-check" alt="Proxy is not ready yet"/>
|
||||
<figcaption>I2P Proxy is Ready</figcaption>
|
||||
</figure>
|
||||
<div class="panel-section-separator"></div>
|
||||
|
||||
<div class="panel-section-identity">
|
||||
<div id="identity-list"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script src="context.js"></script>
|
||||
<script src="privacy.js"></script>
|
||||
<script src="info.js"></script>
|
||||
<script src="content.js"></script>
|
||||
<script src="i2pcontrol.js"></script>
|
||||
<script src="content.js" crossorigin="anonymous"></script>
|
||||
<script src="i2pcontrol/i2pcontrol.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
Reference in New Issue
Block a user