We're calling on all EU-based Mozillians with iOS or iPadOS devices to help us monitor Apple’s new browser choice screens. Join the effort to hold Big Tech to account!

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Tools for working with search engines

  • 7 பதிலளிப்புகள்
  • 4 இந்த பிரச்னைகள் உள்ளது
  • 1 view
  • Last reply by ZeroUnderscoreOu

Hi everyone once again.

I asked a similar question a week ago, and got a relevant answer from cor-el, but now with "system changes" to the forum it seems gone.

Remind me please, how do I open *.mozlz4 files and how do I import search engines through *.xml files? Thanks in advance.


In case someone would need this: XML Search Engines Exporter/Importer.

Hi everyone once again. I asked a similar question a week ago, and got a relevant answer from cor-el, but now with "system changes" to the forum it seems gone. Remind me please, how do I open *.mozlz4 files and how do I import search engines through *.xml files? Thanks in advance. <HR> In case someone would need this: [https://addons.mozilla.org/ru/firefox/addon/search-engines-export-import/ XML Search Engines Exporter/Importer].

ZeroUnderscoreOu மூலமாக திருத்தப்பட்டது

தீர்வு தேர்ந்தெடுக்கப்பட்டது

That would be this code to run in the Browser Console (i.e. NOT in the Web Console) as this is XUL.

var {classes:Cc,interfaces:Ci,utils:Cu} = Components;
function decompressFile(oFilePath,nFilePath){
  Cu.import("resource://gre/modules/Task.jsm");
  Cu.import("resource://gre/modules/osfile.jsm");
  return Task.spawn(function* () {
    var jsonString = yield OS.File.read(oFilePath,{compression:"lz4"});
    yield OS.File.writeAtomic(nFilePath, jsonString);})
}
// Set up file chooser
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmarks/Session (.jsonlz4)","*.jsonlz4");
fp.appendFilter("Search Engines (.mozlz4)","*.mozlz4");
fp.appendFilter("Add-ons Files (.lz4)","*.lz4");
fp.displayDirectory = fu.File(OS.Path.join(OS.Constants.Path.profileDir, "sessionstore-backups"));
// Call file chooser
fp.open((aResult) => {
  if (aResult == Ci.nsIFilePicker.returnOK) {
  if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) {
    var oldfile = fp.file.path;
    var newfile = oldfile + ".json"; // Construct output file name
    try {
      decompressFile(oldfile, newfile);
      console.log("Saved as: \"" + newfile + "\"");
      if(confirm("Open JSON file in a Firefox tab?")){
        var uri="file:///"+newfile.replace(/\\/g, "/");
        window.open(uri, "_blank");
      }
    }
    catch (err) {
      console.log(err);
    }
  }
  }
});

(https://support.mozilla.org/t5/Firefox/Search-engines-reset/m-p/1375515)

You only need to decompress the search.json.mozlz4 file to make its content visible.
It is compressed the same way as the compressed .jsonlz4 bookmark backups.
See:
https://support.mozilla.org/t5/Firefox/DEcompressed-jsonlz4/m-p/1231172
You need to add/modify a line for the *.mozlz4 file extension.
* fp.appendFilter("Search Engines Files","*.mozlz4");
The file contains hashes, so you can't modify this file.
You can't add a search engine that has the same name as a built-in search engine and DuckDuckGo is a built-in search engine as you can see if you inspect the built-in engines via this chrome URI.
* chrome://browser/locale/searchplugins/

XML Search Engines Exporter/Importer:
* https://addons.mozilla.org/firefox/addon/search-engines-export-import/
Read this answer in context 👍 1

All Replies (7)

By any chance did you get an email notification with that information from the other site? If not, hopefully cor-el will find your question again!

jscher2000 said

By any chance did you get an email notification with that information from the other site?

Good hint! I actually did, sadly, the part regarding decompression was on this forum and is also removed.

Is this the one you wanted?

It is just a matter of opening the about:config page via the location/address bar like you open a website and you its search bar to locate the devtools.chrome.enabled pref and sets its value to true with a double-click if its current value is false (default).
Then if you open the Browser Console then you should see a command line at the bottom of the Browser Console window.
On this command line you can paste the code to decompress the compressed .jsonlz4 file and press the enter key to evaluate (run) this JavaScript code.
There is no need to fully understand how this code works.
The below posted code when evaluated in the Browser Console will open a file picker window that allows to browse to a compressed .jsonlz4 and select this file for decompression.
It will show a message to what file the decompressed file has been saved.

var {classes:Cc,interfaces:Ci,utils:Cu} = Components;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.<wbr>nsIFilePicker);
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmark Backup Files", "*.jsonlz4");
if (fp.show() == Ci.nsIFilePicker.returnOK) {
 var file = fp.file;
 if (file.exists() && file.isFile() && file.isReadable()) {
  var oldFile = fp.file.path;
  var newFile = oldFile.replace(".jsonlz4", ".json");
  Cu.import("resource://gre/modules/Task.jsm");
  Cu.import("resource://gre/modules/osfile.jsm");
  function decompressBookmarksFile(oFilePath,nFilePath){retur<wbr>n Task.spawn(function* () {var jsonString = yield OS.File.read(oFilePath,{ compression: "lz4" });yield OS.File.writeAtomic(nFilePath, jsonString);})}
  decompressBookmarksFile(oldFile,newFile);
  console.log("Saved as: "+ newFile);
 }
}

jscher2000 said

Is this the one you wanted?

That's close, but doesn't work (for me "Components" has only "interfaces" property)(also, forum seems to insert "<wbr>" in the code).

ZeroUnderscoreOu மூலமாக திருத்தப்பட்டது

Hopefully the correct code will emerge from cor-el's big bag of tricks...

தீர்வு தேர்ந்தெடுக்கப்பட்டது

That would be this code to run in the Browser Console (i.e. NOT in the Web Console) as this is XUL.

var {classes:Cc,interfaces:Ci,utils:Cu} = Components;
function decompressFile(oFilePath,nFilePath){
  Cu.import("resource://gre/modules/Task.jsm");
  Cu.import("resource://gre/modules/osfile.jsm");
  return Task.spawn(function* () {
    var jsonString = yield OS.File.read(oFilePath,{compression:"lz4"});
    yield OS.File.writeAtomic(nFilePath, jsonString);})
}
// Set up file chooser
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmarks/Session (.jsonlz4)","*.jsonlz4");
fp.appendFilter("Search Engines (.mozlz4)","*.mozlz4");
fp.appendFilter("Add-ons Files (.lz4)","*.lz4");
fp.displayDirectory = fu.File(OS.Path.join(OS.Constants.Path.profileDir, "sessionstore-backups"));
// Call file chooser
fp.open((aResult) => {
  if (aResult == Ci.nsIFilePicker.returnOK) {
  if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) {
    var oldfile = fp.file.path;
    var newfile = oldfile + ".json"; // Construct output file name
    try {
      decompressFile(oldfile, newfile);
      console.log("Saved as: \"" + newfile + "\"");
      if(confirm("Open JSON file in a Firefox tab?")){
        var uri="file:///"+newfile.replace(/\\/g, "/");
        window.open(uri, "_blank");
      }
    }
    catch (err) {
      console.log(err);
    }
  }
  }
});

(https://support.mozilla.org/t5/Firefox/Search-engines-reset/m-p/1375515)

You only need to decompress the search.json.mozlz4 file to make its content visible.
It is compressed the same way as the compressed .jsonlz4 bookmark backups.
See:
https://support.mozilla.org/t5/Firefox/DEcompressed-jsonlz4/m-p/1231172
You need to add/modify a line for the *.mozlz4 file extension.
* fp.appendFilter("Search Engines Files","*.mozlz4");
The file contains hashes, so you can't modify this file.
You can't add a search engine that has the same name as a built-in search engine and DuckDuckGo is a built-in search engine as you can see if you inspect the built-in engines via this chrome URI.
* chrome://browser/locale/searchplugins/

XML Search Engines Exporter/Importer:
* https://addons.mozilla.org/firefox/addon/search-engines-export-import/

cor-el மூலமாக திருத்தப்பட்டது

cor-el said

That would be this code to run in the Browser Console (i.e. NOT in the Web Console) as this is XUL.

That's what was my mistake - running it in Web Console.