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 = '<div id="loading">Loading …</div>';
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 += '<tr><td><b>¤</b></td><td>(<a href="/w/index.php?diff=prev&oldid=' + edit.revid + '">diff</a>...<a href="/w/index.php?title=' + edit.title + '&action=history">hist</a>) <b>' + (edit.minor == undefined ? '' : 'm') + (edit.bot == undefined ? '' : 'b') + '</b> <a href="/wiki/' + escape(edit.title) + '">' + edit.title + '</a></td><td>' + (parseInt(/[0-9]{2}/.exec(edit.timestamp))+24-5)%24 + /:[0-9]{2}:[0-9]{2}/.exec(edit.timestamp) + '</td><td> </td><td><a href="/wiki/User:' + escape(edit.user) + '">' + edit.user + '</a></td></tr>';
}
else
{
result.innerHTML += '<tr><td><b>¤</b></td><td>(<a href="/w/index.php?diff=prev&oldid=' + edit.revid + '">diff</a>...<a href="/w/index.php?title=' + edit.title + '&action=history">hist</a>) <b>' + (edit.minor == undefined ? '' : 'm') + (edit.bot == undefined ? '' : 'b') + '</b> <a href="/wiki/' + escape(edit.title) + '">' + edit.title + '</a></td><td>' + (parseInt(/[0-9]{2}/.exec(edit.timestamp))+24-5)%24 + /:[0-9]{2}:[0-9]{2}/.exec(edit.timestamp) + '</td><td> </td><td><a href="/wiki/User:' + escape(edit.user) + '">' + edit.user + '</a> (' + edit.parsedcomment + ')</td></tr>';
}
}
var watchlistElem = document.getElementById('transclude-watchlist');
watchlistElem.replaceChild(result, watchlistElem.firstChild);
}
luasog.request(requestParams, callback);
}
});