Last active
December 18, 2024 16:10
Revisions
-
jscher2000 revised this gist
Dec 18, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ fp.open((aResult) => { // Construct output file name var newfile = oldfile + "_converted.json"; try { //Cu.import("resource://gre/modules/osfile.jsm"); //let promise = OS.File.read(oldfile,{compression:"lz4"}); let promise = IOUtils.readUTF8(oldfile, { decompress: true }); // Fx104 promise = promise.then(jsonString => { -
jscher2000 revised this gist
Mar 18, 2024 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,11 @@ var {utils:Cu} = Components; // Set up file chooser var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils try { // Fx125+ fp.init(window.browsingContext, 'Open File', Components.interfaces.nsIFilePicker.modeOpen); } catch(e) { // Fx124 and earlier fp.init(window, 'Open File', Components.interfaces.nsIFilePicker.modeOpen); } fp.appendFilter("LZ4 Compressed Files", "*.mozlz4;*.jsonlz4*"); //fp.displayDirectory = fu.File(OS.Constants.Path.profileDir); fp.displayDirectory = fu.File(PathUtils.profileDir); // Fx104 -
jscher2000 revised this gist
Aug 30, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,10 +29,10 @@ fp.open((aResult) => { try { Cu.import("resource://gre/modules/osfile.jsm"); //let promise = OS.File.read(oldfile,{compression:"lz4"}); let promise = IOUtils.readUTF8(oldfile, { decompress: true }); // Fx104 promise = promise.then(jsonString => { //OS.File.writeAtomic(newfile, jsonString); IOUtils.writeUTF8(newfile, jsonString); // Fx104 }); promise = promise.then(retval => { console.log('Saved as: "' + newfile + '"'); -
jscher2000 revised this gist
Aug 30, 2022 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,8 @@ var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Componen var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils fp.init(window, "Open File", Components.interfaces.nsIFilePicker.modeOpen); fp.appendFilter("LZ4 Compressed Files", "*.mozlz4;*.jsonlz4*"); //fp.displayDirectory = fu.File(OS.Constants.Path.profileDir); fp.displayDirectory = fu.File(PathUtils.profileDir); // Fx104 // Call file chooser fp.open((aResult) => { if (aResult == Components.interfaces.nsIFilePicker.returnOK) { @@ -27,9 +28,11 @@ fp.open((aResult) => { var newfile = oldfile + "_converted.json"; try { Cu.import("resource://gre/modules/osfile.jsm"); //let promise = OS.File.read(oldfile,{compression:"lz4"}); let promise = IOUtils.readUTF8(oldfile, { decompress: true }); // Fx104 promise = promise.then(jsonString => { //OS.File.writeAtomic(newfile, jsonString); IOUtils.writeUTF8(newfile, jsonString); // Fx104 }); promise = promise.then(retval => { console.log('Saved as: "' + newfile + '"'); -
jscher2000 renamed this gist
Sep 14, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jscher2000 revised this gist
Mar 27, 2019 . 1 changed file with 25 additions and 29 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,17 @@ /* Decompression Script for the Browser Console NOTE: BEFORE RUNNING THIS SCRIPT, CHECK THIS SETTING: Type or paste about:config into the address bar and press Enter Click the button promising to be careful In the search box type devt and pause while Firefox filters the list If devtools.chrome.enabled is false, double-click it to toggle to true Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j) Then press Enter to run the script. A file picker should promptly open. See: http://forums.mozillazine.org/viewtopic.php?p=14111285#p14111285 */ var {utils:Cu} = Components; // Set up file chooser var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils @@ -27,21 +21,23 @@ fp.displayDirectory = fu.File(OS.Constants.Path.profileDir); // Call file chooser fp.open((aResult) => { if (aResult == Components.interfaces.nsIFilePicker.returnOK) { if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) { var oldfile = fp.file.path; // Construct output file name var newfile = oldfile + "_converted.json"; try { Cu.import("resource://gre/modules/osfile.jsm"); let promise = OS.File.read(oldfile,{compression:"lz4"}); promise = promise.then(jsonString => { OS.File.writeAtomic(newfile, jsonString); }); promise = promise.then(retval => { console.log('Saved as: "' + newfile + '"'); }); } catch (err) { console.log(err); } } } }); -
jscher2000 created this gist
Sep 17, 2017 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ /* NOTE: BEFORE RUNNING THIS SCRIPT, CHECK THIS SETTING: Type or paste about:config into the address bar and press Enter Click the button promising to be careful In the search box type devt and pause while Firefox filters the list If devtools.chrome.enabled is false, double-click it to toggle to true Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j) Then press Enter to run the script. A file picker should promptly open. See: http://forums.mozillazine.org/viewtopic.php?p=14111285#p14111285 */ var {utils:Cu} = Components; function decompressBookmarksFile(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 = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); var fu = Cu.import("resource://gre/modules/FileUtils.jsm").FileUtils fp.init(window, "Open File", Components.interfaces.nsIFilePicker.modeOpen); fp.appendFilter("LZ4 Compressed Files", "*.mozlz4;*.jsonlz4*"); fp.displayDirectory = fu.File(OS.Constants.Path.profileDir); // Call file chooser fp.open((aResult) => { if (aResult == Components.interfaces.nsIFilePicker.returnOK) { if (fp.file.exists() && fp.file.isFile() && fp.file.isReadable()) { var oldfile = fp.file.path; // Construct output file name var newfile = oldfile + "_converted.json"; try { decompressBookmarksFile(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); } } } });