User:Sam Barsoom/monobook.js

importScript('User:AzaToth/twinkle.js');

function diff_only_buttons { handle_diff('differences-prevlink'); handle_diff('differences-nextlink'); function handle_diff(diff_id) {   var link = document.getElementById(diff_id); if (link == null) {     return false; }   var diff_only = document.createElement('a'); diff_only.id = diff_id; diff_only.href = link.href + '&diffonly=1'; diff_only.appendChild(document.createTextNode(' - (Diff only)')); link.parentNode.appendChild(diff_only); return true; } } $(diff_only_buttons)

// Adds a "Changes since last load" link to your watchlist. $(function {    if (!wgCanonicalSpecialPageName || wgCanonicalSpecialPageName != "Watchlist") return;    if (!document.forms[0] || !document.forms[0].namespace) return;    var link = document.createElement('a');    link.id = 'listSince';    link.href = '#listSince';  // must have a href to show as link!    var then = +(new Date);    var fixLinkHref = function  {        var url = window.location.href.split('#')[0];        var days = ( +(new Date) - then )/(1000 * 3600 * 24);        if (url.match(/[?&]days=/))            this.href = url.replace(/([?&]days=)[^&]*/, '$1'+days);        else            this.href = url + (url.indexOf('?') < 0 ? '?':'&') + 'days=' + days;       return true;    };    link.onclick = fixLinkHref;    link.onmousedown = fixLinkHref;  // react to middle clicks too    var frag = document.createDocumentFragment;    frag.appendChild(document.createTextNode(' | '));    frag.appendChild(link);    link.appendChild(document.createTextNode('Changes'));    frag.appendChild(document.createTextNode(' since last load.'));    // just one little ID attribute would be _so_ nice...    var nsSelectForm = document.getElementsByTagName('form')[0];    nsSelectForm.parentNode.insertBefore(frag, nsSelectForm); });

//Mass rollback function //Written by John254 //Adapted from User:Mr.Z-man/rollbackSummary.js //Instructions: Selecting the "rollback all" tab when viewing a user's contributions history //will open all rollback links displayed there. (Use with caution) function rollbackEverythingButton { var hasRollback = getElementsByClassName(document, "span", "mw-rollback-link"); if (hasRollback[0] && (document.title.indexOf("User contributions") != -1) ) { mw.util.addPortletLink('p-cactions', 'javascript:rollbackEverything', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here"); } } $(rollbackEverythingButton); function rollbackEverything { for (var i in document.links) { if (document.links[i].href.indexOf('action=rollback') != -1) { window.open(document.links[i].href); }   } }