I've got my own opinions here, but before I voice them I'd like to hear from the community. What would you (script authors especially) like to see happen? Do you have other ideas I haven't listed?
An alternate related approach is to look at the implementation of TM, and advance that as TM did with GM. How did they implement asynchronous functions for the webextensions API? Learn from the TM folk in terms of how they went about their GM fork. They must already be supporting async calls in the API already, given its webextensions-based anyway.
Given this current pattern:
var sData = GM_getValue("serialized");
var oData = JSON.parse(sData);
// useful things happen here
Where I've heard other people describe it, it sounds like they've made compromises to provide compatible calls. Ones I'm not excited about emulating.
GM.getValue("serialized").then(sData => {var oData = JSON.parse(sData);// useful things happen here.});Which is a change, but hopefully not a huge one.
On Sun, May 14, 2017 at 1:39 AM, <damo....@gmail.com> wrote:An alternate related approach is to look at the implementation of TM, and advance that as TM did with GM. How did they implement asynchronous functions for the webextensions API? Learn from the TM folk in terms of how they went about their GM fork. They must already be supporting async calls in the API already, given its webextensions-based anyway.Tampermonkey is not open source, so I've got no plans to try to "take" from it. Where I've heard other people describe it, it sounds like they've made compromises to provide compatible calls. Ones I'm not excited about emulating.
On Sun, May 14, 2017 at 5:15 PM, jscher2000 <jsche...@gmail.com> wrote:Given this current pattern:
var sData = GM_getValue("serialized");
var oData = JSON.parse(sData);
// useful things happen hereGood point. If we go all-new async (2.2), I'd expect this would turn into something like:GM.getValue("serialized").then(sData => {var oData = JSON.parse(sData);// useful things happen here.});
let sData = await GM.getValue("serialised") ;
let oData = JSON.parse(sData) ;
// useful things still happen here.
Or using ES2017, something like:
let sData = await GM.getValue("serialised") ;
let oData = JSON.parse(sData) ;
// useful things still happen here.
// @run-at document-start
console.log("Hiding body") ;
GM_addStyle("body {visibility: hidden;}") ;
console.log("Body hidden") ;
window.document.getElementsByTagName("body")[0].style.visibility = "visible" ;
In the past, there was no alternative to GreaseMonkey. Now there is. If a script doesn't work in GreaseMonkey, many people will shift over to TamperMonkey.
Async APIs might* be a good idea going forward, but priority should be on making sure that you don't break most scripts.
Also, Tampermonkey has a previous version which was open source, so you might be able to pull from that.*I say might because I'm not sold on promises. I still can't get my head around them, as I can't find anything that really explains them except to programmers already used to similar concepts in other languages. And I
think most userscript authors are amateur.
Plus, well, you aren't the only one defining APIs anymore.
* I'm getting error messages when opening some urls, mostly with plain text file:Could not execute user script: Error: Message manager disconnected execute.js:27:9
<anonymous> moz-extension://0c788338-a98f-4ea8-947a-5825864dacf0/src/bg/execute.js:27:9
* When GM is disabled, opening "Manage User Script", will show "No user scripts installed" and menu from the GM icon in the toolbar says "No user scripts installed!".
* One big "feature" i liked from GM is that the userscripts overview was tightly integrated with Firefox's "about:addons" special page. I get that this is not possible anymore (right?), but could the new userscripts overview page be styled more like Firefox...
* Not having the arrow/pull-down-menu besides the GM icon in the toolbar has me confused many times.
* The menu from the GM icon in the toolbar doesn't look native.
Now, if the purpose, functionality or eventually even APIs were the same, why do we even need Userscripts?