From 0074d0968a9ec502a902391b3cb1580dd63d253e Mon Sep 17 00:00:00 2001 From: idk Date: Thu, 15 Sep 2022 21:10:48 -0400 Subject: [PATCH] add userChrome CSS enablement for Firefox app mode --- .../i2pfirefox/I2PFirefoxProfileBuilder.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java index 6965d01..386e7b9 100644 --- a/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java +++ b/src/java/net/i2p/i2pfirefox/I2PFirefoxProfileBuilder.java @@ -1,6 +1,7 @@ package net.i2p.i2pfirefox; import java.io.File; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.StandardCopyOption; @@ -200,6 +201,28 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser { return copyStrictOptions(base, app); } + protected static boolean writeAppChrome(String profile) { + File dir = new File(profile, "chrome"); + if (!dir.exists()) + dir.mkdirs(); + File f = new File(dir, "userChrome.css"); + try{ + Files.write(f.toPath(), userChromeCSS().getBytes()); + }catch(IOException e){ + logger.warning(e.toString()); + return false; + } + return true; + } + protected static boolean deleteAppChrome(String profile) { + File dir = new File(profile, "chrome"); + if (!dir.exists()) + return true; + File f = new File(dir, "userChrome.css"); + if (f.exists()) + f.delete(); + return true; + } /** * Copy the strict options from the base profile to the profile * @@ -238,11 +261,13 @@ public class I2PFirefoxProfileBuilder extends I2PCommonBrowser { "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", false);", "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);", userOverrides); + writeAppChrome(profileDir.toString()); } else { I2PFirefoxProfileChecker.undoValue( "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", true);", "user_pref(\"toolkit.legacyUserProfileCustomizations.stylesheets\", false);", userOverrides); + deleteAppChrome(profileDir.toString()); } } return true;