add usability mode for Firefox
Former-commit-id: d7769d4320
Former-commit-id: 65d762f837a781302719bb90f55f7efe80a7a479
This commit is contained in:
@ -9,7 +9,7 @@ A port of the batch scripts from i2p.firefox to Java.
|
||||
```sh
|
||||
|
||||
mkdir ~/tmp-i2pfirefox && cd ~/tmp-i2pfirefox
|
||||
wget https://github.com/eyedeekay/i2p.plugins.firefox/releases/download/0.0.10/i2pfirefox.zip
|
||||
wget https://github.com/eyedeekay/i2p.plugins.firefox/releases/download/0.0.16/i2pfirefox.zip
|
||||
unzip i2pfirefox.zip
|
||||
./i2pfirefox.cmd
|
||||
|
||||
|
@ -345,6 +345,7 @@ Linux(because the top command will be run and the script will exit).\n\nBoth det
|
||||
<fileset dir="." includes="*/*.~ **/*.*~ */**/*.*~ *.*~" />
|
||||
</delete>
|
||||
<delete dir="i2p.firefox.base.profile" />
|
||||
<delete dir="i2p.firefox.usability.profile" />
|
||||
<delete dir="i2p.firefox.profile" />
|
||||
<delete dir="src/i2p.firefox.profile.zip" />
|
||||
<delete dir="i2p.chromium.base.profile" />
|
||||
|
@ -120,7 +120,7 @@ public class I2PChromiumProfileBuilder extends I2PCommonBrowser {
|
||||
|
||||
try {
|
||||
System.out.println("Copying base profile to profile directory");
|
||||
copyDirectory(baseProfileDir, profileDir, "chromium");
|
||||
copyDirectory(baseProfileDir, profileDir, "chromium", "base");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error copying base profile to profile" + e);
|
||||
return false;
|
||||
|
@ -148,24 +148,26 @@ public class I2PCommonBrowser {
|
||||
}
|
||||
|
||||
protected static void copyDirectory(File sourceDirectory,
|
||||
File destinationDirectory, String browser)
|
||||
throws IOException {
|
||||
File destinationDirectory, String browser,
|
||||
String base) throws IOException {
|
||||
destinationDirectory = new File(destinationDirectory.toString().replace(
|
||||
"i2p." + browser + ".base.profile", ""));
|
||||
"i2p." + browser + "." + base + ".profile", ""));
|
||||
if (!destinationDirectory.exists()) {
|
||||
destinationDirectory.mkdir();
|
||||
}
|
||||
for (String f : sourceDirectory.list()) {
|
||||
copyDirectoryCompatibityMode(new File(sourceDirectory, f),
|
||||
new File(destinationDirectory, f), browser);
|
||||
new File(destinationDirectory, f), browser,
|
||||
base);
|
||||
}
|
||||
}
|
||||
|
||||
private static void
|
||||
copyDirectoryCompatibityMode(File source, File destination, String browser)
|
||||
private static void copyDirectoryCompatibityMode(File source,
|
||||
File destination,
|
||||
String browser, String base)
|
||||
throws IOException {
|
||||
if (source.isDirectory()) {
|
||||
copyDirectory(source, destination, browser);
|
||||
copyDirectory(source, destination, browser, base);
|
||||
} else {
|
||||
copyFile(source, destination);
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ public class I2PFirefox {
|
||||
private final String[] FIREFOX_SEARCH_PATHS = FIREFOX_FINDER();
|
||||
private final int DEFAULT_TIMEOUT = 200;
|
||||
private Process p = null;
|
||||
private static boolean usability = false;
|
||||
|
||||
/**
|
||||
* Construct an I2PFirefox class which manages an instance of Firefox and
|
||||
@ -443,6 +444,13 @@ public class I2PFirefox {
|
||||
}
|
||||
}
|
||||
|
||||
private String usabilityMode() {
|
||||
if (usability) {
|
||||
return "usability";
|
||||
}
|
||||
return "base";
|
||||
}
|
||||
|
||||
public Process launchAndDetatch(boolean privateWindow, String[] url) {
|
||||
if (waitForProxy()) {
|
||||
String profileDirectory = I2PFirefoxProfileBuilder.profileDirectory();
|
||||
@ -451,7 +459,8 @@ public class I2PFirefox {
|
||||
} else {
|
||||
System.out.println("Invalid profile directory: " + profileDirectory +
|
||||
" rebuilding...");
|
||||
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile()) {
|
||||
if (!I2PFirefoxProfileBuilder.copyBaseProfiletoProfile(
|
||||
usabilityMode())) {
|
||||
System.out.println("Failed to rebuild profile directory: " +
|
||||
profileDirectory);
|
||||
return null;
|
||||
@ -544,6 +553,9 @@ public class I2PFirefox {
|
||||
System.out.println(
|
||||
"private browsing is true, profile will be discarded at end of session");
|
||||
}
|
||||
if (arg.equals("-usability")) {
|
||||
usability = true;
|
||||
}
|
||||
if (!arg.startsWith("-")) {
|
||||
// check if it's a URL
|
||||
visitURL.add(ValidURL(arg));
|
||||
|
@ -34,15 +34,15 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
return profileDirectory("I2P_FIREFOX_PROFILE", "firefox");
|
||||
}
|
||||
|
||||
private static String baseProfileDir(String file) {
|
||||
File profileDir = new File(file, "i2p.firefox.base.profile");
|
||||
private static String baseProfileDir(String file, String base) {
|
||||
File profileDir = new File(file, "i2p.firefox." + base + ".profile");
|
||||
// make sure the directory exists
|
||||
if (profileDir.exists()) {
|
||||
return profileDir.getAbsolutePath();
|
||||
} else {
|
||||
// create the directory
|
||||
I2PFirefoxProfileUnpacker unpacker = new I2PFirefoxProfileUnpacker();
|
||||
if (!unpacker.unpackProfile(profileDir.getAbsolutePath())) {
|
||||
if (!unpacker.unpackProfile(profileDir.getAbsolutePath(), base)) {
|
||||
return null;
|
||||
}
|
||||
return profileDir.getAbsolutePath();
|
||||
@ -54,7 +54,7 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
*
|
||||
* @return the base profile directory, or null if it could not be created
|
||||
*/
|
||||
public static String baseProfileDirectory() {
|
||||
public static String baseProfileDirectory(String base) {
|
||||
String pd = System.getenv("I2P_FIREFOX_BASE_PROFILE");
|
||||
if (pd != null && !pd.isEmpty()) {
|
||||
File pdf = new File(pd);
|
||||
@ -62,13 +62,13 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
return pd;
|
||||
} else {
|
||||
I2PFirefoxProfileUnpacker unpacker = new I2PFirefoxProfileUnpacker();
|
||||
if (!unpacker.unpackProfile(pdf.getAbsolutePath())) {
|
||||
if (!unpacker.unpackProfile(pdf.getAbsolutePath(), base)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
String rtd = runtimeDirectory();
|
||||
return baseProfileDir(rtd);
|
||||
return baseProfileDir(rtd, base);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,8 +109,8 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static boolean copyBaseProfiletoProfile() {
|
||||
String baseProfile = baseProfileDirectory();
|
||||
public static boolean copyBaseProfiletoProfile(String base) {
|
||||
String baseProfile = baseProfileDirectory(base);
|
||||
String profile = profileDirectory();
|
||||
System.out.println("Copying base profile to profile directory: " +
|
||||
baseProfile + " -> " + profile);
|
||||
@ -122,7 +122,7 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
|
||||
try {
|
||||
System.out.println("Copying base profile to profile directory");
|
||||
copyDirectory(baseProfileDir, profileDir, "firefox");
|
||||
copyDirectory(baseProfileDir, profileDir, "firefox", base);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error copying base profile to profile" + e);
|
||||
return false;
|
||||
@ -137,7 +137,7 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
// return false;
|
||||
//}
|
||||
|
||||
return copyStrictOptions();
|
||||
return copyStrictOptions(base);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,11 +146,11 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser {
|
||||
* @return true if successful, false otherwise
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public static boolean copyStrictOptions() {
|
||||
public static boolean copyStrictOptions(String base) {
|
||||
if (!strict) {
|
||||
return true;
|
||||
}
|
||||
String baseProfile = baseProfileDirectory();
|
||||
String baseProfile = baseProfileDirectory(base);
|
||||
String profile = profileDirectory();
|
||||
if (baseProfile.isEmpty() || profile.isEmpty()) {
|
||||
return false;
|
||||
|
@ -34,7 +34,7 @@ public class I2PFirefoxProfileUnpacker extends I2PCommonBrowser {
|
||||
* @return true if the profile directory was successfully unpacked
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public boolean unpackProfile(String profileDirectory) {
|
||||
return unpackProfile(profileDirectory, "firefox", "base");
|
||||
public boolean unpackProfile(String profileDirectory, String base) {
|
||||
return unpackProfile(profileDirectory, "firefox", base);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user