Page MenuHomeMiraheze

Add global gadget UTCLiveClok
Closed, ResolvedPublic

Description

Requesting the global gadget UTCLiveClock be added to Miraheze. Gadget adds a UTC clock to the user's personal toolbar that can be clicked to purge the current page. Link to MediaWiki source: https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock.js

Event Timeline

AmandaCath added a project: MediaWiki.

There is no method to globally implement a gadget, though there is an absolutely ancient upstream task about doing so (T22153). As I don't see that being implemented any time soon, it's likely the closest you can come is by using the User:Name/global.js page to load in the script globally.

You can add the following to Special:MyPage/global.js on meta:

mw.loader.load("https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock.js?action=raw&ctype=text/javascript");
mw.loader.load("https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock.css?action=raw&ctype=text/css", "text/css");
mw.loader.load("https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock-pagestyles.css?action=raw&ctype=text/css", "text/css");

However, on individual wikis, I would still recommend adding the gadget (when you have the tools to do so). To prevent conflicts with the local gadget and your global.js page, you can wrap the lines in an if statement to prevent it from loading in on certain wikis. For example:

if( !["metawiki", "testwiki"].includes($mw.config.get("wgDBname")) ) {
    mw.loader.load("https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock.js?action=raw&ctype=text/javascript");
    mw.loader.load("https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock.css?action=raw&ctype=text/css", "text/css");
    mw.loader.load("https://www.mediawiki.org/wiki/MediaWiki:Gadget-UTCLiveClock-pagestyles.css?action=raw&ctype=text/css", "text/css");
}

Would prevent the scripts from being run on meta.miraheze.org and publictestwiki.com, and all you need to do to expand it, is add another wiki's dbname to the array (you can get the dbname by running mw.config.get("wgDBname") in your browser's console window, or just add -wiki to the subdomain).

Reception123 assigned this task to Void.

Per Void's detailed answer, there is nothing more that can be done at a global level except what Void said.