Alter TBB less when it's discovered

This commit is contained in:
eyedeekay
2024-10-18 23:59:30 -04:00
parent b7bbcf4e4b
commit 1bc9894616
5 changed files with 69 additions and 27 deletions

View File

@ -9,11 +9,11 @@ i2p-in-private-browsing
2.7.0
https://addons.mozilla.org/firefox/downloads/file/4364373/i2p_in_private_browsing-2.7.0.xpi
noscript
11.4.40
https://addons.mozilla.org/firefox/downloads/file/4357325/noscript-11.4.40.xpi
11.4.42
https://addons.mozilla.org/firefox/downloads/file/4363712/noscript-11.4.42.xpi
localcdn-fork-of-decentraleyes
2.6.73
https://addons.mozilla.org/firefox/downloads/file/4349721/localcdn_fork_of_decentraleyes-2.6.73.xpi
2.6.74
https://addons.mozilla.org/firefox/downloads/file/4364493/localcdn_fork_of_decentraleyes-2.6.74.xpi
onion-in-container-browsing
0.82
https://addons.mozilla.org/firefox/downloads/file/3904685/onion_in_container_browsing-0.82.xpi

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Oct 07 14:09:22 EDT 2024
build.number=769
#Fri Oct 18 23:29:32 EDT 2024
build.number=792

View File

@ -391,12 +391,6 @@ public class I2PCommonBrowser {
}
}
protected void makeDirectory(File destDir) {
logger.info("creating directory");
if (!destDir.exists())
destDir.mkdir();
}
/**
* Copy a directory in compatibility mode.
*
@ -440,7 +434,7 @@ public class I2PCommonBrowser {
* copied to
* @throws IOException if an I/O error occurs during the file copy process
*/
private void copyFile(File sourceFile, File destinationFile)
public void copyFile(File sourceFile, File destinationFile)
throws IOException {
try (InputStream in = new FileInputStream(sourceFile);
OutputStream out = new FileOutputStream(destinationFile)) {

View File

@ -375,7 +375,7 @@ public class I2PFirefox extends I2PFirefoxProfileBuilder {
if (firefoxFile.exists()) {
logger.info("Found valid firefox at " + firefox);
validFirefoxes.add(firefox);
}else{
} else {
logger.info("firefox at " + firefox + "does not exist");
}
}

View File

@ -1,6 +1,7 @@
package net.i2p.i2pfirefox;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
@ -27,8 +28,7 @@ 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";
String ret = "@namespace url(\"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul\")\n";
/* only needed once */
@ -104,7 +104,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
// }
private String baseProfileDir(String file, String base,
boolean isTorBrowser) {
boolean isTorBrowser) {
File profileDir = new File(file, "i2p.firefox." + base + ".profile");
// make sure the directory exists
if (profileDir.exists()) {
@ -113,9 +113,11 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
// create the directory
if (!isTorBrowser) {
if (!this.unpackProfile(profileDir.getAbsolutePath(), "firefox",
base)) {
base)) {
return null;
}
} else {
makeTBBDirectory(profileDir, profileDir);
}
return profileDir.getAbsolutePath();
}
@ -181,7 +183,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
* @since 0.0.1
*/
public boolean copyBaseProfiletoProfile(String base, boolean app,
boolean isTorBrowser) {
boolean isTorBrowser) {
String baseProfile = baseProfileDirectory(base, isTorBrowser);
String profile = profileDirectory(app, base);
if (baseProfile.isEmpty() || profile.isEmpty()) {
@ -194,11 +196,11 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
try {
if (!isTorBrowser) {
logger.info("Copying base profile to profile directory: " +
baseProfile + " -> " + profile);
baseProfile + " -> " + profile);
copyDirectory(baseProfileDir, profileDir, "firefox", base);
} else {
logger.info("Creating base directory for use with Tor Browser");
makeDirectory(profileDir);
makeTBBDirectory(baseProfileDir, profileDir);
}
logger.info("Copied base profile to profile directory");
return true;
@ -250,7 +252,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
* @since 0.0.1
*/
public boolean copyStrictOptions(String base, boolean app,
boolean isTorBrowser) {
boolean isTorBrowser) {
logger.info("Checking strict options");
String baseProfile = baseProfileDirectory(base, isTorBrowser);
String profile = profileDirectory(app, base);
@ -261,8 +263,8 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
File baseProfileDir = new File(baseProfile);
File profileDir = new File(profile);
setupUserChrome(profileDir, app);
if (!baseProfileDir.exists() || !profileDir.exists()) {
logger.info("Empty directories");
if (!baseProfileDir.exists()) {
logger.info("Empty base directories: " + baseProfileDir);
return false;
}
File baseOverrides = new File(baseProfile, "strict-overrides.js");
@ -272,7 +274,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
if (strict) {
logger.info("Enabling strict options");
Files.copy(baseOverrides.toPath(), userOverrides.toPath(),
StandardCopyOption.REPLACE_EXISTING);
StandardCopyOption.REPLACE_EXISTING);
return true;
}
}
@ -329,12 +331,56 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
}
}
private String TBB_BASE = "user_pref(\"extensions.torbutton.use_nontor_proxy\", true);\n"
+ "user_pref(\"extensions.torlauncher.start_tor\", false);\n"
+ "user_pref(\"extensions.torlauncher.prompt_at_startup\", false);\n"
+ "user_pref(\"network.proxy.no_proxies_on\", \"127.0.0.1:7657,localhost:7657,127.0.0.1:7662,localhost:7662,127.0.0.1:7669,localhost:7669\");\n"
+ "user_pref(\"network.proxy.type\", 1);\n"
+ "user_pref(\"network.proxy.http\", \"127.0.0.1\");\n"
+ "user_pref(\"network.proxy.http_port\", 4444);\n"
+ "user_pref(\"network.proxy.ssl\", \"127.0.0.1\");\n"
+ "user_pref(\"network.proxy.ssl_port\", 4444);\n"
+ "user_pref(\"network.proxy.ftp\", \"127.0.0.1\");"
+ "user_pref(\"network.proxy.ftp_port\", 4444);\n"
+ "user_pref(\"network.proxy.socks\", \"127.0.0.1\");\n"
+ "user_pref(\"network.proxy.socks_port\", 4444);\n"
+ "user_pref(\"network.proxy.share_proxy_settings\", true);\n"
+ "user_pref(\"browser.startup.homepage\", \"about:blank\");\n"
+ "user_pref(\"keyword.enabled\", false);\n"
+ "user_pref(\"extensions.allowPrivateBrowsingByDefault\", true);\n"
+ "user_pref(\"extensions.PrivateBrowsing.notification\", false);\n"
+ "user_pref(\"extensions.pocket.enabled\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.showSponsoredTopSites\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.showSponsored\", false);\n"
+ "user_pref(\"services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsored\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.feeds.section.highlights\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.feeds.section.topstories\", false);\n"
+ "user_pref(\"browser.newtabpage.activity-stream.default.sites\", \"http://planet.i2p/,http://legwork.i2p/,http://i2pwiki.i2p/,http://i2pforums.i2p/,http://zzz.i2p/\");\n"
+ "user_pref(\"browser.newtabpage.activity-stream.feeds.topsites\", true);\n"
+ "user_pref(\"browser.fixup.domainsuffixwhitelist.i2p\", true);\n";
protected void makeTBBDirectory(File sourceDir, File destDir) {
logger.info("creating TBB directory");
if (!destDir.exists())
destDir.mkdir();
File workUserJs = new File(destDir, "user.js");
// Write the value of TBB_BASE to the file workUserJs
try (FileWriter writer = new FileWriter(workUserJs)) {
logger.info("writing TBB user.js");
writer.write(TBB_BASE);
} catch (IOException e) {
logger.info("Error writing to file: " + e.getMessage());
}
}
/**
* Construct a new Profile Builder
*
* @since 0.0.1
*/
public I2PFirefoxProfileBuilder() { this.strict = false; }
public I2PFirefoxProfileBuilder() {
this.strict = false;
}
/**
* Construct a new Profile Builder
@ -343,5 +389,7 @@ public class I2PFirefoxProfileBuilder extends I2PFirefoxProfileChecker {
*
* @since 0.0.1
*/
public I2PFirefoxProfileBuilder(boolean strict) { this.strict = strict; }
public I2PFirefoxProfileBuilder(boolean strict) {
this.strict = strict;
}
}