Támogatás keresése

Kerülje el a támogatási csalásokat. Sosem kérjük arra, hogy hívjon fel egy telefonszámot vagy osszon meg személyes információkat. Jelentse a gyanús tevékenységeket a „Visszaélés bejelentése” lehetőséggel.

További tudnivalók

A témacsoportot lezárták és archiválták. Tegyen fel új kérdést, ha segítségre van szüksége.

Tools for working with search engines

  • 7 válasz
  • 4 embernek van ilyen problémája
  • 1 megtekintés
  • Utolsó üzenet ettől: ZeroUnderscoreOu

more options

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].

Módosította: ZeroUnderscoreOu,

Kiválasztott megoldás

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/
Válasz olvasása eredeti szövegkörnyezetben 👍 1

Összes válasz (7)

more options

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!

more options

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.

more options

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);
 }
}
more options

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).

Módosította: ZeroUnderscoreOu,

more options

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

more options

Kiválasztott megoldás

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/

Módosította: cor-el,

more options

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.