X
Tap here to go to the mobile version of the site.

Support Forum

Tools for working with search engines

Posted

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

Modified by ZeroUnderscoreOu

Chosen solution

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;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmark Backup Files","*.jsonlz4");
fp.appendFilter("Search Engines Files","*.mozlz4");
if (fp.show() == Ci.nsIFilePicker.returnOK) {
 var file = fp.file;
 if (file.exists() && file.isFile() && file.isReadable()) {
  Cu.import("resource://gre/modules/Task.jsm");
  Cu.import("resource://gre/modules/osfile.jsm");
  function decompressLZ4File(oFilePath,nFilePath){
   return Task.spawn(function* (){
    var jsonString = yield OS.File.read(oFilePath,{compression:"lz4"});
    yield OS.File.writeAtomic(nFilePath,jsonString);})
  }
  var oldFile = file.path;
  var newFile = oldFile + ".json";
  decompressLZ4File(oldFile,newFile);
  console.log("Saved as: "+newFile);
 }
}

(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
Quote

Additional System Details

Installed Plug-ins

  • Shockwave Flash 25.0 r0

Application

  • User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0

More Information

jscher2000
  • Top 10 Contributor
6063 solutions 49811 answers

Helpful Reply

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!

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!
Was this helpful to you? 1
Quote

Question owner

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.

''jscher2000 [[#answer-961296|said]]'' <blockquote> By any chance did you get an email notification with that information from the other site? </blockquote> Good hint! I actually did, sadly, the part regarding decompression [https://support.mozilla.org/t5/Firefox/DEcompressed-jsonlz4/m-p/1231172 was on this forum] and is also removed.
Was this helpful to you?
Quote
jscher2000
  • Top 10 Contributor
6063 solutions 49811 answers

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);
 }
}
'''''Is this the one you wanted?''''' <p>It is just a matter of opening the <b>about:config</b> 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).<br> Then if you open the Browser Console then you should see a command line at the bottom of the Browser Console window.<br> 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.<br> There is no need to fully understand how this code works.<br> 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.<br> It will show a message to what file the decompressed file has been saved. </p> <ul><li>https://support.mozilla.org/questions/1071533 </li></ul> <pre>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() &amp;&amp; file.isFile() &amp;&amp; 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); } }</pre>
Was this helpful to you?
Quote

Question owner

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

''jscher2000 [[#answer-961389|said]]'' <blockquote> '''''Is this the one you wanted?''''' </blockquote> That's close, but doesn't work (for me "Components" has only "interfaces" property)(also, forum seems to insert "<wbr>" in the code).

Modified by ZeroUnderscoreOu

Was this helpful to you?
Quote
jscher2000
  • Top 10 Contributor
6063 solutions 49811 answers

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

Hopefully the correct code will emerge from cor-el's big bag of tricks...
Was this helpful to you?
Quote
cor-el
  • Top 10 Contributor
  • Moderator
15015 solutions 136270 answers

Chosen Solution

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;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen);
fp.appendFilter("Bookmark Backup Files","*.jsonlz4");
fp.appendFilter("Search Engines Files","*.mozlz4");
if (fp.show() == Ci.nsIFilePicker.returnOK) {
 var file = fp.file;
 if (file.exists() && file.isFile() && file.isReadable()) {
  Cu.import("resource://gre/modules/Task.jsm");
  Cu.import("resource://gre/modules/osfile.jsm");
  function decompressLZ4File(oFilePath,nFilePath){
   return Task.spawn(function* (){
    var jsonString = yield OS.File.read(oFilePath,{compression:"lz4"});
    yield OS.File.writeAtomic(nFilePath,jsonString);})
  }
  var oldFile = file.path;
  var newFile = oldFile + ".json";
  decompressLZ4File(oldFile,newFile);
  console.log("Saved as: "+newFile);
 }
}

(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/
That would be this code to run in the Browser Console (i.e. NOT in the Web Console) as this is XUL. <pre>var {classes:Cc,interfaces:Ci,utils:Cu} = Components; var fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); fp.init(window, "Open File", Ci.nsIFilePicker.modeOpen); fp.appendFilter("Bookmark Backup Files","*.jsonlz4"); fp.appendFilter("Search Engines Files","*.mozlz4"); if (fp.show() == Ci.nsIFilePicker.returnOK) { var file = fp.file; if (file.exists() && file.isFile() && file.isReadable()) { Cu.import("resource://gre/modules/Task.jsm"); Cu.import("resource://gre/modules/osfile.jsm"); function decompressLZ4File(oFilePath,nFilePath){ return Task.spawn(function* (){ var jsonString = yield OS.File.read(oFilePath,{compression:"lz4"}); yield OS.File.writeAtomic(nFilePath,jsonString);}) } var oldFile = file.path; var newFile = oldFile + ".json"; decompressLZ4File(oldFile,newFile); console.log("Saved as: "+newFile); } }</pre> ---- (https://support.mozilla.org/t5/Firefox/Search-engines-reset/m-p/1375515) <blockquote><pre>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/</pre></blockquote>
Was this helpful to you? 1
Quote

Question owner

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.

''cor-el [[#answer-961442|said]]'' <blockquote> That would be this code to run in the Browser Console (i.e. NOT in the Web Console) as this is XUL. </blockquote> That's what was my mistake - running it in Web Console.
Was this helpful to you?
Quote
Ask a question

You must log in to your account to reply to posts. Please start a new question, if you do not have an account yet.