wikimedia-gadgets / twinkle

The English Wikipedia twinkle javascript helper
http://en.wikipedia.org/wiki/Wikipedia:Twinkle
Other
135 stars 149 forks source link

User:AzaToth/twinkle.js #749

Closed siddharthvp closed 4 years ago

siddharthvp commented 4 years ago

Yesterday, I updated the list of most imported scripts. It turns out that User:AzaToth/twinkle.js remains the 2nd-most installed userscript on the pedia with a whooping 5508 installs!

I suggest that the content of User:AzaToth/twinkle.js be changed to

mw.loader.using(['user.options', mediawiki.api']).then(function() {
    if (mw.user.options.get('gadget-Twinkle') === null) {
        new mw.Api().saveOption('gadget-Twinkle', '1');
    }
});

This enables the gadget, so that subsequently, the gadget is fetched directly w/o going through the userscript page. This leads to more accurate gadget usage statistics. Also, this makes the load experience consistent across all users since I guess gadgets are loaded before userscripts.

Ping @azatoth.


user.options values are string '1' for user-enabled gadgets, number 1 for default-enabled gadgets, and 0 for default gadgets disabled by user. Non-default gadgets that are not enabled aren't there in the user.options object at all. When accessed using mw.user.options.get(), it gives null.

Amorymeltzer commented 4 years ago

See also #85

Amorymeltzer commented 4 years ago

@azatoth Are you opposed to this? It's heavy-handed but would be a marginal improvement. Another option would be to use mw.notify to annoy folks until they change to the gadget.

Amorymeltzer commented 4 years ago

I've gone and done this. I considered just importing the notification note (like the submodules do) but figured it'd be simpler to just take care of it for folks, given how long it's "just worked."