User:Writ Keeper/Scripts/liveWatchlist.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Writ Keeper/Scripts/liveWatchlist. |
watchlistLastRetrieved;
apiProps = {"action":"query","list":"watchlist","wlprop":"ids|title|user|comment|timestamp|sizes","wlallrev":"true"}
watchlistUpdateClass= "watchlistUpdate";
function refreshWatchlist()
{
}
function populateWatchlist()
{
if($("#mw-liveWatchlistUL").length > 0)
{
$.post("\w\api.php",apiProps, function(response)
{
watchlistLastRetrieved = new Date(Date.now()).toISOString();
});
}
}
function renderWatchlistEntry(var watchListJSON)
{
var resultString = "";
var editTime = new Date(watchlistJSON.timestamp);
var editDelta = watchlistJSON.newlen - watchlistJSON.oldlen;
if(watchlistJSON.type === "edit")
{
resultString = '<li class="mw-changeslist-liu ">(<a href="/w/index.php?title=' + watchlistJSON.title + '&curid=' + watchlistJSON.pageid + '&diff=' + watchlistJSON.revid + '&oldid=' + watchlistJSON.old_revid + '" class="mw-changeslist-diff nonimage userlink" title="' + watchlistJSON.title + '">diff</a> | <a href="/w/index.php?title=' + watchlistJSON.title + '&curid=' + watchlistJSON.pageid + '&action=history" class="mw-changeslist-history nonimage userlink" title="' + watchlistJSON.title + '">hist</a>) <span class="mw-changeslist-separator">. .</span><a href="#" id="' + watchlistJSON.revid + '" class=" nonimage" title="#"><b><span style="color:black;"> [</span><span style="color:#339900;">inspect diff</span><span style="color:black;">] </span></b></a><span class="mw-title"><a href="/wiki/' + watchlistJSON.title + '" class="mw-changeslist-title nonimage userlink" title="' + watchlistJSON.title + '">' + watchlistJSON.title + '; </a></span>; <span class="mw-changeslist-date">' + editTime.getHours() + ':' + editTime.getMinutes() + '</span><span class="mw-changeslist-separator">. .</span><span dir="ltr" class="mw-plusminus-' + (editDelta >= 0 ? 'pos' : 'neg') + '" title="' + watchlistJSON.newLen + '" bytes after change">(' + (editDelta >= 0 ? '+' : '' + editDelta) + ')</span> <span class="mw-changeslist-separator">. .</span> <a href="/wiki/User:' + watchlistJSON.user + '" class="mw-redirect mw-userlink nonimage userlink redirect" title="' + watchlistJSON.title + '"><bdi>' + watchlistJSON.user + '</bdi></a><span class="mw-usertoollinks">(<a href="/wiki/' + watchlistJSON.title + '" class="mw-usertoollinks-talk nonimage userlink" title="' + watchlistJSON.title + '">talk</a> | <a href="/wiki/Special:Contributions/' + watchlistJSON.user + '" class="mw-usertoollinks-contribs nonimage userlink" title="Special:Contributions/' + watchlistJSON.user + '">contribs</a> |<a href="/wiki/Special:Block/' + watchlistJSON.user + '" class="mw-usertoollinks-block nonimage" title="Special:Block/' + watchlistJSON.user + '">block</a>)</span> <span class="comment">(' + watchlistJSON.comment + ')</span></li>';
}
else if (watchlistJSON.type === "new")
{
resultString = '<li class="mw-changeslist-liu mw-changeslist-src-mw-new">(diff | <a href="/w/index.php?title=' + watchlistJSON.title + '&curid=' + watchlistJSON.pageid + '&action=history" class="mw-changeslist-history nonimage" title="' + watchlistJSON.title + '">hist</a>) <span class="mw-changeslist-separator">. .</span><abbr class="newpage" title="This edit created a new page">N</abbr><span class="mw-title"><a href="/wiki/' + watchlistJSON.title + '" class="mw-changeslist-title nonimage" title="' + watchlistJSON.title + '">' + watchlistJSON.title + '; </a></span>; <span class="mw-changeslist-date">' + editTime.getHours() + ':' + editTime.getMinutes() + '</span><span class="mw-changeslist-separator">. .</span><span dir="ltr" class="mw-plusminus-pos" title="' + watchlistJSON.newlen + ' bytes after change">(+' + watchlistJSON.newlen + ')</span> <span class="mw-changeslist-separator">. .</span> <a href="/wiki/User:' + watchlistJSON.user + '" class="mw-userlink nonimage userlink protection-edit-sysop-indef protection-edit-sysop protection-move-sysop-indef protection-move-sysop" title="User:' + watchlistJSON.user + '"><bdi>' + watchlistJSON.user + '</bdi></a><span class="mw-usertoollinks">(<a href="/wiki/User_talk:' + watchlistJSON.user + '" class="mw-usertoollinks-talk nonimage userlink" title="User talk:' + watchlistJSON.user + '">talk</a> | <a href="/wiki/Special:Contributions/' + watchlistJSON.user + '" class="mw-usertoollinks-contribs nonimage userlink" title="Special:Contributions/' + watchlistJSON.user + '">contribs</a> | <a href="/wiki/Special:Block/' + watchlistJSON.user + '" class="mw-usertoollinks-block nonimage" title="Special:Block/' + watchlistJSON.user + '">block</a>)</span> <span class="comment">(' + watchlistJSON.comment + ')</span></li>';
}
else if (watchlistJSON.type === "log")
{
resultString = '<li class="mw-changeslist-liu mw-changeslist-src-mw-log">(log); <span class="mw-changeslist-date">' + editTime.getHours() + ':' + editTime.getMinutes() + '</span><span class="mw-changeslist-separator">. .</span> <a href="/wiki/User:' + watchlistJSON.user + '" class="mw-userlink nonimage userlink protection-edit-sysop-indef protection-edit-sysop protection-move-sysop-indef protection-move-sysop" title="User:' + watchlistJSON.user + '"><bdi>' + watchlistJSON.user + '</bdi></a><span class="mw-usertoollinks">(<a href="/wiki/User_talk:' + watchlistJSON.user + '" class="mw-usertoollinks-talk nonimage userlink" title="User talk:' + watchlistJSON.user + '">talk</a> | <a href="/wiki/Special:Contributions/' + watchlistJSON.user + '" class="mw-usertoollinks-contribs nonimage userlink" title="Special:Contributions/' + watchlistJSON.user + '">contribs</a> | <a href="/wiki/Special:Block/' + watchlistJSON.user + '" class="mw-usertoollinks-block nonimage" title="Special:Block/' + watchlistJSON.user + '">block</a>)</span> did something to <a href="/wiki/' + watchlistJSON.title + '" class="mw-userlink nonimage userlink" ><bdi>' + watchlistJSON.title + '</bdi></a>with the comment: "<span class="comment">' + watchlistJSON.comment + '</span>"</li>';
}
return resultString;
}