Decompressing search.jsonlz4

User Help for Mozilla Firefox
Post Reply
User avatar
Drumbrake
Posts: 1177
Joined: February 14th, 2011, 2:34 am

Decompressing search.jsonlz4

Post by Drumbrake »

This is one of the threads that are apparently missing after the recent forum issue: someone asked about decompressing this obnoxius search.jsonlz4 that now obfuscates search engines (replacing the good old searchplugin folder) and Alice0775 came to the rescue with the following code
Alice0775 wrote: Execute the following code in Browser Console ( set devtools.chrome.enabled=true in about:config )

search.json.mozlz4 -> search.json

Code: Select all

function decompress() {
  Task.spawn(function() {
    let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json.mozlz4");
    let bytes = yield OS.File.read(cacheFilePath, {compression: "lz4"});
    let data = new TextDecoder().decode(bytes);
    let jsonFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
    OS.File.writeAtomic(jsonFilePath, data);
  });
}
decompress();
search.json -> search.json.mozlz4_new

Code: Select all

function compress() {
  Task.spawn(function() {
    let jsonFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json");
    let bytes = yield OS.File.read(jsonFilePath);
    let data = new TextDecoder().decode(bytes);
    let cacheFilePath = OS.Path.join(OS.Constants.Path.profileDir, "search.json.mozlz4_new");
    OS.File.writeAtomic(cacheFilePath, data, {compression: "lz4"});
  });
}
compress();
which unfortunately isn't working for me : I've set devtools.chrome.enabled=true and tried to execute this code in the Scratchpad but nothing happens, I'm only getting this
error

Code: Select all

/*
Exception: ReferenceError: Task is not defined
decompress@Scratchpad/1:11:3
@Scratchpad/1:19:1
WCA_evalWithDebugger@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/server/actors/webconsole.js:1256:16
WCA_onEvaluateJS@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/server/actors/webconsole.js:850:20
WCA_onEvaluateJSAsync@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/server/actors/webconsole.js:820:20
DSC_onPacket@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/server/main.js:1643:15
LocalDebuggerTransport.prototype.send/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/transport/transport.js:569:11
makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/DevToolsUtils.js:87:14
makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://devtools/shared/DevToolsUtils.js:87:14
*/
I'm trying in clean temporary profile, no addons or modifications whatsoever: what am I doing wrong ?
User avatar
Benjamin Markson
Posts: 397
Joined: November 19th, 2011, 3:57 am
Location: en-GB

Re: Decompressing search.jsonlz4

Post by Benjamin Markson »

XUL is dead. Long live the Google Chrome Clones.
Brummelchen
Posts: 4480
Joined: March 19th, 2005, 10:51 am

Re: Decompressing search.jsonlz4

Post by Brummelchen »

i would delete it, exit firefox, edit the xml files in <profile>\searchengines\ and restart firefox.
the magic number is 51 and you are probably part of it :p
User avatar
therube
Posts: 21714
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Re: Decompressing search.jsonlz4

Post by therube »

(From what I recall, when I tested, I also didn't get that code to work. But then I'm mostly unfamiliar with "devtools".

I think you also asked if the code should be entered into Error Console or "Dev Tools"?)

Might try a stand-alone .jsonlz4 decompressor, http://forums.mozillazine.org/viewtopic ... #p14604245.
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript
User avatar
Drumbrake
Posts: 1177
Joined: February 14th, 2011, 2:34 am

Re: Decompressing search.jsonlz4

Post by Drumbrake »

Benjamin Markson wrote:Does this help?

http://forums.mozillazine.org/viewtopic ... &t=3020165

Ben.
Yes, I think so. I'm giving it a try, thanks.
Brummelchen wrote:i would delete it, exit firefox, edit the xml files in <profile>\searchengines\ and restart firefox.
Clever, I didn't figure this out. This will allow me to import all searchplugins at once from another profile, but (if a got it right) will also overwrite all existing ones - still, interesting workaround.

As for the code posted originally by Alice, does anyone have clue about why isn't working?
Is it correct to execute it in the Scratchpad, to begin with?
Brummelchen
Posts: 4480
Joined: March 19th, 2005, 10:51 am

Re: Decompressing search.jsonlz4

Post by Brummelchen »

this jsonlz4 is a compressed form of the present xml files - firefox would create it from scratch if not present (and use it) to avoid malware changes in the xml files - or adding new (unwanted) xml files/search engines.

once it was possible to edit the xml files, eg with OSE (organize search engines from malte kraus)
not sure if the revised edition can that do too
https://github.com/Baton34/organize-search-engines/

OSE can do more, eg create folders and sort search engines, not sure if it offers the old style before it was changed in firefox. (CTR do)
Post Reply