Jump to content

User:Svick/transcludeWatchlist.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Svick (talk | contribs) at 01:32, 20 February 2011 (Created page with 'importScript('User:Luasóg bot/framework.js'); if (typeof jQuery == 'undefined') importScriptURI('http://bits.wikimedia.org/skins-1.5/common/jquery.min.js'); ...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Luasóg bot/framework.js');
 
if (typeof jQuery == 'undefined')
  importScriptURI('http://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 = 100;
 
    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: wgUserName, wlprop: "ids|title|timestamp|user|comment", wllimit: transcludeWatchlistLimit};
 
    var callback = function(data) {
      var result = document.createElement("ol");
 
      for (var edit in data.query.watchlist) {
        var date = edit.timestamp.toDateString();
        result.innerHTML += '<li>(<a href="/w/index.php?diff=prev&oldid=' + edit.revid + '">diff</a>) ' + date + ' <a href="/wiki/' + escape(edit.title) + '">' + edit.title + '</a> <a href="/wiki/User:' + escape(edit.user) + '">' + edit.user + '</a> (' + edit.comment + ')</li>';
      }
      watchlistElem.replaceChild(watchlistElem.firstChild, result);
    }
 
    luasog.request(requestParams, callback);
  }
});