User:Ruslik0/monobook.js

if(typeof Object.keys == "undefined") { Object.keys = (function {    var hasOwnProperty = Object.prototype.hasOwnProperty,        hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),        DontEnums = [             'toString', 'toLocaleString', 'valueOf', 'hasOwnProperty',            'isPrototypeOf', 'propertyIsEnumerable', 'constructor'        ],        DontEnumsLength = DontEnums.length;    return function (o) {        if (typeof o != "object" && typeof o != "function" || o === null)            throw new TypeError("Object.keys called on a non-object");        var result = [];        for (var name in o) {            if (hasOwnProperty.call(o, name))                result.push(name);        }        if (hasDontEnumBug) {            for (var i = 0; i < DontEnumsLength; i++) {                if (hasOwnProperty.call(o, DontEnums[i]))                    result.push(DontEnums[i]);            }           }        return result; }; }); } $(document).ready(function {       console.log($("#pt-notifications").text); var numNotes = /\d+/.exec($("#pt-notifications").text)[0]; if(numNotes == null) {		var data = {action:"query", meta:"notifications", format:"json", notprop:"count"}; $.post("/w/api.php", data, function(result)		{			numNotes = result.query.notifications.count;		}); }	if(numNotes > 0) {		var firstData = {action:"query", meta:"notifications", format:"json", notprop:"list",notlimit:numNotes} $.post("/w/api.php", firstData, function(firstResponse)		{			var keyArray = Object.keys(firstResponse.query.notifications.list)			if((mw.config.get('wgCanonicalNamespace') + ":" + mw.config.get('wgTitle')) == ("User_talk:" + mw.config.get('wgUserName')))			{				var idString = "";				for(i = 0; i < keyArray.length; i++)				{					if(firstResponse.query.notifications.list[keyArray[i]].category == "edit-user-talk" && typeof firstResponse.query.notifications.list[keyArray[i]].read == "undefined")					{						idString = idString + keyArray[i] + "|";					}				}				if(idString.length > 0)				{					var secondData = {action:"query", meta:"notifications", format:"json", notlimit:"1", notmarkread:idString};					$.post("/w/api.php", secondData);				}			}			else			{				for(i = 0; i < keyArray.length; i++)				{					if(firstResponse.query.notifications.list[keyArray[i]].category == "edit-user-talk" && typeof firstResponse.query.notifications.list[keyArray[i]].read == "undefined") {						var lastUser = firstResponse.query.notifications.list[keyArray[i]].agent.name; var orangeBarDiv = document.createElement("div"); orangeBarDiv.innerHTML = 'You have new messages (last change by '+lastUser+').'; orangeBarDiv.className = "usermessage"; $("#contentSub").after(orangeBarDiv); return; }				}			}		});	} });

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