User:Floydian/callwatchlist.js
importScript('User:Luasóg bot/framework.js');
if (typeof jQuery == 'undefined')
mw.loader.load('//bits.wikimedia.org/skins-1.5/common/jquery.min.js');
addOnloadHook(function() {
var watchlistElem = document.getElementById('transclude-watchlist');
if (watchlistElem != null)
{
if (typeof transcludeWatchlistLimit == 'undefined')
transcludeWatchlistLimit = 10;
watchlistElem.innerHTML = '
var luasog = new Luasog("http://en.wikipedia.org/w/api.php");
var requestParams = {action:"query", list: "watchlist", wlexcludeuser: mw.config.get('wgUserName'), wlprop: "ids|title|timestamp|user|parsedcomment|flags", wllimit: transcludeWatchlistLimit};
var callback = function(data) {
var result = document.createElement("table");
result.setAttribute("width", "100%");
for (var i = 0; i < data.query.watchlist.length; i++) {
var edit = data.query.watchlist[i];
edit.timestamp = /[0-9]{2}:[0-9]{2}:[0-9]{2}/.exec(edit.timestamp);
if (edit.parsedcomment == '')
{
result.innerHTML += '
}
else
{
result.innerHTML += '
}
}
var watchlistElem = document.getElementById('transclude-watchlist');
watchlistElem.replaceChild(result, watchlistElem.firstChild);
}
luasog.request(requestParams, callback);
}
});