User:OneTwoThreeFall/LastEdited.js

/** * this is a derivative of the LastEdited script by Slyst * original script available at w:c:dev:LastEdited * source revision: */

/*jslint browser, long */ /*global jQuery, mediaWiki */

(function ($, mw) {   "use strict";

if (       window.lastEditedLoaded ||        !mw.config.get("wgIsArticle") ||        !mw.config.get("wgArticleId") ||        mw.util.getParamValue("diff") ||        mw.util.getParamValue("oldid")    ) { return; }   window.lastEditedLoaded = true;

function main(data) { var rv = data.query.pages[mw.config.get("wgArticleId")].revisions["0"];

var user = "" + rv.user + ""; var timestamp = new Date(rv.timestamp).toUTCString.slice(5, -3) + "(UTC)";

var html = " Last edited by " + user + " on " + timestamp; if (rv.parentid) { html += " (diff) "; } else { html += " N "; }       if (rv.minor !== undefined) { html += "m "; }       if (rv.parsedcomment) { html += " (" + rv.parsedcomment + ") "; }       html += " ";

$("#siteSub, .page-header__title").after(html); }

function init { mw.util.addCSS(".lastEdited { color: #888; font-size: 11px; }");

$.get(mw.util.wikiScript("api"), {           action: "query",            prop: "revisions",            rvprop: "ids|flags|user|timestamp|parsedcomment",            titles: mw.config.get("wgPageName"),            format: "json"        }).done(main); }

$(init); }(jQuery, mediaWiki));