improvements to TBB compatibility

This commit is contained in:
eyedeekay
2024-10-07 14:15:26 -04:00
parent b46abac574
commit b7bbcf4e4b
8 changed files with 148 additions and 84 deletions

View File

@ -6,23 +6,23 @@ Extension Versions
```md
i2p-in-private-browsing
2.6.0
https://addons.mozilla.org/firefox/downloads/file/4339795/i2p_in_private_browsing-2.6.0.xpi
2.7.0
https://addons.mozilla.org/firefox/downloads/file/4364373/i2p_in_private_browsing-2.7.0.xpi
noscript
11.4.34
https://addons.mozilla.org/firefox/downloads/file/4333280/noscript-11.4.34.xpi
11.4.40
https://addons.mozilla.org/firefox/downloads/file/4357325/noscript-11.4.40.xpi
localcdn-fork-of-decentraleyes
2.6.72
https://addons.mozilla.org/firefox/downloads/file/4336546/localcdn_fork_of_decentraleyes-2.6.72.xpi
2.6.73
https://addons.mozilla.org/firefox/downloads/file/4349721/localcdn_fork_of_decentraleyes-2.6.73.xpi
onion-in-container-browsing
0.82
https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi
javascript-restrictor
0.19
https://addons.mozilla.org/firefox/downloads/file/4339678/javascript_restrictor-0.19.xpi
0.19.1
https://addons.mozilla.org/firefox/downloads/file/4352350/javascript_restrictor-0.19.1.xpi
ublock-origin
1.59.0
https://addons.mozilla.org/firefox/downloads/file/4328681/ublock_origin-1.59.0.xpi
1.60.0
https://addons.mozilla.org/firefox/downloads/file/4359936/ublock_origin-1.60.0.xpi
```
## Chromium
@ -32,15 +32,15 @@ __MSG_extensionName__
1.29
https://clients2.google.com/service/update2/crx
NoScript
11.4.33
11.4.42
https://clients2.google.com/service/update2/crx
LocalCDN
2.6.72
2.6.73
https://clients2.google.com/service/update2/crx
uBlock Origin
1.59.0
1.60.0
https://clients2.google.com/service/update2/crx
__MSG_extensionName__
0.19
0.19.1
https://clients2.google.com/service/update2/crx
```

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Aug 20 23:41:03 EDT 2024
build.number=746
#Mon Oct 07 14:09:22 EDT 2024
build.number=769

View File

@ -391,6 +391,12 @@ public class I2PCommonBrowser {
}
}
protected void makeDirectory(File destDir) {
logger.info("creating directory");
if (!destDir.exists())
destDir.mkdir();
}
/**
* Copy a directory in compatibility mode.
*

View File

@ -1,9 +1,11 @@
package net.i2p.i2pfirefox;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
@ -124,6 +126,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
}
return exePath;
}
public String[] firefoxPathsOSX() {
String firefoxPathsProp = getProperties().getProperty("firefox.paths.osx");
if (firefoxPathsProp != null)
@ -134,6 +137,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
"/Applications/Waterfox.app/Contents/MacOS",
"/Applications/Librewolf.app/Contents/MacOS"};
}
private String[] FIND_FIREFOX_SEARCH_PATHS_OSX() {
String[] path = firefoxPathsOSX();
String[] exes = firefoxBinsUnix();
@ -147,6 +151,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
}
return exePath;
}
public String[] firefoxPathsWindows() {
String firefoxPathsProp =
getProperties().getProperty("firefox.paths.windows");
@ -181,6 +186,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
new File(programFiles, "Librewolf/").toString(),
};
}
private String[] firefoxBinsWindows() {
String firefoxPathsProp =
getProperties().getProperty("firefox.bins.windows");
@ -192,6 +198,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
"waterfox.exe", "waterfox-bin.exe", "librewolf.exe",
};
}
private String[] FIND_FIREFOX_SEARCH_PATHS_WINDOWS() {
String[] path = firefoxPathsWindows();
String[] exes = firefoxBinsWindows();
@ -226,6 +233,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
}
return exePath;
}
private String[] FIND_FIREFOX_SEARCH_PATHS() {
switch (getOperatingSystem()) {
case "Windows":
@ -337,6 +345,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
return new String[] {};
}
private String[] FIREFOX_FINDER() {
String[] nearby = NEARBY_FIREFOX_SEARCH_PATHS();
String[] all = FIND_FIREFOX_SEARCH_PATHS();
@ -366,8 +375,9 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
if (firefoxFile.exists()) {
logger.info("Found valid firefox at " + firefox);
validFirefoxes.add(firefox);
}else{
logger.info("firefox at " + firefox + "does not exist");
}
logger.info("firefox at " + firefox + "does not exist");
}
return validFirefoxes.toArray(new String[validFirefoxes.size()]);
}
@ -376,7 +386,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
* Return the best available Firefox from the list of Firefoxes we have.
*
* @return the path to the best available Firefox, or null if none are
* found.
* found.
* @since 0.0.1
*/
public String topFirefox() {
@ -411,7 +421,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param override the path to a valid Firefox binary to use.
* @return the path to the best available Firefox, or null if none are
* found.
* found.
* @since 0.0.1
*/
public String topFirefox(String overrideFirefox) {
@ -429,7 +439,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
* the default profile.
*
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
* @since 0.0.1
*/
public ProcessBuilder defaultProcessBuilder() {
@ -442,7 +452,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the args to pass to the Firefox binary
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
*/
public ProcessBuilder defaultProcessBuilder(String[] args) {
return processBuilder(args, false);
@ -455,7 +465,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the arguments to pass to the Firefox binary.
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
* @since 0.0.1
*/
public ProcessBuilder privateProcessBuilder() {
@ -469,7 +479,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the arguments to pass to the Firefox binary
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
*/
public ProcessBuilder privateProcessBuilder(String[] args) {
ArrayList<String> argList = new ArrayList<String>();
@ -491,7 +501,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the arguments to pass to the Firefox binary.
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
* @since 0.0.1
*/
public ProcessBuilder appProcessBuilder() {
@ -505,7 +515,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the arguments to pass to the Firefox binary
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
*/
public ProcessBuilder appProcessBuilder(String[] args) {
ArrayList<String> argList = new ArrayList<String>();
@ -526,7 +536,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the arguments to pass to the Firefox binary
* @return a ProcessBuilder for the top Firefox binary and
* the default profile.
* the default profile.
*/
public ProcessBuilder headlessProcessBuilder(String[] args) {
ArrayList<String> argList = new ArrayList<String>();
@ -548,14 +558,14 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
*
* @param args the extended arguments to pass to the Firefox binary.
* @return a ProcessBuilder for the top Firefox binary and
* default profile, with a specific set of extended arguments.
* default profile, with a specific set of extended arguments.
* @since 0.0.1
*/
/*
public ProcessBuilder processBuilder(String[] args ) {
return processBuilder(args, false);
}
*/
* public ProcessBuilder processBuilder(String[] args ) {
* return processBuilder(args, false);
* }
*/
public ProcessBuilder processBuilder(String[] args, boolean app) {
String firefox = topFirefox();
if (!firefox.isEmpty()) {
@ -683,7 +693,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
pb.environment().put("TOR_SKIP_CONTROLPORTTEST", "1");
pb.environment().put("TOR_NONTOR_PROXY", "1");
return pb;
//}
// }
// return null;
}
@ -693,12 +703,14 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
}
return "base";
}
public Process launchAndDetatch(boolean privateWindow, String[] url) {
int privateWindowInt = 0;
if (privateWindow)
privateWindowInt = 1;
return launchAndDetatch(privateWindowInt, url);
}
public Process launchAndDetatch(int privateWindow, String[] url) {
validateUserDirectory();
boolean app = false;
@ -706,12 +718,13 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
app = true;
if (waitForProxy()) {
String profileDirectory = this.profileDirectory(app, baseMode());
if (this.validateProfileDirectory(profileDirectory)) {
if (this.validateProfileDirectory(profileDirectory) && !isTorBrowser()) {
logger.info("Valid profile directory: " + profileDirectory);
} else {
logger.info("Invalid profile directory: " + profileDirectory +
" rebuilding...");
if (!this.copyBaseProfiletoProfile(usabilityMode(), app)) {
if (!this.copyBaseProfiletoProfile(usabilityMode(), app,
isTorBrowser())) {
logger.info("Failed to rebuild profile directory: " +
profileDirectory);
return null;
@ -720,7 +733,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
}
}
if (validateProfileFirstRun(profileDirectory)) {
if (isWindows()) {
if (isWindows() && !isTorBrowser()) {
ProcessBuilder hpb = headlessProcessBuilder(url);
try {
Process hp = hpb.start();
@ -786,8 +799,8 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
* Waits for an HTTP proxy on the port 4444 to be ready.
* Launches Firefox with the profile directory.
*
* @param bool if true, the profile will be ephemeral(i.e. a
* --private-window profile).
* @param bool if true, the profile will be ephemeral(i.e. a
* --private-window profile).
* @param String[] a list of URL's to pass to the browser window
* @since 0.0.17
*/
@ -797,6 +810,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
priv = 1;
launch(priv, url);
}
public void launch(int privateWindow, String[] url) {
if (waitForProxy()) {
process = launchAndDetatch(privateWindow, url);
@ -820,7 +834,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
* Launches Firefox with the profile directory.
*
* @param bool if true, the profile will be ephemeral(i.e. a
* --private-window profile).
* --private-window profile).
* @since 0.0.1
*/
public void launch(boolean privateWindow) { launch(privateWindow, null); }
@ -902,12 +916,40 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
visitURL.toArray(new String[visitURL.size()]));
}
/*private void sleep(int millis) {
public boolean isTorBrowser() {
String[] args = {"--version"};
ProcessBuilder tpb = defaultProcessBuilder(args);
try {
Thread.sleep(millis);
} catch (InterruptedException bad) {
bad.printStackTrace();
throw new RuntimeException(bad);
Process tp = tpb.start();
BufferedReader reader =
new BufferedReader(new InputStreamReader(tp.getInputStream()));
StringBuilder builder = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
builder.append(line);
builder.append(System.getProperty("line.separator"));
}
String result = builder.toString().toLowerCase();
if (result.contains("tor ")) {
logger.info("running in Tor Browser, modifying only required config");
return true;
} else {
logger.info("running in regular Firefox, using extended config");
return false;
}
} catch (Exception e) {
return false;
}
}*/
}
/*
* private void sleep(int millis) {s
* try {
* Thread.sleep(millis);
* } catch (InterruptedException bad) {
* bad.printStackTrace();
* throw new RuntimeException(bad);
* }
* }
*/
}

View File

@ -25,6 +25,7 @@ import java.nio.file.StandardCopyOption;
*/
public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
private boolean strict;
private String userChromeCSS() {
String ret =
"@namespace url(\"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\")\n";
@ -99,18 +100,22 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
* @return the profile directory, or null if it could not be created
*/
// public String profileDirectory() {
// return profileDirectory("I2P_FIREFOX_PROFILE", "firefox", false);
// return profileDirectory("I2P_FIREFOX_PROFILE", "firefox", false);
// }
private String baseProfileDir(String file, String base) {
private String baseProfileDir(String file, String base,
boolean isTorBrowser) {
File profileDir = new File(file, "i2p.firefox." + base + ".profile");
// make sure the directory exists
if (profileDir.exists()) {
return profileDir.getAbsolutePath();
} else {
// create the directory
if (!this.unpackProfile(profileDir.getAbsolutePath(), "firefox", base)) {
return null;
if (!isTorBrowser) {
if (!this.unpackProfile(profileDir.getAbsolutePath(), "firefox",
base)) {
return null;
}
}
return profileDir.getAbsolutePath();
}
@ -121,7 +126,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
*
* @return the base profile directory, or null if it could not be created
*/
public String baseProfileDirectory(String base) {
public String baseProfileDirectory(String base, boolean isTorBrowser) {
String pd = System.getenv("I2P_FIREFOX_BASE_PROFILE");
if (pd != null && !pd.isEmpty()) {
File pdf = new File(pd);
@ -134,7 +139,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
}
}
String rtd = runtimeDirectory();
return baseProfileDir(rtd, base);
return baseProfileDir(rtd, base, isTorBrowser);
}
/**
@ -175,11 +180,10 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
*
* @since 0.0.1
*/
public boolean copyBaseProfiletoProfile(String base, boolean app) {
String baseProfile = baseProfileDirectory(base);
public boolean copyBaseProfiletoProfile(String base, boolean app,
boolean isTorBrowser) {
String baseProfile = baseProfileDirectory(base, isTorBrowser);
String profile = profileDirectory(app, base);
logger.info("Copying base profile to profile directory: " + baseProfile +
" -> " + profile);
if (baseProfile.isEmpty() || profile.isEmpty()) {
return false;
}
@ -188,24 +192,31 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
if (!profileDir.exists()) {
try {
logger.info("Copying base profile to profile directory");
copyDirectory(baseProfileDir, profileDir, "firefox", base);
if (!isTorBrowser) {
logger.info("Copying base profile to profile directory: " +
baseProfile + " -> " + profile);
copyDirectory(baseProfileDir, profileDir, "firefox", base);
} else {
logger.info("Creating base directory for use with Tor Browser");
makeDirectory(profileDir);
}
logger.info("Copied base profile to profile directory");
return true;
} catch (Exception e) {
logger.info("Error copying base profile to profile" + e);
return false;
}
logger.info("Copied base profile to profile directory");
}
// if user.js does not exist yet, make an empty one.
// if (!touch(profileDir.toString(), "user.js")) {
// return false;
//}
// }
// if extensions does not exist yet, make an empty one.
// if (!mkExtensionsDir(profileDir.toString())){
// return false;
//}
// }
return copyStrictOptions(base, app);
return copyStrictOptions(base, app, isTorBrowser);
}
protected boolean writeAppChrome(String profile) {
@ -221,6 +232,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
}
return true;
}
protected boolean deleteAppChrome(String profile) {
File dir = new File(profile, "chrome");
if (!dir.exists())
@ -230,15 +242,17 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
f.delete();
return true;
}
/**
* Copy the strict options from the base profile to the profile
*
* @return true if successful, false otherwise
* @since 0.0.1
*/
public boolean copyStrictOptions(String base, boolean app) {
public boolean copyStrictOptions(String base, boolean app,
boolean isTorBrowser) {
logger.info("Checking strict options");
String baseProfile = baseProfileDirectory(base);
String baseProfile = baseProfileDirectory(base, isTorBrowser);
String profile = profileDirectory(app, base);
if (baseProfile.isEmpty() || profile.isEmpty()) {
logger.info("Empty paths");
@ -324,6 +338,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
/**
* Construct a new Profile Builder
*
* @param strict if true, the strict overrides will be copied to the profile
*
* @since 0.0.1

View File

@ -190,8 +190,8 @@ public class I2PBrowserPlugin extends I2PBrowser implements ClientApp {
// Ubuntu GNOME does not work, SystemTray.isSupported() returns false
String xdg = System.getenv("XDG_CURRENT_DESKTOP");
boolean dflt = SystemVersion.isWindows() || SystemVersion.isMac() ||
"XFCE".equals(xdg) ||
"KDE".equals(xdg) || "LXDE".equals(xdg);
"XFCE".equals(xdg) || "KDE".equals(xdg) ||
"LXDE".equals(xdg);
return _context.getProperty(PROP_DTG_ENABLED, dflt);
}

View File

@ -19,11 +19,6 @@ user_pref("extensions.torlauncher.start_tor", false);
//user_pref("extensions.torlauncher.default_bridge_type", "");
user_pref("extensions.torlauncher.prompt_at_startup", false);
// Resist-fingerprinting and first-party isolation enable
user_pref("privacy.resistFingerprinting", true);
user_pref("privacy.firstparty.isolate", true);
// Use i2p http proxy for all connections and set homepage to safe local form.
// DON'T allow access to the admin panel from the profile we browse i2p with.
@ -39,7 +34,6 @@ user_pref("network.proxy.socks", "127.0.0.1");
user_pref("network.proxy.socks_port", 4444);
user_pref("network.proxy.share_proxy_settings", true);
user_pref("browser.startup.homepage", "about:blank");
user_pref("dom.security.https_only_mode", false);
user_pref("keyword.enabled", false);
user_pref("extensions.allowPrivateBrowsingByDefault", true);
user_pref("extensions.PrivateBrowsing.notification", false);
@ -51,17 +45,4 @@ user_pref("browser.newtabpage.activity-stream.feeds.section.highlights", false);
user_pref("browser.newtabpage.activity-stream.feeds.section.topstories", false);
user_pref("browser.newtabpage.activity-stream.default.sites", "http://planet.i2p/,http://legwork.i2p/,http://i2pwiki.i2p/,http://i2pforums.i2p/,http://zzz.i2p/");
user_pref("browser.newtabpage.activity-stream.feeds.topsites", true);
user_pref("ui.use_standins_for_native_colors", true);
user_pref("webgl.disable-extensions", true);
user_pref("webgl.min_capability_mode", true);
user_pref("webgl.disable-fail-if-major-performance-caveat", true);
user_pref("webgl.enable-webgl2", false);
user_pref("media.navigator.enabled", false);
user_pref("dom.w3c_touch_events.enabled", false);
user_pref("browser.privatebrowsing.autostart", false);
user_pref("browser.display.use_system_colors", false);
user_pref("dom.image-lazy-loading.enabled", false);
user_pref("extensions.autoDisableScopes", 0);
user_pref("extensions.enabledScopes", 1);
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", false);
user_pref("browser.fixup.domainsuffixwhitelist.i2p", true);

View File

@ -228,4 +228,24 @@ user_pref("dom.w3c_touch_events.enabled", false);
user_pref("browser.privatebrowsing.autostart", false);
user_pref("browser.display.use_system_colors", false);
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", false);
user_pref("browser.fixup.domainsuffixwhitelist.i2p", true);
user_pref("browser.fixup.domainsuffixwhitelist.i2p", true);
user_pref("ui.use_standins_for_native_colors", true);
user_pref("webgl.disable-extensions", true);
user_pref("webgl.min_capability_mode", true);
user_pref("webgl.disable-fail-if-major-performance-caveat", true);
user_pref("webgl.enable-webgl2", false);
user_pref("media.navigator.enabled", false);
user_pref("dom.w3c_touch_events.enabled", false);
user_pref("browser.privatebrowsing.autostart", false);
user_pref("browser.display.use_system_colors", false);
user_pref("dom.image-lazy-loading.enabled", false);
user_pref("extensions.autoDisableScopes", 0);
user_pref("extensions.enabledScopes", 1);
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", false);
user_pref("dom.security.https_only_mode", false);
// Resist-fingerprinting and first-party isolation enable
user_pref("privacy.resistFingerprinting", true);
user_pref("privacy.firstparty.isolate", true);