mirror of
				https://codeberg.org/claui/mobile-config-firefox.git
				synced 2025-11-03 20:15:56 +00:00 
			
		
		
		
	mobile-config-autoconfig: restart Firefox on update
With the current implementation, `userChrome.css` and `userContent.css` are effectively replaced on a package update, but the session still uses the previous version. Triggering a restart as soone as those files are updated ensures the latest version will be used immediately.
This commit is contained in:
		
							parent
							
								
									d661fc1666
								
							
						
					
					
						commit
						fbc916b447
					
				
					 1 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -9,6 +9,8 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 | 
			
		|||
Cu.import("resource://gre/modules/Services.jsm");
 | 
			
		||||
Cu.import("resource://gre/modules/FileUtils.jsm");
 | 
			
		||||
 | 
			
		||||
var updated = false;
 | 
			
		||||
 | 
			
		||||
// Create <profile>/chrome/ directory if not already present
 | 
			
		||||
var chromeDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
 | 
			
		||||
chromeDir.append("chrome");
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +32,7 @@ if (chromeFile.exists() && defaultChrome.exists() &&
 | 
			
		|||
// Copy userChrome.css to <profile>/chrome/
 | 
			
		||||
if (!chromeFile.exists()) {
 | 
			
		||||
    defaultChrome.copyTo(chromeDir, "userChrome.css");
 | 
			
		||||
    updated = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Create nsIFile objects for userContent.css in <profile>/chrome/ and in /etc/
 | 
			
		||||
| 
						 | 
				
			
			@ -46,6 +49,13 @@ if (contentFile.exists() && defaultContent.exists() &&
 | 
			
		|||
// Copy userContent.css to <profile>/chrome/
 | 
			
		||||
if (!contentFile.exists()) {
 | 
			
		||||
    defaultContent.copyTo(chromeDir, "userContent.css");
 | 
			
		||||
    updated = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Restart Firefox immediately if one of the files got updated
 | 
			
		||||
if (updated == true) {
 | 
			
		||||
    var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
 | 
			
		||||
    appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Select a mobile user agent for firefox (same as tor browser on android)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue