User:Xaradnam/monobook.js: Difference between revisions
Appearance
Content deleted Content added
m + |
m <nowiki> |
||
Line 1: | Line 1: | ||
// <nowiki> |
|||
CurPg=mw.config.get('wgPageName'); // Current page name |
CurPg=mw.config.get('wgPageName'); // Current page name |
||
//================================================== |
//================================================== |
||
Line 27: | Line 29: | ||
ts=ts.replace(mth, months[mth]); |
ts=ts.replace(mth, months[mth]); |
||
ts=ts.replace(", 0", ", "); |
ts=ts.replace(", 0", ", "); |
||
$('body').append("<center><h4><tt>{{subst:Unsigned|"+username+"|"+ts+"}}</tt></h4></center>"); |
|||
printValue("ts", "<!-- Template:Unsigned --><span class="autosigned" style="font-size:85%;">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[User:"+username+"|"+username+"]] ([[User talk:"+username+"#top|talk]] • [[Special:Contributions/"+username+"|contribs]]) "+ts+" (UTC)</span>"); //////////////////// |
|||
} |
} |
||
Line 77: | Line 79: | ||
importScript('User:Shubinator/DYKcheck.js'); |
importScript('User:Shubinator/DYKcheck.js'); |
||
// </nowiki> |
Revision as of 08:14, 21 October 2021
// <nowiki>
CurPg=mw.config.get('wgPageName'); // Current page name
//==================================================
function printValue(txt, val)
{$('body').append("<center><h4><tt>" + txt + ": " + val + " </tt></h4></center>");}
//==================================================
printValue("CurPg", CurPg);
//==================================================
// Add {{Unsigned}} to bottom of diff pages with user and time filled in
//if (mw.config.get('wgRevisionId'))
{
const months=[];
months["Jan"]="January"; months["Feb"]="February"; months["Mar"]="March";
months["Apr"]="April"; months["May"]="May"; months["Jun"]="June";
months["Jul"]="July"; months["Aug"]="August"; months["Sep"]="September";
months["Oct"]="October"; months["Nov"]="November"; months["Dec"]="December";
// user=document.getElementById('mw-diff-ntitle2').firstChild.firstChild.firstChild.nodeValue;
// ts=document.getElementById('mw-diff-ntitle1').firstChild.firstChild.firstChild.nodeValue.replace(/(Latest )?Revision as of /i, "");
username="Somebody"; /////////////////////
wpts = "16:42, 6 February 2021"; ///////////////////
wpts=wpts.replace(",", "");
var ts = new Date(wpts);
ts=ts.toUTCString();
mth=ts.substr(8, 3);
//UTCtime: Sat, 06 Feb 2021 17 : 42 :00 GMT -> WP 09:42, 6 February 2021 (UTC)
ts=ts.replace(/..., (\d+) (...) (\d+) (\d+):(\d+).*/, "$4:$5, $1 $2 $3 (UTC)");
ts=ts.replace(mth, months[mth]);
ts=ts.replace(", 0", ", ");
$('body').append("<center><h4><tt>{{subst:Unsigned|"+username+"|"+ts+"}}</tt></h4></center>");
}
//==================================================
// Section subscribe
CurNSnum=mw.config.get('wgNamespaceNumber');
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)"><span style="color:#534e8a"><sup> Я</sup></span></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 + "|diff]]</tt></h4></center>");
} else {
var oldidMatch = mw.util.getParamValue("oldid");
if(oldidMatch) {
$('body').append("<center><h4><tt>[[Special:Permalink/" + oldidMatch + "|permalink]]</tt></h4></center>");
}
}
} );
//==================================================
importScript('User:Shubinator/DYKcheck.js');
// </nowiki>