SeaMonkey 2.53.17 βeta 1 has been released !!!

Discussion about Seamonkey builds
n0spam
Posts: 30
Joined: November 7th, 2020, 7:56 am

Re: SeaMonkey 2.53.17 βeta 1 has been released !!!

Post by n0spam »

You need to modify the script to use inline scripts and styles instead of remote ones. All I could find was a webextension version of the extension (https://github.com/bhollis/jsonview/releases/tag/v0.9), but SeaMonkey doesn't support webextensions, so either upload your XUL version somewhere or upload your XUL version somewhere.
In the webextension version, you need to modify file "lib\jsonformatter.js". Replace function toHTML with this one:

Code: Select all

  toHTML: function(content, title) {
    function read_file(url)
    {
      var rc;
      var istream = Components.classes["@mozilla.org/network/io-service;1"]
        .getService(Components.interfaces.nsIIOService)
        .newChannel(url, null, null)
        .open();
      var sstream = Components.classes["@mozilla.org/scriptableinputstream;1"]
        .createInstance(Components.interfaces.nsIScriptableInputStream);
      sstream.init(istream);
      rc = sstream.read(sstream.available()); // sstream.read(-1) also reads all.
      sstream.close(); sstream = null;
      istream.close(); istream = null;
      return rc;
    }
    return '<!DOCTYPE html>\n' +
      '<html><head><title>' + this.htmlEncode(title) + '</title>' +
	  '<style type="text/css">' + read_file(addonData.url("default.css")) + '</style>' + 
	  '<script type="text/javascript">' + read_file(addonData.url("default.js")) + '</script>' +
      '</head><body>' +
      content +
      '</body></html>';
  }
User avatar
raj_bhaskar
Posts: 1939
Joined: November 7th, 2002, 3:50 am
Location: Glasgow, Scotland
Contact:

Re: SeaMonkey 2.53.17 βeta 1 has been released !!!

Post by raj_bhaskar »

Hi n0spam, thanks for your help so far. I tried changing the toHTML function as described but it threw an error while in the messageError() function. I disabled the lines generating the error and got this in the console:

Code: Select all

17:01:26.052 ReferenceError: `Components` is not available in this context.
Functionality provided by Components may be available in an SDK
module: https://developer.mozilla.org/en-US/Add-ons/SDK 

However, if you still need to import Components, you may use the
`chrome` module's properties for shortcuts to Component properties:

Shortcuts: 
    Cc = Components.classes 
    Ci = Components.interfaces 
    Cu = Components.utils 
    CC = Components.Constructor 
Example: 
    let { Cc, Ci } = require('chrome');
 1 loader.js:487:13
I've uploaded the XUL version to https://lordofthemoon.com/files/jsonview.xpi

Thanks, Raj.
n0spam
Posts: 30
Joined: November 7th, 2020, 7:56 am

Re: SeaMonkey 2.53.17 βeta 1 has been released !!!

Post by n0spam »

In file harness-options.json, in block "jsonview/jsonformatter", add "chrome": "chrome" under "requirements". This is needed for function read_file to have access to XPCOM (Components.classes, etc.) to read files.

Code: Select all

{
...
  "jsonview/jsonformatter": {
   "docsSHA256": null, 
   "jsSHA256": "bf4b9daafe70f1f20e5be7f4bb736346580e0c6332f986d5e8ec8f8a0a49d7cc", 
   "moduleName": "jsonformatter", 
   "packageName": "jsonview", 
   "requirements": {
    "chrome": "chrome", 
    "sdk/l10n": "sdk/l10n", 
    "sdk/self": "sdk/self"
   }, 
   "sectionName": "lib"
  }, 
...
In file lib\jsonformatter.js modify function toHTML again (small changes in function read_file):

Code: Select all

  toHTML: function(content, title) {
    function read_file(url)
    {
      var { Cc, Ci } = require('chrome');
      var rc = "";
      var istream = Cc["@mozilla.org/network/io-service;1"]
        .getService(Ci.nsIIOService)
        .newChannel(url, null, null)
        .open();
      var cstream = Cc["@mozilla.org/intl/converter-input-stream;1"]
        .createInstance(Ci.nsIConverterInputStream);
      cstream.init(istream, "utf-8", 0, 0);
      for (var n, s = {}; (n = cstream.readString(-1, s)) > 0; ) { rc += s.value; }
      cstream.close(); cstream = null;
      istream.close(); istream = null;
      return rc;
    }
    
    return '<!DOCTYPE html>\n' +
      '<html><head><title>' + this.htmlEncode(title) + '</title>' +
      '<style type="text/css">' + read_file(addonData.url("default.css")) + '</style>' + 
      '<script type="text/javascript">' + read_file(addonData.url("default.js")) + '</script>' +
      '</head><body>' +
      content +
      '</body></html>';
  }
User avatar
raj_bhaskar
Posts: 1939
Joined: November 7th, 2002, 3:50 am
Location: Glasgow, Scotland
Contact:

Re: SeaMonkey 2.53.17 βeta 1 has been released !!!

Post by raj_bhaskar »

Apologies for the delay in getting back to you, I've been on holiday for a few weeks. n0spam: you're a star. Thanks for sticking with me, that works perfectly now!
DoYouWantKarate
Posts: 24
Joined: March 24th, 2005, 9:24 am

Re: SeaMonkey 2.53.17 βeta 1 has been released !!!

Post by DoYouWantKarate »

raj_bhaskar wrote:
August 4th, 2023, 2:21 am
Having just upgraded, I had to modify the following extensions and change either nsIPrefBranch2 or nsIPrefBranchInternal to nsIPrefBranch:
=D> Big thanks! This also fixed Preferences Toolbar after extracting /content/goprefbar/main.js from prefbar.jar, editing it, and putting it back in.
Post Reply