Extensions :  K-Meleon Web Browser Forum
All about K-Meleon extensions. 
Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: November 08, 2020 12:21PM

This is restartless add-on.
File -> Open -> All Files -> polyfill@om.xpi
You can manage it in about:addons page.

This add-in injects the JS file into the pages
before any scripts are executed.

Preferences:
extensions.polyfill@om.toolbar - toolbar for the button.
('Browser Con&figuration' by default)

extensions.polyfill@om.jsfile - path to file
(for example 'file:///c:/KM-Goanna/polyfill.js')
Internal file 'polyfill.js' is used by default

This fixes the problem with NodeList.prototype.forEach() function.
https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach


Enjoy!

Attachments: polyfill@om_3.zip (8.5 KB)  
Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: November 08, 2020 04:03PM

WHOW!! Sounds like POWER stuff, almost magic for aging KM!
What macro writers never dared to dream yet, a chance to modify pages BEFORE they finished loading.... and a chance to run scripts with higher rights as webpage authors ... and a chance to add some missing modern engine features by polyfills...
Of course all possible before with xpi-addons (I guess...), but no addon devs around, and obviously you're giving us here simple, tiny EXAMPLE addons. Thank you! smiling smiley

Can you give more instructions, and perhaps screenshots? I know you think "just look inside the code", but the few of us here dabbling with macros have next to zero clue about xul-addons, only modifying existing ones here and there, based on just a bit javascript snippets collected over the years when needed in macros.
And personally have the prob that "just look and see" is a bit difficult, due to old main OS, runs max a very buggy KMG74. Just occasionally on another machine capable of KG76, and offline.

For example:
I see the flexibility that the called scripts path can be changed easily by simple macros changing a pref, affecting future page loads, but no clue about:

What does THIS do?
var CmdName = 'Polyfill10';
Can find this only 1x in the addon-code.... intrigued...

So, what exactly happens when the button is clicked?
For the current page, AFTER page load?
On pages which are in the process of loading?
On background pages?
Can an observed pref (changed any time by macros) also inject such power stuff into the current page only?

And perhaps offtopic for this addon, can this ominious "gBrowser" used in FF addons somehow be addressed by KM?
For example to allow full-page screenshots? (years ago have seen addon code for Firefox which was just a few lines and superfast, but all such addons use this ominous "gBrower" overlay which KM just doesn't have)

By the way KM has an own target-ID for install.rdf, although have some doubts it works right, and at least KG74 still prefers the FF-ID anyway.

<em:targetApplication><!-- K-Meleon -->
<Description><em:id>{944df56f-c0ec-4d7b-94b6-f625c8cc96ea}</em:id>
Hmm... then again... a dim memory, very dim.... that ID may have been changed a few years back? Something with "kmeleon" as clear text in ID...
Found it: 944 is correct. Only *before* until 74RC1 it was "kmeleon@"
http://kmeleonbrowser.org/forum/read.php?22,128038,128994#msg-128994



Edited 5 time(s). Last edit at 11/08/2020 04:54PM by siria.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: November 14, 2020 11:08PM

Quote
siria
var CmdName = 'Polyfill10';
Can find this only 1x in the addon-code.... intrigued...

This creates the custom command "Polyfill10" to open Polyfill.js source file in a new tab for viewing.
Just so the user can check that the correct file is being used:

jsb.RegisterCmd(CmdName, 'Polyfill', function(mode) {
jsb.Open(JSfile, jsb.OPEN_NEWTAcool smiley;
}, 'chrome://polyfill/content/icon.png');

This creates the button and associates it with the command:
jsb.AddButton(Toolbar, CmdName, "");
The icon for the button is taken from the command (chrome://polyfill/content/icon.png).

Quote
siria
Can an observed pref (changed any time by macros) also inject such power stuff into the current page only?

The script is loaded for any page opened or reloaded after add-on was enabled.
But you can do conditional things, for example:

if(window.location.hostname == 'kmeleonbrowser.org'){
window.addEventListener('load', function(event) {
alert('kmeleonbrowser.org is loaded');
});
}

It would of course be very tempting to call the macro so that it can load the script.
But if I understand correctly, communication between the browser and macros is done asynchronously. When a macro is triggered by an event, it may be too late to load the script.
On the other hand, I haven't fully figured it out yet. Too many sources ...

Quote
siria
And perhaps offtopic for this addon, can this ominious "gBrowser" used in FF addons somehow be addressed by KM?
If I understand correctly, gbrowser is a collection of opened tabs and pages. It present in KM.
But KM uses its own tab manager and I don't know how to associate a tab with a page.
I haven't figured it out yet.

Quote
siria
By the way KM has an own target-ID for install.rdf, although have some doubts it works right, and at least KG74 still prefers the FF-ID anyway.
Thank you!

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: November 15, 2020 12:16AM

Button action changed to switch injection on/off.
Use right click to view polyfill.js source file.

Attachments: polyfill@om2.zip (8.4 KB)  
Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: adodupan
Date: November 30, 2020 11:25PM

Quote
siria
What macro writers never dared to dream yet, a chance to modify pages BEFORE they finished loading...

Quote
Kris_88
It would of course be very tempting to call the macro so that it can load the script.
But if I understand correctly, communication between the browser and macros is done asynchronously. When a macro is triggered by an event, it may be too late to load the script.

In 2014. i packed kmm file inside the xpi addon.
Necessary changes were new events:
OnLocaleChange
OnRootElementInserted
OnDocumentCreated
Macros within xpi uses a properties file instead of localizations from a kml file.
New option are some events that made it possible to intercept page loads from macros.
Instead of setting global variables in a kmm file, it is necessary to register these new events in a chrome.manifest file.

You both probably want to play with the code, but keep in mind, the code uses a nsIJSBridge.SendMessage function. Starting with version 75, this function crashes km. You can try this in 74, or you can search for roytam's build 20191116, it is not stable but it's enough to test.

test_ipl.kmm
$_testurl = "";
_test_ipl{
#  set some criteria here
#  if(hostname($_testurl) == "kmeleonbrowser.org")
#  do something 
   alert($_testurl, "Intercepting Page Loads");
}
Paste this into the error console:
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
Components.utils.import('resource://gre/modules/Services.jsm');
XPCOMUtils.defineLazyServiceGetter(this, 'JSB', '@kmeleon/jsbridge;1', 'nsIJSBridge');
XPCOMUtils.defineLazyServiceGetter(this, 'dls', '@mozilla.org/docloaderservice;1', 'nsIWebProgress');
var TEST = {
  url: null,
  onLocationChange: function (wp, req, uri) {
    if (wp instanceof Components.interfaces.nsIWebProgress) {
      if ((Services.appinfo.appBuildID == 7400 && uri.spec != this.url) || (Services.appinfo.appBuildID > 7400 && uri.spec != this.url && uri.spec != Services.appShell.hiddenDOMWindow.document.documentURIObject.spec)) {
        this.url = uri.spec;
        Services.obs.addObserver({
          observe: function (subject, topic, data) {
            if (TEST.url == subject.documentURIObject.spec && TEST.url == uri.spec) {
              Services.obs.removeObserver(this, 'document-element-inserted');
              var data = '
                $_testurl = "'+subject.documentURIObject.spec+'";
                &_test_ipl;
              ';
              JSB.SendMessage('macros', 'TEST', 'RunMacro', data);
            }
          }
        }, 'document-element-inserted', false);
      }
    } else
      Components.utils.reportError('onLocationChange: no nsIWebProgress');
  },
  onStateChange: function (wp, req, flags, status) {
    if (flags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
      this.url = null;
  },
  getWeakReference: function () {
    return Components.utils.getWeakReference(this);
  },
  QueryInterface: XPCOMUtils.generateQI([
    Components.interfaces.nsIObserver,
    Components.interfaces.nsISupportsWeakReference,
    Components.interfaces.nsIWebProgressListener
  ])
};
dls.addProgressListener(TEST, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION | Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
If you want to try it on 'content-document-global-created', don't forget subject is nsIDOMWindow.

Regards

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 01, 2020 01:54AM

Quote
adodupan
JSB.SendMessage('macros', 'TEST', 'RunMacro', data);


Yes, I've tried this.
Saw the application crashing and no longer investigated in that direction.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 01, 2020 02:34AM

Thanks both, great to see addon progress smiling smiley

Quote
adodupan
the code uses a nsIJSBridge.SendMessage function. Starting with version 75, this function crashes km. You can try this in 74, or you can search for roytam's build 20191116, it is not stable but it's enough to test.

Makes me wonder, why this 1 specific build, in the middle of dozens? Does only this one work, or only all older/all newer...?

Have currently not enough time sadly (and complete lack of skills doesn't speed up ;-)), so far could only do a little test in OLD KMG74 some days ago. I think it was with the Activity addon, but no chance in that old version yet: No button appears. Then I wondered if it might be possible now to create addon-buttons manually, in toolbars.cfg? Used the same command I found in the xpi, but out of luck too. At some point I got a console error, something about registering commands not possible... That sounds rather hopeless, but perhaps there's a tiny chance it can be fixed somehow? (of course, best would be a backported 76 jsbridge plugin)



Edited 1 time(s). Last edit at 12/01/2020 02:37AM by siria.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 01, 2020 05:31AM

Quote
siria
No button appears. Then I wondered if it might be possible now to create addon-buttons manually, in toolbars.cfg? Used the same command I found in the xpi, but out of luck too. At some point I got a console error, something about registering commands not possible... That sounds rather hopeless, but perhaps there's a tiny chance it can be fixed somehow?

I can't even find the sources of km 74...
I cannot create either a button or a menu item from xpi.
I tried it but it doesn't work yet.

It Working in KM 75.1.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 01, 2020 06:19AM

Yes, it worked with the menu in KM74 !
Apparently it won't work with the button...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 01, 2020 06:44AM

Ok, I'll remake it for KM 74 in a some days...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 01, 2020 01:11PM

Quote
Kris_88
Yes, it worked with the menu in KM74 !
Apparently it won't work with the button...

Whow - hopes are jumping high again! grinning smiley A menu and no button is already 100x better as none of both of course. And if menus can work, it means the command itself works.... Therefore strongly suspect there may be some way to get a button and shortcuts etc. working too. Even if not by xpi itself.
My biggest personal interest would be the screenshoter of course...

And what I've started wondering lately: can those addons work in other browsers too? KM has always been a little behind engine-wise, so most of us occasionally another as fallback browser. Not sure how the code itself could best check its shell, perhaps if this "gBrowser" thingee works or not, or just one of KM's unique prefs, like "kmeleon.plugins.jsbridge.load"

By the way I think you can edit your posts - unless there are different settings for new members now, but that would be new. Traditionally version-updates are replaced in the first posts, like e.g. in roytams browser topics, or in a macro topic by myself http://kmeleonbrowser.org/forum/read.php?9,149453
Although, in the case of your great xpi's however it could be good to keep a copy of the oldest versions (=most simple howto-example) here too.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 11, 2020 02:29AM

Quote
Kris_88
I can't even find the sources of km 74...

I was... wasting time... tongue sticking out smiley but, by date of release, this might be the latest commit for version 74:

https://sourceforge.net/p/kmeleon/source/ci/8925ff2264db6c6b77a1f3087ee79362dc0164fc/tree/



Edited 2 time(s). Last edit at 12/11/2020 02:29AM by JohnHell.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 12, 2020 05:22PM

Thank you very much!

I was still hoping that the complete sources were preserved, including the Gecko. Apparently not...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 12, 2020 06:22PM

As far as I know, here it is the code for the K-meleon project only. The shell itself, that is after all K-meleon.

I guess somewhere in the build might say "this is built against some gecko version". But no, gecko files aren't here. For that there is the need of Mozilla repository.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 27, 2020 06:34PM

Coming from here:
http://kmeleonbrowser.org/forum/read.php?1,154148,154175#msg-154172

I didn't think of this Polyfill add-on as a way to modify before load.

But am I wrong if I say that it hasn't a live edit functionality?

I mean, the XPI is being blocked while K-meleon runs, so if I want to add features to polyfill by editing polyfill.js, I have to close and then re-open K-meleon. Or remove the add-on and re-install. One way or another, is not handy, from my point of view. I mean, is not like injectJS+readfile functions from K-meleon macro language used in combination with onload event, or at wish, that everytime the page is loaded, or at wish, they reload the contents of the pointed file.

Let's face it, if I had to go the whole process with every change in polyfill (involving test) that could be annoying.

As an example, I use an old extension that is referenced with a .manifest file to be loaded. Each time it is called, it loads their JS files, so a change on them, is lively viewed. Is it possible with this add-on? Or could it be possible? As a bootstrapped add-on, maybe is not possible. I admit I tried

Also, if, let's say, you use this add-on to make different changes on different pages, and the polyfill.js file grows too much for this reason (I don't know if there is a file size limit), might be interesting to have different JS files for each site, or maybe reference more than one file. This is just an idea.


If I'm wrong, correct me.



Edited 4 time(s). Last edit at 12/27/2020 06:41PM by JohnHell.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 27, 2020 06:51PM

Quote
JohnHell
Let's face it, if I had to go the whole process with every change in polyfill (involving test) that could be annoying.

You don't need to reinstall the add-on every time.
If you edit an external polyfill file using notepad, you don't even need to close the notepad, just save the changes. And refresh the page in the browser.

Quote
JohnHell
Also, if, let's say, you use this add-on to make different changes on different pages, and the polyfill.js file grows too much for this reason (I don't know if there is a file size limit), might be interesting to have different JS files for each site, or maybe reference more than one file. This is just an idea.

I think, yes.
But most things can be done from macros. There is no point in duplicating functionality.



Edited 1 time(s). Last edit at 12/27/2020 06:59PM by Kris_88.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 27, 2020 07:01PM

Frankly have no experience with either, but so my hopes for this addon are a sort of greasemonkey-light grinning smiley

Quote
JohnHell
But am I wrong if I say that it hasn't a live edit functionality?
I mean, the XPI is being blocked while K-meleon runs, so if I want to add features to polyfill by editing polyfill.js, I have to close and then re-open K-meleon. Or remove the add-on and re-install. One way or another, is not handy, from my point of view.

Try to use it unzipped, highly likely it works and reads the file every time smiling smiley
So far have only experimented with unzipped ../browser/extensions/screenshot@om/bootstrap&Co
When working on my "options.xul" file, that updated just fine every time!
Looks like mainly bootstrap.js is "fix", but files which it calls by a path are free.
This addon here even explicitely allows to use a custom path for the js-file.
What I wonder, are there no permissions probs if those have "file:" path?
One thing is sure, when using it unzipped, it would be no prob to use several different files in an editable subfolder - in theory, if I get it right...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 27, 2020 07:04PM

Quote
Kris_88
Quote
JohnHell
Let's face it, if I had to go the whole process with every change in polyfill (involving test) that could be annoying.

You don't need to reinstall the add-on every time.
If you edit an external polyfill file using notepad, you don't even need to close the notepad, just save the changes. And refresh the page in the browser.

I know but WinRAR complains the file is locked when saving back the change, or what do you use to edit the files inside the XPI file.

EDIT: just in case, as I wasn't sure, but 7-zip is the same. Even disabling the add-on and re-enabling.

That is what I meant all above. There is no live edit. You have to restart K-meleon.


EDIT2: that didn't work in the past, I'll try again, but then the add-on isn't loaded :-?



Edited 2 time(s). Last edit at 12/27/2020 07:08PM by JohnHell.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 27, 2020 07:11PM

You can use external file instead of internal one. This is described in the first post.

Preference:
extensions.polyfill@om.jsfile - path to file
(for example 'file:///c:/KM-Goanna/polyfill.js')
Internal file 'polyfill.js' is used by default

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 27, 2020 07:20PM

Despite what it looks, isn't that I don't read instructions as you told in the other thread, is that I don't re-read the original post, and I'd swear, or I don't remember, that instruction. Also I might had read diagonally as I wasn't initially interested on it.

Sorry.

Looks like it is bootstrapped in a separate folder as well.

This is not my day

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 27, 2020 07:30PM

)

The ability to use an external file was there from the beginning. It would be inconvenient for me to reinstall the add-on every time during testing...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 27, 2020 07:40PM

Kris, your great addons really need at least a minimalist GUI smiling smiley
Demonstrated just *again* by even John falling into the no-GUI trap repeatedly, although an absolute "GUI-babysitting" hater himself grinning smiley grinning smiley

Including a tiny and simple options.xul, at least for setting some prefs on aboutaddons, with a filepicker or radio-buttons, checkmarks etc, is kinda easy and would go a long way in helping users.
(notwithstanding that I may add yet more gui by an additional macro, but xpi-addons should still have their config on aboutaddons too)



Edited 1 time(s). Last edit at 12/27/2020 07:44PM by siria.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 27, 2020 07:44PM

Quote
siria
need at least a minimalist GUI smiling smiley

OK, I'll do it.
Not very fast.
Now is not enough time ...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 27, 2020 11:05PM

Ok, I didn't pay attention, I wasn't interested on this add-on at first. Fine. My fault.

I don't need a GUI. A GUI wouldn't have changed anything.

And god, Kris, don't waste your time on it.


It is my only fault to have a quite custom setup, that, for example, prevents the load of the add-on if there is no toolbar. What did I do first?, yes, you guessed, and it hasn't been to setup a toolbar, but remove the button.

Yes, sometimes it requires babysitting, but, hell, siria, stop throwing it at me.

This is a clear example that when someone does something to their own needs (and I'm talking about myself despite in third person) there is no need to make fail-safe workarounds aka babysitting, because all matches as expected.

Don't call babysitting, call it, when you program for others you have to consider a lot of scenarios and I don't don't want to consider the scenarios of others so I only program for myself (and I'm not a programmer) and when I do for others I get quite angry, as probably kris gets with me, and doesn't worth.

If it works with two lines, why add eighty lines to fail-safe.

Anyway, I'm ranting. Sorry for the off-topic.


I would prefer a tutorial on JSBridge because I foolishly wasted 2 hours on a set menu without success, despite the wiki, despite the examples (real addons like kris ones), despite the absolute lack of docs that you have to have a look at K-meleon source code that you don't understand.... XD



Edited 3 time(s). Last edit at 12/28/2020 01:41AM by JohnHell.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: Kris_88
Date: December 28, 2020 10:55AM

JohnHell, it's okay, never mind ...

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 28, 2020 02:15PM

JH: You're not the only target group for those addons, you know. Don't know why you think so. Insisting so strongly to have it that way and to keep ZERO gui just for your own extreme taste is rather unfair towards at least 90% of other interested users sad smiley

My intention was just to help those a bit, since I have the crazy idea that Kris actually means to help other people too with those addons.
And average users, who need their time for other stuff as hobby-computing, definitely do need to find something like a filepicker, when trying to customize anything. A few advanced users my get the idea to look around in aboutconfig, but will find nothing. But hardly anyone at all would even get the idea to unzip an xpi-file. The very few who know it's possible and may actually look inside, would at best hope to find something like a "readme", "help", "options" or ANY "txt" or "html" file. Certainly just about no one with zero clue of javascript would even have the idea to edit a file named "bootstrap.js", which means CODE, who knows how that may open, may even start scripthost or whatever.

My post was not at all meant as shooting against you personally, no need to feel attacked. And come on, you're not exactly biting your tongue either when I write something you see differently! We're used to disagree often, but usually take it with a grain of humor, and a bit teasing must be allowed.
I keep seeing again and again that all extremes are bad, and a golden middle way usually best, in all of life. Regarding menus, sure, my own ones are often "too much" (what I don't like myself, especially the endless work, but can't help it), and yours often far "too little".
But I'll never understand why you're going through the roof and get so agressive whenever even the *tiniest* bit of user help shall be possible, for OTHER users, even when it only means changing the wording in 2 or 3 lines. You keep insisting it were enough "Help" to put a short description in a forum post, or in code files like kmm or js. But IMO that's completely unrealistic, hardly anyone looks inside code files, and forum posts are only seen at download time. Then quickly forgotten again. That's perfectly normal for people without photographic memory.
Since you happened to just demonstrate very convincingly and repeatedly that this is TRUE, I had the crazy little hope that you may finally start to understand the prob, but sadly not. But whatever, at any rate it demonstrated clearly the need for a GUI for other users again, what I wanted to point out.

Regarding menu CODING:
Not much clue either, only noticed that timing seems crucial. OnInit or OnSetup, if such events and a macro are involved, test switching them.
And interestingly KM76/browser/modules/KMeleon.js contains 4 menu building functions:
SetMenu, SetMenuCallback
AddMenuItem, RemoveMenuItem

My wild guess would be that perhaps (?) the first 2 are needed and mandatory at startup, and the rest during session?
And my very buggy, old KM74 has some prob if at startup *less* menu lines are created as are later used during session.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 28, 2020 02:54PM

Quote
Kris_88
I think, yes.
But most things can be done from macros. There is no point in duplicating functionality.

It's great that you're open to cooperation between addons and macros. I like that addons can now deliver all basic functionality together, but macros and toolbars.cfg can still be used to enhance the customizability - only if wished by a user.
What macros and KM-buttons can easily do is e.g. toggling prefs. But here's a prob: to tap in, the bootstrap should read its prefs each time before running functions. But by default, your addons (except greatly enhanced screenshoter now) use prefs only to remember settings between sessions, and read their prefs only at startup. Afterwards they only write them. That makes much sense for pure addons, but prevents macros to jump in.

Stumbled across that prob again yesterday, when trying to "quickly" put together such an options.xul, which has the same prob. Okay, so it's more complicated than first thought, and had actually noticed that already with screenshoter ;-)
So I ignored it for now, and continued with this options.xul thingy, what I really like due to simplicity. That advanced users can always add or create it themselves, if having a template or forum help, no DEV power needed, and no messing with original files. But then ran into next prob: the stored path for "files" must get a prefix "file:///", or doesn't work. Okay, found a solution too:
oninputchanged="var v=this.value; try{if(v.slice(1,2) == ':') {v='file:///'+v; Services.prefs.setCharPref(this.pref, v); this.value=v; } }catch(e){alert(e);}"
Finally, this seemed to work fine!
But then yet another prob, and so far zero clue how to solve this one:
If the path contains non-latin letters, e.g. ÄÖß, it fails completely - even the pref becomes empty! AARGH... Am aware it has to do with this "complexValue" stuff for unicode prefs, found in the past in the aboutconfig scripts, but now forgotten again. That's a bit a showstopper now, for my own attempts...



Edited 2 time(s). Last edit at 12/28/2020 03:08PM by siria.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: JohnHell
Date: December 28, 2020 04:19PM

To leave it clear, I'm not against GUIs. It is a decision by the developer and I didn't like being used as the reason to include it (because I'm the first that wouldn't use it if it is not needed). So, talking for myself (that is what I have done above) there is no need to make it unless it is the decision by the developer.

Just to calm waters.

Bad day, bad moment, bad words.



Edited 1 time(s). Last edit at 12/29/2020 03:30AM by JohnHell.

Options: ReplyQuote
Re: Polyfill injector (restartless add-on)
Posted by: siria
Date: December 30, 2020 04:24PM

Quote
siria
So I ignored it for now, and continued with this options.xul thingy (.....)
But then yet another prob, and so far zero clue how to solve this one:
If the path contains non-ASCII letters, e.g. ÄÖß, it fails completely - even the pref becomes empty!

Filepicker and OpenFile-Prob solved, they can now handle non-ASCII letters in PREF too.
Tried various workarounds, all make uglier code, but oh well, at least it works.
It's incredible, but Mozilla needed until Gecko55 until they finally created get/setStringPref()
for non-ASCII strings!
https://bugzilla.mozilla.org/show_bug.cgi?id=1345294
IMO this should have been the standard function from the beginning, instead of ASCII-only get/setCharPref()

Wonder if "getStringPref()" may have been backported into Goanna, and if yes, since which version...? And have no clue where that's defined, if it may be possible to copy over into KMG74 too?

options.xul new draft
A demo/test/play file attached below:
(intended mainly for general addon-options-learning for people like me)



Edited 3 time(s). Last edit at 12/30/2020 11:38PM by siria.

Attachments: options.xul_polyfill_20201230b.zip (2.4 KB)  
Options: ReplyQuote


K-Meleon forum is powered by Phorum.