34 Commits
0.87 ... 0.91

Author SHA1 Message Date
idk
13c5042006 Exclude clearnet code hosting sites from scrub checks 2020-12-14 14:47:34 -05:00
idk
01ce1a2f13 fmt 2020-12-14 14:44:46 -05:00
idk
8430e3b952 git commit -am exclude searches on clearnet code hosting services from scrub checks 2020-12-14 14:43:04 -05:00
idk
ac09b72be3 change the url for the MuWire test 2020-12-13 14:07:10 -05:00
idk
d901711c7b Merge branch 'slightly-better-popup' into 'master'
Slightly better popup

See merge request idk/I2P-in-Private-Browsing-Mode-Firefox!18
2020-12-13 04:37:06 +00:00
idk
88517a7b52 bail out when the header has already been detected and the pageaction is already set 2020-12-12 23:33:25 -05:00
idk
39eb695522 fmt 2020-12-12 00:08:27 -05:00
idk
009bac364c fmt 2020-12-11 20:49:16 -05:00
idk
9741b21def fmt 2020-12-11 20:48:35 -05:00
idk
df7bc109ed update popup css 2020-12-11 20:47:49 -05:00
idk
8cd9b53be3 update popup css 2020-12-11 20:18:58 -05:00
idk
9db61be253 Merge branch 'do-less' into 'master'
Be less Interruptive in non-essential ways

Closes #29 and #30

See merge request idk/I2P-in-Private-Browsing-Mode-Firefox!17
2020-12-12 01:16:18 +00:00
idk
78a1794568 fix sanity check on torrent proxy 2020-12-11 16:30:22 -05:00
idk
aa9805e107 Fix torrent-proxy sanity check 2020-12-11 15:42:28 -05:00
idk
a992553ffb make embedding torrents in pages faster 2020-12-10 10:15:48 -05:00
idk
3a30961cd1 fix btProxy 2020-12-09 21:58:58 -05:00
idk
a6aba7b5f7 fix btProxy 2020-12-09 20:55:57 -05:00
idk
26c4152bf6 fix btProxy 2020-12-09 20:55:04 -05:00
idk
8230fe92a7 uninstall process 2020-12-09 20:53:15 -05:00
idk
6d0cda9e67 get ready to clean up after the extension when it uninstalls 2020-12-09 20:51:08 -05:00
idk
12992c461b get ready to clean up after the extension when it uninstalls 2020-12-09 20:45:49 -05:00
idk
531963c1c0 filter the headers before we search them 2020-12-09 20:13:20 -05:00
idk
8bfb7cdd27 search the headers backward and break on the first one since the non-standard header is usually near the end 2020-12-09 18:20:48 -05:00
idk
40899889a0 correct promise resolution on scripts.js 2020-12-09 17:59:53 -05:00
idk
bc88ca80fd re-enable tab-to-tab isolation 2020-12-09 17:53:31 -05:00
idk
3b3744ffff Cheat at excluding MuWire from ! 2020-12-09 17:49:36 -05:00
idk
9cd6ce888e Try and bail out of all proxy-setting in the Wire Web App 2020-12-09 17:09:54 -05:00
idk
7b2216a12f Nix timed x-i2p-torrentlocation stuff entirely 2020-12-09 16:43:08 -05:00
idk
1946669b82 pre-filter URL's for so we don't try to run isolator checks on domains that have no chance of needing isolation 2020-12-09 14:36:59 -05:00
idk
bb14021bc0 make it so we only launch containers out of firefox-default, rather than re-checking every single request 2020-12-09 14:19:59 -05:00
idk
51510abaed Merge branch 'torrent-3' into 'master'
Torrent 3

See merge request idk/I2P-in-Private-Browsing-Mode-Firefox!16
2020-12-06 18:35:18 +00:00
idk
f837eb18d5 Make it so clicking the pageaction also triggers the torrent check as a manual approach 2020-12-06 13:32:43 -05:00
idk
bf4b160dcd fmt 2020-12-06 13:01:02 -05:00
idk
7bd08ab6e0 Check whether it's a torrent-enabled site much more often. It's still not quite right but it's much better now. Update priorities when it comes as a header instead of as a meta tag 2020-12-06 13:00:11 -05:00
17 changed files with 707 additions and 539 deletions

View File

@@ -37,11 +37,11 @@ clean: rc clean-artifacts
## EVEN RELEASES are AMO RELEASES
## ODD RELEASES are SELFHOSTED RELEASES
MOZ_VERSION=0.88
VERSION=0.87
MOZ_VERSION=0.92
VERSION=0.91
## INCREMENT THIS EVERY TIME YOU DO A RELEASE
LAST_VERSION=0.85
LAST_VERSION=0.89
YELLOW=F7E59A
ORANGE=FFC56D
@@ -339,7 +339,29 @@ snark-mirror:
seed:
cp -v "./i2ppb-$(VERSION)@eyedeekay.github.io.xpi.torrent" "$(HOME)/.i2p/i2psnark"
cp -v "../i2ppb-$(VERSION)@eyedeekay.github.io.xpi" "$(HOME)/.i2p/i2psnark"
wire:
cp -v "./i2ppb-$(VERSION)@eyedeekay.github.io.xpi.torrent" "$(HOME)/i2p/MuWireDownloads/"
cp -v "../i2ppb-$(VERSION)@eyedeekay.github.io.xpi" "$(HOME)/i2p/MuWireDownloads/"
ndtest:
web-ext run -u about:debugging \
-u http://127.0.0.1:7657/home \
-u http://127.0.0.1:7657/i2ptunnel \
-u http://127.0.0.1:7657/i2psnark \
-u http://127.0.0.1:7657/webmail \
-u http://127.0.0.1:7657/MuWire \
-u http://idk.i2p/video.html \
-u http://idk.i2p \
-u http://stats.i2p \
-u https://ramble.pw \
-u https://ramble.pw/f/i2p \
lht-test:
web-ext run -u about:debugging \
-u http://localhost:7657/home \
-u http://localhost:7657/i2ptunnel \
-u http://localhost:7657/i2psnark \
-u http://localhost:7657/webmail \
-u http://localhost:7657/MuWire/ \
-u http://idk.i2p

View File

@@ -14,8 +14,19 @@ var ircpref = chrome.i18n.getMessage('ircPreface');
var ircprefpriv = chrome.i18n.getMessage('ircPrefacePrivate');
var extensionpref = chrome.i18n.getMessage('extensionPreface');
var muwirepref = chrome.i18n.getMessage('muwirePreface');
var muwireprefpriv = chrome.i18n.getMessage('muwirePrefacePrivate');
var botepref = chrome.i18n.getMessage('botePreface');
function onError(err) {
console.log('(background)', err);
}
function onContextGotLog(contexts) {
if (contexts != null) {
console.log(contexts);
}
}
function onContextsGot(contexts) {
var ids = [];
for (let context of contexts) {
@@ -370,29 +381,31 @@ function handleUpdated(updateInfo) {
them.originalTheme.images == null &&
them.originalTheme.properties == null)
) {
if (
updateInfo.theme.colors.frame != "#4456B7" &&
updateInfo.theme.colors.frame != "#363A68"
) {
function onSet() {
console.log("stored theme:", updateInfo.theme);
}
if (updateInfo.theme.colors != null) {
if (
updateInfo.theme.colors != null ||
updateInfo.theme.images != null ||
updateInfo.theme.properties != null
updateInfo.theme.colors.frame != "#4456B7" &&
updateInfo.theme.colors.frame != "#363A68"
) {
console.log("storing theme:", updateInfo.theme);
browser.storage.local
.set({ originalTheme: updateInfo.theme })
.then(onSet, onError);
function onSet() {
console.log("stored theme:", updateInfo.theme);
}
if (
updateInfo.theme.colors != null &&
updateInfo.theme.images != null &&
updateInfo.theme.properties != null
) {
console.log("storing theme:", updateInfo.theme);
browser.storage.local
.set({ originalTheme: updateInfo.theme })
.then(onSet, onError);
}
}
}
} else {
console.log("keeping stored theme:", them);
}
} catch {
console.log("theme storage error");
} catch (e) {
console.log("theme storage error", e);
}
}
browser.storage.local.get("originalTheme").then(maybeSet, onError);

View File

@@ -182,6 +182,7 @@ function bookmarksSetup() {
title: 'I2P Console',
});
b4.then(bookConsole, onRejected);
defaultSettings['bookmarks_state'] = true;
}
var bt = browser.bookmarks.search({
@@ -190,7 +191,6 @@ function bookmarksSetup() {
function toolDir(bookmarkToolbar) {
let defaultSettings = {};
defaultSettings['bookmarks_state'] = true;
chrome.storage.local.set(defaultSettings);
console.log('(bookmarks) created');
var ibbt = browser.bookmarks.search('I2P Toolbar');

13
debian/changelog vendored
View File

@@ -1,3 +1,16 @@
i2psetproxy.js (0.91-1) UNRELEASED; urgency=low
* Exclude clearnet code hosting sites from scrub checks
-- idk <hankhill19580@gmail.com> Sat, 14 DEC 2020 2:46:23 -0400
i2psetproxy.js (0.89-1) UNRELEASED; urgency=low
* Pages with lots of AJAX requests could trigger a performance degradation
* Improve performance of x-i2p-* headers and meta tags
-- idk <hankhill19580@gmail.com> Sat, 13 DEC 2020 2:22:00 -0400
i2psetproxy.js (0.87-1) UNRELEASED; urgency=low
* Disable searching for i2p sites in non-i2p search engines

View File

@@ -109,9 +109,8 @@ var handlerSetup = function(requestDetails) {
}
return requestDetails;
};
browser.webRequest.onBeforeRequest.addListener(
handlerSetup,
{ urls: ['<all_urls>'] },
['blocking']
);
/*
browser.webRequest.onBeforeRequest.addListener(handlerSetup, {
urls: ['<all_urls>'],
});
*/

View File

@@ -38,7 +38,7 @@
<ul>
<li>
<a href="magnet:?xt=urn:btih:8d0e4b7965826328d2d857487116a6af997807e1">Magnet Link</a>
<a href="magnet:?xt=urn:btih:7c941672fd7b36cbb2cec817549616ef51d70bfd">Magnet Link</a>
</li>
<li>

View File

@@ -14,7 +14,7 @@ function checkSnowflake() {
try {
function snowflake(snowflake) {
console.log("snowflake plugin found, leaving WebRTC alone", snowflake);
EnablePeerConnection();
AssurePeerConnection();
}
var snowflakeInfo = browser.management.get(
"{b11bea1f-a888-4332-8d8a-cec2be7d24b9}" // string

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8">
<link href="search.css" rel="stylesheet">
<link href="home.css" rel="stylesheet">
<link href="info.css" rel="stylesheet"><!--<link href="torrent/popup.css" rel="stylesheet">-->
<!--<link href="info.css" rel="stylesheet">--><!--<link href="torrent/popup.css" rel="stylesheet">-->
<title>
</title>

View File

@@ -27,7 +27,7 @@
],
"manifest_version": 2,
"name": "__MSG_extensionName__",
"version": "0.85",
"version": "0.89",
"description": "__MSG_extensionDescription__",
"homepage_url": "https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox",
"icons": {

View File

@@ -20,6 +20,15 @@ function disableHyperlinkAuditing() {
setting.then(onSet);
}
// UNINSTALL ONLY
function enableHyperlinkAuditing() {
var setting = browser.privacy.websites.hyperlinkAuditingEnabled.clear();
console.log('Disabling hyperlink auditing/val=', {
value: false,
});
setting.then(onSet);
}
// This enables first-party isolation
function enableFirstPartyIsolation() {
var setting = browser.privacy.websites.firstPartyIsolate.set({
@@ -31,6 +40,15 @@ function enableFirstPartyIsolation() {
setting.then(onSet);
}
// UNINSTALL ONLY
function disableFirstPartyIsolation() {
var setting = browser.privacy.websites.firstPartyIsolate.clear();
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 */
@@ -53,6 +71,10 @@ function disableEvilCookies() {
});
}
function enableEvilCookies() {
var getting = browser.privacy.websites.cookieConfig.clear();
}
// Make sure that they're gone
/*function disableBadCookies(){
var setting = browser.privacy.websites.thirdPartyCookiesAllowed.set({
@@ -75,6 +97,15 @@ function disableReferrers() {
setting.then(onSet);
}
// UNINSATALL ONLY
function enableReferrers() {
var setting = browser.privacy.websites.referrersEnabled.clear();
console.log("Disabling referrer headers/val=", {
value: false,
});
setting.then(onSet);
}
// enable fingerprinting resistent features(letterboxing and stuff)
function enableResistFingerprinting() {
var setting = browser.privacy.websites.resistFingerprinting.set({
@@ -86,6 +117,15 @@ function enableResistFingerprinting() {
setting.then(onSet);
}
// UNINSTALL ONLY
function disableResistFingerprinting() {
var setting = browser.privacy.websites.resistFingerprinting.clear();
console.log("Enabling resist fingerprinting/val=", {
value: false,
});
setting.then(onSet);
}
// This is essentially a blocklist of clearnet web-sites known to do bad tracking
function enableTrackingProtection() {
var setting = browser.privacy.websites.trackingProtectionMode.set({
@@ -97,6 +137,15 @@ function enableTrackingProtection() {
setting.then(onSet);
}
// UNINSTALL ONLY
function disableTrackingProtection() {
var setting = browser.privacy.websites.trackingProtectionMode.clear();
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 */
function disableDigitalRestrictionsManagement() {
@@ -117,6 +166,45 @@ function disableDigitalRestrictionsManagement() {
});
}
// UNINSTALL ONLY
function disableDigitalRestrictionsManagement() {
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then((got) => {
if (got.os == "win") {
var setting = browser.privacy.websites.protectedContentEnabled.clear();
console.log(
"Setting Protected Content(Digital Restrictions Management) false/val=",
{
value: true,
}
);
setting.then(onSet);
}
});
}
function unsetAllPrivacy() {
enableHyperlinkAuditing();
disableFirstPartyIsolation();
enableEvilCookies();
enableReferrers();
disableTrackingProtection();
disableResistFingerprinting();
enableDigitalRestrictionsManagement();
UnsetPeerConnection();
EnableSavePasswords();
}
browser.management.onUninstalled.addListener((info) => {
function gotSelf(selfinfo) {
if (info.name == selfinfo.name) {
unsetAllPrivacy();
}
}
var gettingSelf = browser.management.getSelf();
gettingSelf.then(gotSelf);
});
function setAllPrivacy() {
disableHyperlinkAuditing();
enableFirstPartyIsolation();
@@ -140,7 +228,7 @@ function ResetPeerConnection() {
}
function snowflake(snowflake) {
console.log("snowflake plugin found, leaving WebRTC alone", snowflake);
EnablePeerConnection();
AssurePeerConnection();
}
var snowflakeInfo = browser.management.get(
"{b11bea1f-a888-4332-8d8a-cec2be7d24b9}" // string
@@ -148,23 +236,11 @@ function ResetPeerConnection() {
snowflakeInfo.then(snowflake, reset);
}
function EnablePeerConnection() {
var webrtc = true;
var rtc = browser.privacy.network.peerConnectionEnabled.set({
value: webrtc,
});
rtc.then(AssurePeerConnection);
console.log("Enabled WebRTC");
}
function AssurePeerConnection() {
function assure(webrtc) {
browser.privacy.network.peerConnectionEnabled.set({
value: true,
});
browser.privacy.network.networkPredictionEnabled.set({
value: false,
});
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: "disable_non_proxied_udp",
});
@@ -173,6 +249,20 @@ function AssurePeerConnection() {
rtc.then(assure);
}
// UNINSTALL ONLY
function UnsetPeerConnection() {
function assure(webrtc) {
browser.privacy.network.peerConnectionEnabled.set({
value: true,
});
chrome.privacy.network.webRTCIPHandlingPolicy.set({
value: "default",
});
}
let rtc = browser.privacy.network.peerConnectionEnabled.get({});
rtc.then(assure);
}
var gettingInfo = browser.runtime.getPlatformInfo();
gettingInfo.then((got) => {
if (got.os == "android") {
@@ -191,9 +281,7 @@ function ResetDisableSavePasswords() {
}
function EnableSavePasswords() {
browser.privacy.services.passwordSavingEnabled.set({
value: true,
});
browser.privacy.services.passwordSavingEnabled.clear();
console.log("Enabled saved passwords");
}
@@ -401,7 +489,7 @@ function message(recieved) {
console.log(recieved);
if (recieved.rtc === "enableWebRTC") {
console.log("enableWebRTC");
EnablePeerConnection();
AssurePeerConnection();
} else if (recieved.rtc === "disableWebRTC") {
console.log("disableWebRTC");
ResetPeerConnection();

171
proxy.js
View File

@@ -1,6 +1,7 @@
var titlepref = chrome.i18n.getMessage('titlePreface');
var webpref = chrome.i18n.getMessage('webPreface');
var ircpref = chrome.i18n.getMessage('ircPreface');
var torrentpref = chrome.i18n.getMessage('torrentPreface');
var routerpref = chrome.i18n.getMessage('routerPreface');
var routerprefpriv = chrome.i18n.getMessage('routerPrefacePrivate');
var ircpref = chrome.i18n.getMessage('ircPreface');
@@ -22,6 +23,61 @@ function shouldProxyRequest(requestInfo) {
}
var handleContextProxyRequest = async function(requestDetails) {
function ircProxy() {
if (!requestDetails.url.includes('7669')) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
return proxy;
}
if (requestDetails.url.includes(':7669')) {
proxy = null;
return proxy;
}
}
function btProxy() {
proxy = routerProxy();
if (requestDetails.url.includes(':7662')) {
proxy = null;
return proxy;
}
console.log('(bt proxy)', proxy);
return proxy;
}
function mainProxy() {
console.log('(proxy) mainproxy 0');
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
let url = new URL(requestDetails.url);
if (
requestDetails.url.startsWith(
'http://' + getHost() + ':' + getConsolePort() + '/i2psnark/'
)
) {
//+url.host)) {
console.log('(proxy) mainproxy 2', url);
proxy = null;
}
return proxy;
}
function routerProxy() {
if (routerHost(requestDetails.url)) {
proxy = null;
return proxy;
} else if (!routerHost(requestDetails.url)) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
return proxy;
}
}
try {
var handleProxyRequest = function(context) {
proxy = {
@@ -32,85 +88,52 @@ var handleContextProxyRequest = async function(requestDetails) {
proxy = null;
return proxy;
}
console.log('(proxy), context', context);
if (context != undefined) {
console.log('(proxy), context', context);
proxy = routerProxy();
if (context.name == ircpref) {
if (!requestDetails.url.includes('7669')) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
}
}
if (context.name == titlepref) {
if (!requestDetails.url.includes('/i2psnark/')) {
console.log('URL', requestDetails.url);
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
}
proxy = ircProxy();
return proxy;
} else if (context.name == ircpref) {
} else if (context.name == titlepref) {
proxy = mainProxy();
return proxy;
} else if (context.name == routerpref) {
proxy = routerProxy();
return proxy;
} else if (context.name == torrentpref) {
proxy = btProxy();
return proxy;
}
return proxy;
} else {
if (!routerHost(requestDetails.url)) {
if (localHost(requestDetails.url)) {
if (requestDetails.url.includes(':7669')) {
proxy = null;
} else if (requestDetails.url.includes(':7662')) {
proxy = null;
} else {
console.log(
'(proxy) non-routerconsole localhost url, will not interfere',
requestDetails.url
);
}
}
} else if (i2pHost(requestDetails.url)) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
if (requestDetails.url.includes(':7669')) {
proxy = null;
}
} else if (context.name == routerpref) {
if (routerHost(requestDetails.url)) {
proxy = null;
} else if (!routerHost(requestDetails.url)) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
}
return proxy;
} else if (context.name == webpref) {
if (localHost(requestDetails.url)) {
if (!routerHost(requestDetails.url)) {
proxy = {
type: 'http',
host: 'localhost',
port: '65535',
};
}
}
return proxy;
}
//var tab = tabGet(requestDetails.tabId);
//tab.then(handleTabRequest,)
return proxy;
}
if (!routerHost(requestDetails.url)) {
if (localHost(requestDetails.url)) {
if (requestDetails.url.includes(':7669')) {
proxy = null;
} else {
console.log(
'(proxy) non-routerconsole localhost url, will not interfere',
requestDetails.url
);
}
}
} else if (i2pHost(requestDetails.url)) {
proxy = {
type: getScheme(),
host: getHost(),
port: getPort(),
};
}
//var tab = tabGet(requestDetails.tabId);
//tab.then(handleTabRequest,)
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) {
@@ -120,7 +143,6 @@ var handleContextProxyRequest = async function(requestDetails) {
};
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) {
@@ -136,10 +158,6 @@ var handleContextProxyRequest = async function(requestDetails) {
return proxy;
}
if (requestDetails.originUrl == browser.runtime.getURL('security.html')) {
console.log(
'(proxy) extension security URL',
browser.runtime.getURL('security.html')
);
proxy = {
type: getScheme(),
host: getHost(),
@@ -154,6 +172,9 @@ var handleContextProxyRequest = async function(requestDetails) {
return browser.proxy.settings.get({});
}
if (requestDetails.tabId > 0) {
if (requestDetails.url.includes('MuWire')) {
return;
}
if (proxyHost(requestDetails.url)) {
proxy = {
type: getScheme(),
@@ -168,7 +189,7 @@ var handleContextProxyRequest = async function(requestDetails) {
requestDetails.tabId = tab;
var context = tab.then(contextGet);
var proxy = await context.then(handleProxyRequest);
console.log('(proxy)Returning I2P Proxy', proxy);
//console.log('(proxy)Returning I2P Proxy', proxy);
return proxy;
} else {
var tab = tabGet(requestDetails.tabId);
@@ -307,15 +328,15 @@ function getConsolePort() {
if (control_port == undefined) {
var scheme = getScheme();
if (scheme == 'socks') proxy_port = '7657';
else proxy_port = '7657';
else control_port = '7657';
}
return proxy_port;
return control_port;
}
function setupProxy() {
console.log('Setting up Firefox WebExtension proxy');
browser.proxy.onRequest.addListener(handleContextProxyRequest, {
urls: ['<all_urls>'],
urls: ['*://*.i2p/*', '*://localhost/*', '*://127.0.0.1/*', '*://*/*i2p*'],
});
console.log('i2p settings created for WebExtension Proxy');
}

View File

@@ -4,13 +4,53 @@
<link type="text/html" rel="alternate" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases"/>
<link type="application/atom+xml" rel="self" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases.atom"/>
<title>Release notes from I2P-in-Private-Browsing-Mode-Firefox</title>
<updated>2020-11-11T06:44:09Z</updated>
<updated>2020-12-13T19:07:10Z</updated>
<entry>
<id>tag:github.com,2008:Repository/169256012/0.89</id>
<updated>2020-12-13T19:11:13Z</updated>
<link rel="alternate" type="text/html" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases/tag/0.89"/>
<title>0.89</title>
<enclosure url="magnet:?xt=urn:btih:7c941672fd7b36cbb2cec817549616ef51d70bfd" type="application/x-bittorrent" />
<content type="html">&lt;p&gt;============================&lt;/p&gt;
&lt;p&gt;A simple plugin for configuring a Firefox based web browser to isolate I2P&lt;br&gt;
Browsing to a single contextual identity, thus creating an I2P in Private&lt;br&gt;
Browsing mode. It requires the use of a pre-installed I2P Router.&lt;br&gt;
i2psetproxy.js (0.89-1) UNRELEASED; urgency=low&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pages with lots of AJAX requests could trigger a performance degradation&lt;/li&gt;
&lt;li&gt;Improve performance of x-i2p-* headers and meta tags&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;i2psetproxy.js (0.87-1) UNRELEASED; urgency=low&lt;/p&gt;</content>
<author>
<name>eyedeekay</name>
</author>
<media:thumbnail height="30" width="30" url="https://avatars3.githubusercontent.com/u/8733713?s=60&amp;v=4"/>
</entry>
<entry>
<id>tag:github.com,2008:Repository/169256012/0.87</id>
<updated>2020-12-06T18:37:57Z</updated>
<link rel="alternate" type="text/html" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases/tag/0.87"/>
<title>0.87</title>
<content type="html">&lt;p&gt;Browsing to a single contextual identity, thus creating an I2P in Private&lt;br&gt;
Browsing mode. It requires the use of a pre-installed I2P Router.&lt;br&gt;
i2psetproxy.js (0.87-1) UNRELEASED; urgency=low&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Disable searching for i2p sites in non-i2p search engines&lt;/li&gt;
&lt;li&gt;Add contexts for i2pbote and Dispatch&lt;/li&gt;
&lt;li&gt;Remain in tighter control of x-i2p-torrentlocation priority&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;-- idk &lt;a href=&quot;mailto:hankhill19580@gmail.com&quot;&gt;hankhill19580@gmail.com&lt;/a&gt; Sat, 10 NOV 2020 1:33:50 -0400&lt;/p&gt;
&lt;p&gt;i2psetproxy.js (0.85-1) UNRELEASED; urgency=low&lt;/p&gt;</content>
<author>
<name>eyedeekay</name>
</author>
<media:thumbnail height="30" width="30" url="https://avatars3.githubusercontent.com/u/8733713?s=60&amp;v=4"/>
</entry>
<entry>
<id>tag:github.com,2008:Repository/169256012/0.85</id>
<updated>2020-11-11T06:44:44Z</updated>
<link rel="alternate" type="text/html" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases/tag/0.85"/>
<title>0.85</title>
<enclosure url="magnet:?xt=urn:btih:8d0e4b7965826328d2d857487116a6af997807e1" type="application/x-bittorrent" />
<content type="html">&lt;p&gt;A simple plugin for configuring a Firefox based web browser to isolate I2P&lt;br&gt;
Browsing to a single contextual identity, thus creating an I2P in Private&lt;br&gt;
Browsing mode. It requires the use of a pre-installed I2P Router.&lt;br&gt;
@@ -156,43 +196,4 @@ i2psetproxy.js (0.71-1) UNRELEASED; urgency=low&lt;/p&gt;
</author>
<media:thumbnail height="30" width="30" url="https://avatars3.githubusercontent.com/u/8733713?s=60&amp;v=4"/>
</entry>
<entry>
<id>tag:github.com,2008:Repository/169256012/0.69</id>
<updated>2020-03-24T04:19:44Z</updated>
<link rel="alternate" type="text/html" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases/tag/0.69"/>
<title>0.69</title>
<content type="html">&lt;p&gt;A simple plugin for configuring a Firefox based web browser to isolate I2P&lt;br&gt;
Browsing to a single contextual identity, thus creating an I2P in Private&lt;br&gt;
Browsing mode. It requires the use of a pre-installed I2P Router.&lt;br&gt;
i2psetproxy.js (0.69-1) UNRELEASED; urgency=low&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add MuWire contextual ID&lt;/li&gt;
&lt;li&gt;Fix bug occurring on certain modded I2P installs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;-- idk &lt;a href=&quot;mailto:hankhill19580@gmail.com&quot;&gt;hankhill19580@gmail.com&lt;/a&gt; Tue, 24 MAR 2020 0:12:02 -0400&lt;/p&gt;
&lt;p&gt;i2psetproxy.js (0.67-1) UNRELEASED; urgency=low&lt;/p&gt;</content>
<author>
<name>eyedeekay</name>
</author>
<media:thumbnail height="30" width="30" url="https://avatars3.githubusercontent.com/u/8733713?s=60&amp;v=4"/>
</entry>
<entry>
<id>tag:github.com,2008:Repository/169256012/0.67</id>
<updated>2020-03-18T04:27:30Z</updated>
<link rel="alternate" type="text/html" href="https://github.com/eyedeekay/I2P-in-Private-Browsing-Mode-Firefox/releases/tag/0.67"/>
<title>0.67</title>
<content type="html">&lt;p&gt;A simple plugin for configuring a Firefox based web browser to isolate I2P&lt;br&gt;
Browsing to a single contextual identity, thus creating an I2P in Private&lt;br&gt;
Browsing mode. It requires the use of a pre-installed I2P Router.&lt;br&gt;
i2psetproxy.js (0.67-1) UNRELEASED; urgency=low&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Tweak some default settings that should have gone into 65&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;-- idk &lt;a href=&quot;mailto:hankhill19580@gmail.com&quot;&gt;hankhill19580@gmail.com&lt;/a&gt; Tue, 17 MAR 2020 22:58:55 -0400&lt;/p&gt;
&lt;p&gt;i2psetproxy.js (0.65-1) UNRELEASED; urgency=low&lt;/p&gt;</content>
<author>
<name>eyedeekay</name>
</author>
<media:thumbnail height="30" width="30" url="https://avatars3.githubusercontent.com/u/8733713?s=60&amp;v=4"/>
</entry>
</feed>

231
script.js
View File

@@ -1,102 +1,151 @@
browser.runtime.onMessage.addListener((request) => {
var response = '';
var response = 'no-alt-location';
console.log(request);
if (request.req === 'i2p-location') {
response = 'no-alt-location';
const metas = document.getElementsByTagName('meta');
for (let i = 0; i < metas.length; i++) {
try {
tag = metas[i].getAttribute('http-equiv');
if (tag.toUpperCase() === 'I2P-LOCATION') {
response = metas[i].getAttribute('content');
}
if (tag.toUpperCase() === 'X-I2P-LOCATION') {
response = metas[i].getAttribute('content');
}
} catch {};
var tag = document.querySelector('meta[http-equiv="i2p-location"]');
if (tag != undefined) {
console.log(tag);
if (tag) response = tag.content;
}
var tag = document.querySelector('meta[http-equiv="x-i2p-location"]');
if (tag != undefined) {
console.log(tag);
if (tag) response = tag.content;
}
}
if (request.req === 'i2p-torrentlocation') {
response = 'no-alt-location';
const metas = document.getElementsByTagName('meta');
var tag = document.querySelector('meta[http-equiv="i2p-torrentlocation"]');
console.log(tag);
if (tag) {
response = tag.content;
var imgs = document.getElementsByTagName('img');
console.log('rewriting torrent link');
for (let img of imgs) {
let tmpsrc = new URL(img.src);
if (tmpsrc.host == location.host) {
img.src =
'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
img.onerror = function() {
img.src = tmpsrc;
};
}
}
var videos = document.getElementsByTagName('video');
for (let video of videos) {
video.setAttribute('preload', 'none');
let tmpsrc = new URL(video.currentSrc);
if (tmpsrc.host == location.host) {
if (!video.innerHTML.includes('127.0.0.1')) {
innerHTML = video.innerHTML;
topInnerHTML = video.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
);
video.innerHTML = topInnerHTML; // + innerHTML;
video.onerror = function() {
video.innerHTML = topInnerHTML + innerHTML;
};
}
}
}
var audios = document.getElementsByTagName('audio');
for (let audio of audios) {
audio.setAttribute('preload', 'none');
let tmpsrc = new URL(audio.currentSrc);
if (tmpsrc.host == location.host) {
if (!audio.innerHTML.includes('127.0.0.1')) {
innerHTML = audio.innerHTML;
topInnerHTML = audio.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
);
audio.innerHTML = topInnerHTML; // + innerHTML;
audio.onerror = function() {
audio.innerHTML = topInnerHTML + innerHTML;
};
}
}
}
var links = document.getElementsByTagName('a');
for (let link of links) {
let tmpsrc = new URL(link.href);
if (tmpsrc.host == location.host) {
if (
!tmpsrc.pathname.endsWith('html') &&
!tmpsrc.pathname.endsWith('htm') &&
!tmpsrc.pathname.endsWith('php') &&
!tmpsrc.pathname.endsWith('jsp') &&
!tmpsrc.pathname.endsWith('asp') &&
!tmpsrc.pathname.endsWith('aspx') &&
!tmpsrc.pathname.endsWith('atom') &&
!tmpsrc.pathname.endsWith('rss') &&
!tmpsrc.pathname.endsWith('/') &&
tmpsrc.pathname.includes('.')
) {
link.href =
'http://127.0.0.1:7657/i2psnark/' + tmpsrc.host + tmpsrc.pathname;
link.onerror = function() {
window.location.href = tmpsrc.href;
};
}
}
}
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
var tag = document.querySelector(
'meta[http-equiv="x-i2p-torrentlocation"]'
);
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
}
return Promise.resolve({ content: response });
});
window.document.onload = function (e) {
console.log("presetting x-i2p-torrentlocation");
var tag = document.querySelector('meta[http-equiv="i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
var tag = document.querySelector('meta[http-equiv="x-i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
};
console.log("presetting x-i2p-torrentlocation");
var tag = document.querySelector('meta[http-equiv="i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
var tag = document.querySelector('meta[http-equiv="x-i2p-torrentlocation"]');
if (tag != undefined) {
console.log(tag);
response = i2pTorrent(tag);
}
function i2pTorrent(tag) {
let response = "no-alt-location";
if (tag) {
response = tag.content;
var imgs = document.getElementsByTagName("img");
console.log("rewriting torrent link");
for (let img of imgs) {
let tmpsrc = new URL(img.src);
if (tmpsrc.host == location.host) {
img.src =
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname;
img.onerror = function () {
img.src = tmpsrc;
};
}
}
var videos = document.getElementsByTagName("video");
for (let video of videos) {
video.setAttribute("preload", "none");
let tmpsrc = new URL(video.currentSrc);
if (tmpsrc.host == location.host) {
if (!video.innerHTML.includes("127.0.0.1")) {
innerHTML = video.innerHTML;
topInnerHTML = video.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + "/"
);
// let url = new URL("http://127.0.0.1:7657/i2psnark/"+location.host+"/"location.path)
console.log(
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname
); //+"/"location.path)
video.src =
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname;
video.innerHTML = topInnerHTML; // + innerHTML;
video.onerror = function () {
console.log("video error");
video.innerHTML = topInnerHTML + innerHTML;
};
}
}
}
var audios = document.getElementsByTagName("audio");
for (let audio of audios) {
audio.setAttribute("preload", "none");
let tmpsrc = new URL(audio.currentSrc);
if (tmpsrc.host == location.host) {
if (!audio.innerHTML.includes("127.0.0.1")) {
innerHTML = audio.innerHTML;
topInnerHTML = audio.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + "/"
);
//console.log("http://127.0.0.1:7657/i2psnark/" + location); //.host+"/"location.path)
console.log(
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname
); //+"/"location.path)
audio.src =
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname;
audio.innerHTML = topInnerHTML; // + innerHTML;
audio.onerror = function () {
console.log("audio error");
audio.innerHTML = topInnerHTML + innerHTML;
};
}
}
}
var links = document.getElementsByTagName("a");
for (let link of links) {
let tmpsrc = new URL(link.href);
if (tmpsrc.host == location.host) {
if (
!tmpsrc.pathname.endsWith("html") &&
!tmpsrc.pathname.endsWith("htm") &&
!tmpsrc.pathname.endsWith("php") &&
!tmpsrc.pathname.endsWith("jsp") &&
!tmpsrc.pathname.endsWith("asp") &&
!tmpsrc.pathname.endsWith("aspx") &&
!tmpsrc.pathname.endsWith("atom") &&
!tmpsrc.pathname.endsWith("rss") &&
!tmpsrc.pathname.endsWith("/") &&
tmpsrc.pathname.includes(".")
) {
link.href =
"http://127.0.0.1:7657/i2psnark/" + tmpsrc.host + tmpsrc.pathname;
link.onerror = function () {
window.location.href = tmpsrc.href;
};
}
}
}
}
return response;
}

525
scrub.js
View File

@@ -13,30 +13,14 @@ var contextScrub = async function(requestDetails) {
function onHeaderError() {
console.log('Header scrub error');
}
//console.log("(scrub)Scrubbing info from contextualized request");
try {
var headerScrub = function(context) {
var ua = 'MYOB/6.66 (AN/ON)';
if (!context) {
} else if (context.name == titlepref) {
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,
};
} else if (context.name == routerpref) {
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);
}
for (var header of requestDetails.requestHeaders) {
if (header.name.toLowerCase() === 'user-agent') {
header.value = ua;
}
}
return {
@@ -65,23 +49,10 @@ var contextScrub = async function(requestDetails) {
}
};
if (requestDetails.tabId > 0) {
var tab = {};
var context = {};
var req = {};
if (i2pHost(requestDetails.url)) {
//console.log("(scrub)I2P URL detected, ");
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onHeaderError);
req = await context.then(headerScrub, onHeaderError);
//console.log("(scrub)Scrubbing I2P Request", req);
return req;
} else if (routerHost(requestDetails.url)) {
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onHeaderError);
req = await context.then(headerScrub, onHeaderError);
//console.log("(scrub)Scrubbing non-I2P Request", req);
return req;
}
tab = tabGet(requestDetails.tabId);
context = tab.then(contextGet, onHeaderError);
req = context.then(headerScrub, onHeaderError);
//console.log("(scrub)Scrubbing I2P Request", req);
return req;
}
} catch (error) {
@@ -144,7 +115,6 @@ var contextSetup = function(requestDetails) {
function onContextError() {
console.log('Context launcher error');
}
console.log('(scrub) host', requestDetails.url);
//console.log("(isolate)Forcing I2P requests into context");
try {
var i2pTabFind = async function(tabId) {
@@ -617,57 +587,69 @@ var contextSetup = function(requestDetails) {
if (requestDetails.tabId > 0) {
var tab = tabGet(requestDetails.tabId);
if (i2pHost(requestDetails.url)) {
var thn = i2pHostName(requestDetails.url);
if (requestDetails.url.includes('=' + thn)) {
console.log('(scrub)checking search hostnames =' + thn);
var tpt = requestDetails.url.split('=' + thn, 2);
requestDetails.url =
'http://' + thn + '/' + tpt[1].replace('%2F', '');
}
console.log('(scrub) new hostname', requestDetails.url);
var setcookie = browser.cookies.set({
firstPartyDomain: i2pHostName(requestDetails.url),
url: requestDetails.url,
secure: true,
});
setcookie.then(onContextGotLog, onContextError);
var i2ptab = tab.then(i2pTabFind, onContextError);
return requestDetails;
}
if (extensionHost(requestDetails)) {
return requestDetails;
}
let localhost = localHost(requestDetails.url);
let routerhost = routerHost(requestDetails.url);
if (routerhost) {
if (routerhost === 'i2ptunnelmgr') {
var tunneltab = tab.then(i2ptunnelTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'i2psnark') {
var snarktab = tab.then(snarkTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'webmail') {
var mailtab = tab.then(mailTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'muwire') {
var routertab = tab.then(muwireTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'i2pbote') {
var routertab = tab.then(i2pboteTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'routerconsole') {
var routertab = tab.then(routerTabFind, onContextError);
tab.then(isolate);
function isolate(oldtab) {
// if (oldtab.cookieStoreId == 'firefox-default') {
if (i2pHost(requestDetails.url)) {
var thn = i2pHostName(requestDetails.url);
if (requestDetails.url.includes('=' + thn)) {
if (
!requestDetails.url.includes('github.com') ||
!requestDetails.url.includes('notabug.org') ||
!requestDetails.url.includes('i2pgit.org') ||
!requestDetails.url.includes('gitlab.com')
) {
console.log('(scrub)checking search hostnames =' + thn);
var tpt = requestDetails.url.split('=' + thn, 2);
requestDetails.url =
'http://' + thn + '/' + tpt[1].replace('%2F', '');
}
}
console.log('(scrub) new hostname', requestDetails.url);
var setcookie = browser.cookies.set({
firstPartyDomain: i2pHostName(requestDetails.url),
url: requestDetails.url,
secure: true,
});
setcookie.then(onContextGotLog, onContextError);
var i2ptab = tab.then(i2pTabFind, onContextError);
return requestDetails;
}
} else {
if (localhost) {
var irctab = tab.then(ircTabFind, onContextError);
if (extensionHost(requestDetails)) {
return requestDetails;
}
var normalTab = tab.then(normalTabFind, onContextError);
return requestDetails;
//return requestDetails;
let localhost = localHost(requestDetails.url);
let routerhost = routerHost(requestDetails.url);
if (routerhost) {
if (routerhost === 'i2ptunnelmgr') {
var tunneltab = tab.then(i2ptunnelTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'i2psnark') {
var snarktab = tab.then(snarkTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'webmail') {
var mailtab = tab.then(mailTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'muwire') {
var routertab = tab.then(muwireTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'i2pbote') {
var routertab = tab.then(i2pboteTabFind, onContextError);
return requestDetails;
} else if (routerhost === 'routerconsole') {
var routertab = tab.then(routerTabFind, onContextError);
return requestDetails;
}
} else {
if (localhost) {
var irctab = tab.then(ircTabFind, onContextError);
return requestDetails;
}
var normalTab = tab.then(normalTabFind, onContextError);
return requestDetails;
//return requestDetails;
}
//}
}
}
} catch (error) {
@@ -678,146 +660,108 @@ var contextSetup = function(requestDetails) {
var coolheadersSetup = function(e) {
var asyncSetPageAction = new Promise((resolve, reject) => {
window.setTimeout(() => {
for (i = 0; i < e.responseHeaders.length; i++) {
let header = e.responseHeaders[i];
if (e.url.startsWith('https')) {
if (
header.name.toUpperCase() === 'I2P-LOCATION' ||
header.name.toUpperCase() === 'X-I2P-LOCATION'
) {
browser.pageAction.setPopup({
tabId: e.tabId,
popup: 'location.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
browser.pageAction.setTitle({
tabId: e.tabId,
title: header.value,
});
browser.pageAction.show(e.tabId);
if (e.tabId != undefined) {
popup = browser.pageAction.getPopup({ tabId: e.tabId });
popup.then(gotPopup);
}
function gotPopup(p) {
console.log('(scrub) checking popup', p);
if (p.length != 0) return;
let headers = e.responseHeaders.filter((word) =>
word.name.toUpperCase().includes('I2P')
);
for (i = headers.length - 1; i >= 0; i--) {
let header = headers[i];
console.log('(scrub) checking header', header);
if (header.name.toUpperCase().endsWith('I2P-LOCATION')) {
var tab = browser.tabs.get(e.tabId);
tab.then(altSrc);
function altSrc(tab) {
console.log('(scrub) X-I2P-LOCATION');
let url = new URL(header.value);
browser.pageAction.setPopup({
tabId: e.tabId,
popup: 'location.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
let eurl = new URL(tab.url);
browser.pageAction.setTitle({
tabId: e.tabId,
title: 'http://' + url.host + eurl.pathname,
});
browser.pageAction.show(e.tabId);
}
break;
}
if (
header.name.toUpperCase() === 'I2P-TORRENTLOCATION' ||
header.name.toUpperCase() === 'X-I2P-TORRENTLOCATION'
) {
var imgs = document.getElementsByTagName('img');
for (let img of imgs) {
if (tmpsrc.host == location.host) {
img.src =
'http://127.0.0.1:7657/i2psnark/' +
tmpsrc.host +
tmpsrc.pathname;
img.onerror = function() {
img.src = tmpsrc;
};
}
}
var videos = document.getElementsByTagName('video');
for (let video of videos) {
let tmpsrc = new URL(video.currentSrc);
if (tmpsrc.host == location.host) {
if (!video.innerHTML.includes('127.0.0.1')) {
innerHTML = video.innerHTML;
topInnerHTML = video.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
);
video.innerHTML = topInnerHTML + innerHTML;
} else {
if (header.name.toUpperCase().endsWith('I2P-TORRENTLOCATION')) {
var imgs = document.getElementsByTagName('img');
for (let img of imgs) {
if (tmpsrc.host == location.host) {
img.src =
'http://127.0.0.1:7657/i2psnark/' +
tmpsrc.host +
tmpsrc.pathname;
img.onerror = function() {
img.src = tmpsrc;
};
}
}
}
var audios = document.getElementsByTagName('audio');
for (let audio of audios) {
let tmpsrc = new URL(audio.currentSrc);
if (tmpsrc.host == location.host) {
if (!audio.innerHTML.includes('127.0.0.1')) {
innerHTML = audio.innerHTML;
topInnerHTML = audio.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
);
audio.innerHTML = topInnerHTML + innerHTML;
var videos = document.getElementsByTagName('video');
for (let video of videos) {
let tmpsrc = new URL(video.currentSrc);
if (tmpsrc.host == location.host) {
if (!video.innerHTML.includes('127.0.0.1')) {
innerHTML = video.innerHTML;
topInnerHTML = video.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' +
location.host +
'/'
);
video.innerHTML = topInnerHTML; // + innerHTML;
video.onerror = function() {
video.innerHTML = topInnerHTML + innerHTML;
};
}
}
}
}
browser.pageAction.setPopup({
tabId: tabId.id,
popup: 'torrent.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
browser.pageAction.setTitle({
tabId: e.tabId,
title: header.value,
});
browser.pageAction.show(e.tabId);
break;
}
} else {
if (
header.name.toUpperCase() === 'I2P-TORRENTLOCATION' ||
header.name.toUpperCase() === 'X-I2P-TORRENTLOCATION'
) {
var imgs = document.getElementsByTagName('img');
for (let img of imgs) {
if (tmpsrc.host == location.host) {
img.src =
'http://127.0.0.1:7657/i2psnark/' +
tmpsrc.host +
tmpsrc.pathname;
img.onerror = function() {
img.src = tmpsrc;
};
}
}
var videos = document.getElementsByTagName('video');
for (let video of videos) {
let tmpsrc = new URL(video.currentSrc);
if (tmpsrc.host == location.host) {
if (!video.innerHTML.includes('127.0.0.1')) {
innerHTML = video.innerHTML;
topInnerHTML = video.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
);
video.innerHTML = topInnerHTML + innerHTML;
var audios = document.getElementsByTagName('audio');
for (let audio of audios) {
let tmpsrc = new URL(audio.currentSrc);
if (tmpsrc.host == location.host) {
if (!audio.innerHTML.includes('127.0.0.1')) {
innerHTML = audio.innerHTML;
topInnerHTML = audio.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' +
location.host +
'/'
);
audio.innerHTML = topInnerHTML; // + innerHTML;
audio.onerror = function() {
audio.innerHTML = topInnerHTML + innerHTML;
};
}
}
}
browser.pageAction.setPopup({
tabId: tabId.id,
popup: 'torrent.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
browser.pageAction.setTitle({
tabId: e.tabId,
title: header.value,
});
browser.pageAction.show(e.tabId);
break;
}
var audios = document.getElementsByTagName('audio');
for (let audio of audios) {
let tmpsrc = new URL(audio.currentSrc);
if (tmpsrc.host == location.host) {
if (!audio.innerHTML.includes('127.0.0.1')) {
innerHTML = audio.innerHTML;
topInnerHTML = audio.innerHTML.replace(
'src="',
'src="http://127.0.0.1:7657/i2psnark/' + location.host + '/'
);
audio.innerHTML = topInnerHTML + innerHTML;
}
}
}
browser.pageAction.setPopup({
tabId: tabId.id,
popup: 'torrent.html',
});
browser.pageAction.setIcon({
path: 'icons/i2plogo.png',
tabId: e.tabId,
});
browser.pageAction.setTitle({
tabId: e.tabId,
title: header.value,
});
browser.pageAction.show(e.tabId);
break;
}
}
}
@@ -828,64 +772,84 @@ var coolheadersSetup = function(e) {
};
function getTabURL(tab) {
console.log("(scrub)", tab);
if (tab.url.startsWith("https")) {
browser.tabs
.sendMessage(tab.id, { req: "i2p-location" })
.then((response) => {
if (response.content.toUpperCase() != "NO-ALT-LOCATION") {
browser.pageAction.setPopup({
tabId: tab.id,
popup: "location.html",
});
browser.pageAction.setIcon({
path: "icons/i2plogo.png",
tabId: tab.id,
});
browser.pageAction.setTitle({
tabId: tab.id,
title: response.content,
});
browser.pageAction.show(tab.id);
}
});
console.log("(pageaction)", tab.id, tab.url);
try {
browser.tabs
.sendMessage(tab.id, { req: "i2p-location" })
.then((response) => {
if (response != undefined) {
console.log("(scrub) i2p-location response object", response);
if (response.content.toUpperCase() != "NO-ALT-LOCATION") {
browser.pageAction.setPopup({
tabId: tab.id,
popup: "location.html",
});
browser.pageAction.setIcon({
path: "icons/i2plogo.png",
tabId: tab.id,
});
browser.pageAction.setTitle({
tabId: tab.id,
title: response.content,
});
browser.pageAction.show(tab.id);
}
}
});
console.log("(pageaction)", tab.id, tab.url);
} catch (e) {
console.log("(pageaction)", e);
}
} else {
browser.tabs
.sendMessage(tab.id, { req: "i2p-torrentlocation" })
.then((response) => {
if (response.content.toUpperCase() != "NO-ALT-LOCATION") {
browser.pageAction.setPopup({
tabId: tab.id,
popup: "torrent.html",
});
browser.pageAction.setIcon({
path: "icons/i2plogo.png",
tabId: tab.id,
});
browser.pageAction.setTitle({
tabId: tab.id,
title: response.content,
});
browser.pageAction.show(tab.id);
}
});
console.log("(pageaction)", tab.id, tab.url);
try {
browser.tabs
.sendMessage(tab.id, { req: "i2p-torrentlocation" })
.then((response) => {
if (response != undefined) {
console.log("(scrub) i2p-location response object", response);
if (response.content.toUpperCase() != "NO-ALT-LOCATION") {
browser.pageAction.setPopup({
tabId: tab.id,
popup: "torrent.html",
});
browser.pageAction.setIcon({
path: "icons/i2plogo.png",
tabId: tab.id,
});
browser.pageAction.setTitle({
tabId: tab.id,
title: response.content,
});
browser.pageAction.show(tab.id);
}
}
});
console.log("(pageaction)", tab.id, tab.url);
} catch (e) {
console.log("(pageaction)", e);
}
}
}
function getClearTab(tobj) {
if (typeof tobj == "number") {
browser.tabs.get(tobj).then(getTabURL, onError);
}
if (typeof tobj.tabId == "number") {
console.log("(scrub) tobj", tobj);
browser.tabs.get(tobj.tabId).then(getTabURL, onError);
} else {
for (let tab in tobj.tabIds) {
console.log("(scrub) tab", tobj, tab, tobj.tabIds[tab]);
browser.tabs.get(tobj.tabIds[tab]).then(getTabURL, onError);
function setupTabs(tobj) {
if (typeof tobj == "number") {
browser.tabs.get(tobj).then(getTabURL, onError);
}
if (typeof tobj.tabId == "number") {
console.log("(scrub) tobj", tobj);
browser.tabs.get(tobj.tabId).then(getTabURL, onError);
} else {
for (let tab in tobj.tabIds) {
console.log("(scrub) tab", tobj.tabIds[tab]);
browser.tabs.get(tobj.tabIds[tab]).then(getTabURL, onError);
}
}
}
if (tobj != undefined) {
setupTabs(tobj);
} else {
browser.tabs.query({}).then(setupTabs);
}
}
@@ -897,18 +861,15 @@ function logOnDOMContentLoaded(details) {
console.log(`onDOMContentLoaded: ${details.url}`);
}
browser.webNavigation.onDOMContentLoaded.addListener(getClearTab, filter);
browser.tabs.onActivated.addListener(getClearTab);
browser.tabs.onUpdated.addListener(getClearTab);
browser.tabs.onAttached.addListener(getClearTab);
browser.tabs.onCreated.addListener(getClearTab);
browser.tabs.onDetached.addListener(getClearTab);
browser.tabs.onHighlighted.addListener(getClearTab);
browser.tabs.onMoved.addListener(getClearTab);
browser.tabs.onRemoved.addListener(getClearTab);
browser.tabs.onReplaced.addListener(getClearTab);
browser.tabs.onZoomChange.addListener(getClearTab);
browser.pageAction.onClicked.addListener(getClearTab);
function reloadTabs(tabs) {
for (let tab of tabs) {
@@ -927,20 +888,22 @@ querying.then(reloadTabs, onError);
// Set "blocking" and "responseHeaders".
browser.webRequest.onHeadersReceived.addListener(
coolheadersSetup,
{ urls: ["<all_urls>"] },
{ urls: ["*://*.i2p/*", "https://*/*"] },
["responseHeaders"]
);
//browser.webNavigation.onDOMContentLoaded.addListener(getClearTab)
browser.webRequest.onBeforeRequest.addListener(
contextSetup,
{ urls: ["<all_urls>"] },
["blocking"]
browser.webNavigation.onDOMContentLoaded.addListener(getClearTab, filter);
browser.webNavigation.onDOMContentLoaded.addListener(
logOnDOMContentLoaded,
filter
);
browser.webRequest.onBeforeRequest.addListener(contextSetup, {
urls: ["*://*.i2p/*", "*://localhost/*", "*://127.0.0.1/*", "*://*/*i2p*"],
});
browser.webRequest.onBeforeSendHeaders.addListener(
contextScrub,
{ urls: ["<all_urls>"] },
["blocking", "requestHeaders"]
{ urls: ["*://*.i2p/*"] },
["requestHeaders"]
);

View File

@@ -3,8 +3,7 @@
<head>
<meta charset="utf-8">
<link href="search.css" rel="stylesheet">
<link href="home.css" rel="stylesheet">
<link href="info.css" rel="stylesheet"><!--<link href="torrent/popup.css" rel="stylesheet">-->
<link href="home.css" rel="stylesheet"><!--<link href="info.css" rel="stylesheet">--><!--<link href="torrent/popup.css" rel="stylesheet">-->
<title>
</title>

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8">
<link href="search.css" rel="stylesheet">
<link href="home.css" rel="stylesheet">
<link href="info.css" rel="stylesheet"><!--<link href="torrent/popup.css" rel="stylesheet">-->
<!--<link href="info.css" rel="stylesheet">--><!--<link href="torrent/popup.css" rel="stylesheet">-->
<title>
</title>