Jump to content

User:Xaradnam/monobook.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Xaradnam (talk | contribs) at 21:41, 22 October 2021 (c). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// <nowiki>

CurPg=mw.config.get('wgPageName'); // Current page name
CurNSnum=mw.config.get('wgNamespaceNumber');
//==================================================
function printValue(txt, val)
	{$('body').append('<center><h4><tt>' + txt + ': ' + val + ' </tt></h4></center>');}
//==================================================
if (CurPg=="User:Xaradnam/monobook.js") printValue("CurPg", CurPg);

//==================================================
// Add {{Unsigned}} to bottom of diff page (talk, WP, Template), with user and time filled in
// Works with any of the four Wiki date formats available in Prefs
if (mw.config.get('wgDiffNewId') && (CurNSnum%2==1||CurNSnum==4||CurNSnum==10)) 
	{
	const month=[];
	month["Jan"]="January"; month["Feb"]="February"; month["Mar"]="March";
	month["Apr"]="April"; month["May"]="May"; month["Jun"]="June";
	month["Jul"]="July"; month["Aug"]="August"; month["Sep"]="September";
	month["Oct"]="October"; month["Nov"]="November"; month["Dec"]="December";

	user=document.getElementById('mw-diff-ntitle2').firstChild.firstChild.firstChild.nodeValue;
	rev=document.getElementById('mw-diff-ntitle1').firstChild.firstChild.firstChild.nodeValue;
	var ts = new Date(rev.replace(/(Latest )?Revision as of /i, "").replace(",", ""));
	ts=ts.toUTCString();
	mth=ts.substr(8, 3);
	//UTCtime:     Sat,   06   Feb   2021   17 : 42  :00 GMT → 09:42, 6 February 2021 (UTC)
	ts=ts.replace(/..., (\d+) (...) (\d+) (\d+):(\d+).*/,     "$4:$5, $1 $2 $3 (UTC)");
	ts=ts.replace(mth, month[mth]).replace(", 0", ", ");
	$('body').append("<center><h4><tt>{{subst:Unsigned|"+user+"|"+ts+"}}</tt></h4></center>");
	}

//==================================================

// Section subscribe
if (CurNSnum%2==1||CurNSnum==4)
	{mw.util.addPortletLink(
		'p-tb',
		mw.config.get('wgScript')+'?title='+mw.config.get('wgPageName')+'&dtenable=1',
		'Section subscribe'
		);}
		
//==================================================

// Add unredirected link next to redirects; from [[User:BrandonXLF/NoRedirect.js]]
$(function() {
	$('#mw-content-text .mw-redirect').after(function() {
		return this.href.indexOf('redirect=no') !== -1 || this.href.indexOf('action=') !== -1  || this.href.indexOf('diff=') !== -1 ? ''
			: '<a href="' + this.href 
			+ (this.href.includes('?') ? '&' : '?')
			+'redirect=no" title="' + (this.title || this.href) +
			' (redirect pg)"><sup style="color:#97ad18"> Я</sup></a>';
	});
});


// ======== ADD DIFF INFO TO BOTTOM OF PAGE WHEN APPLICABLE =========
$.when( $.ready, mw.loader.using(["mediawiki.util"]) ).then( function () {
    var suffix = mw.config.get("wgDiffNewId");
    if (suffix) {
        if (document.getElementsByClassName("diff-multi").length ||
            CurPg === "Special:ComparePages") {
            suffix = mw.config.get("wgDiffOldId") + "/" + suffix;
        }
        $('body').append("<center><h4><tt>[[Special:Diff/" + suffix + "&#124;diff]]</tt></h4></center>");
    } else {
        var oldidMatch = mw.util.getParamValue("oldid");
        if(oldidMatch) {
            $('body').append("<center><h4><tt>[[Special:Permalink/" + oldidMatch + "&#124;permalink]]</tt></h4></center>");
        }
    }
} );

//==================================================

importScript('User:Shubinator/DYKcheck.js');


// </nowiki>