Disable/Change Firefox Safe Mode Hotkey (Shift)

后端 未结 3 1616
小鲜肉
小鲜肉 2020-12-19 14:06

Is there any way to change the firefox shift hotkey that makes firefox start in safe mode? I\'ve set up some unit tests using Selenium and PHPUnit, but if I\'m working on th

3条回答
  •  执念已碎
    2020-12-19 14:21

    Until Bug 653410 is fixed, the best workaround I can come up with is to detect when safe mode is launched and handle it in the best way fit for your particular purposes. This may mean killing the Firefox process and launching again, or it may mean warning the user, or both.

    When Firefox is launched into safe mode, it writes "LastVersion=Safe Mode" to its compatibility.ini file in its profile directory. An example C# function to watch for this is given below.

        FileSystemWatcher safeModeWatcher;
    
        private void watchSafeMode()
        {
            string profiles = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mozilla", "Firefox", "Profiles");
            string defaultProfile = Directory.GetDirectories(profiles, "*default*")[0];
            safeModeWatcher = new FileSystemWatcher(defaultProfile, "compatibility.ini");
            safeModeWatcher.NotifyFilter = NotifyFilters.LastWrite;
            safeModeWatcher.Changed += delegate(object s, FileSystemEventArgs e)
            {
                if (File.ReadAllText(e.FullPath).Contains("LastVersion=Safe Mode"))
                {
                    // safe mode!
                    System.Diagnostics.Trace.WriteLine("safe mode detected!");
                    // TODO kill Firefox and launch again, or whatever makes sense for you
                }
            };
            safeModeWatcher.EnableRaisingEvents = true;
            // ...
            // TODO Dispose safeModeWatcher when done
        }
    

提交回复
热议问题