MozillaZine

Firefox ESR - Prevent default search engines from returning

User Help for Mozilla Firefox
nathan22
 
Posts: 2
Joined: April 29th, 2020, 7:58 am

Post Posted April 29th, 2020, 8:14 am

Hello, my employer has tasked me with preventing the default search engines from returning on our ESR build.
I have spent far too long searching for the answer with no results, so I am hoping y'all can help me :)

Currently I delete all of them via policies.json and add in a dummy search engine that will be set as the default.
Apparently this is not enough and I have been asked to disable the "Restore Default Search Engines" button so these engines can NEVER return.

I can think of two ways of accomplishing this:
1. Complete removal of the stock search engines (Seems impossible...)
2. Disabling the "Restore" button completely, so the user cannot press it.

I have been able to disable the restore button by modifying omni.ja, but I really really don't want to have to do that as I would need to include Cygwin in our Windows distributions in order to rezip the file properly (zip -qr9XD)

Is there any way to accomplish this without modifying omni.ja? Maybe some mozilla.cfg js code??

And if modifying omni.ja is the only way, is there a way to rezip omni.ja with default Windows libraries?

We are currently on esr 68.7.0 and update whenever available. Use both Windows and Linux machines.

jscher2000

User avatar
 
Posts: 11034
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA

Post Posted April 29th, 2020, 12:36 pm

nathan22 wrote:Currently I delete all of them via policies.json and add in a dummy search engine that will be set as the default.
Apparently this is not enough and I have been asked to disable the "Restore Default Search Engines" button so these engines can NEVER return.


How are you deleting them in your Policies file? You can use the Extensions key to Uninstall the built-in search engines and that should thoroughly disable them. See: https://support.mozilla.org/en-US/questions/1265135#answer-1239106. If they can still be restored after that I would be very surprised (but then, bugs happen).

tanstaafl
Moderator

User avatar
 
Posts: 46810
Joined: July 30th, 2003, 5:06 pm

Post Posted April 29th, 2020, 5:36 pm

The problem with modifying omni.ja is you never know beforehand when an update will replace it.

Does the policies.json file effect a search engine added by an add-on like the add custom search engine add-on? That add-on would not be on the list of extensions in policies.json and the add-on just needs the search URL and a name for the search engine.

I'm confused why you (OP) are both removing the stock search engines AND providing a dummy search engine. How do you want them to search the Internet? You don't seem to be preventing them from navigating to the google search web page etc, you're just breaking the integration with the browser. Could you re-phrase and elaborate on what your goal is?

morat
 
Posts: 3910
Joined: February 3rd, 2009, 6:29 pm

Post Posted April 29th, 2020, 9:45 pm

The omni.ja files aren't signed in 68esr.

More info: viewtopic.php?p=14847954#p14847954

I bet the omni.ja files in 78esr will be signed so you won't be able to hack it anymore.

Release Calendar
http://wiki.mozilla.org/Release_Management/Calendar

morat
 
Posts: 3910
Joined: February 3rd, 2009, 6:29 pm

Post Posted April 29th, 2020, 10:17 pm

How to hide the "Restore Default Search Engines" button using the browser console.

Code: Select all
(function () {

  var css = `@-moz-document url-prefix("about:preferences"),
    url-prefix("chrome://browser/content/preferences/in-content/preferences.xul"),
    url-prefix("chrome://browser/content/preferences/in-content/preferences.xhtml") {
    #restoreDefaultSearchEngines {
      display: none !important;
    }
  }`;
  var ios = Components.classes["@mozilla.org/network/io-service;1"].
    getService(Components.interfaces.nsIIOService);
  var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
  var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
    getService(Components.interfaces.nsIStyleSheetService);
  // var type =  sss.AGENT_SHEET;
     var type =  sss.USER_SHEET;
  // var type = sss.AUTHOR_SHEET;
  if (sss.sheetRegistered(uri, type)) sss.unregisterSheet(uri, type);
  else sss.loadAndRegisterSheet(uri, type);

})();

Browser Console command line
http://developer.mozilla.org/docs/Tools/Browser_Console#Browser_Console_command_line

nathan22
 
Posts: 2
Joined: April 29th, 2020, 7:58 am

Post Posted May 8th, 2020, 8:08 am

Whoops, sorry for the late replies, I thought I would be emailed when someone responded!

jscher2000 wrote:How are you deleting them in your Policies file? You can use the Extensions key to Uninstall the built-in search engines and that should thoroughly disable them. See: https://support.mozilla.org/en-US/questions/1265135#answer-1239106. If they can still be restored after that I would be very surprised (but then, bugs happen).


Currently in the policies file I just remove them from the installed search engine list, which is why they come back when clicking the "restore" button. I tried removing them the way you linked and I believe it did remove them, but they still come back when clicking the button... Their search icon is gone though, so I'm sure they're uninstalled as the policy file states.

tanstaafl wrote:I'm confused why you (OP) are both removing the stock search engines AND providing a dummy search engine. How do you want them to search the Internet? You don't seem to be preventing them from navigating to the google search web page etc, you're just breaking the integration with the browser. Could you re-phrase and elaborate on what your goal is?


The dummy search engine is because Firefox seems to require one search engine to be selected. If I could have none at all, that would be even better! For our purpose, we do not want them searching the internet which is why they've asked me to remove all traces of these search engines. It is a bit overkill in my opinion.

morat wrote:How to hide the "Restore Default Search Engines" button using the browser console.

Is this something I can do in mozilla.cfg? I'll play around with it!
This works in mozilla.cfg! Problem solved, thank you so much!

Many thanks for all the replies everyone

Return to Firefox Support


Who is online

Users browsing this forum: Bing [Bot] and 7 guests