User:Daniel Gadsby/vector.js

importScriptURI('//ru.wikipedia.org/w/index.php?title=MediaWiki:Gadget-markblocked.js&action=raw&ctype=text/javascript'); importScript('User:Nageh/rollbackSum.js');

/* Modified version of User:Splarka/sysopdectector.js Sysop decrier/detector (rights group displayer), version [0.2.0a] Originally from http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js Notes: Options: var showUserGroupSettings = { 'IP':true, 'unregistered':true, 'registered':true, 'groups': true, 'editcount':true, 'regdate':true, 'blocked':true }; if((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && wgTitle.indexOf('/') == -1 && (wgAction != 'edit' || wgAction != 'submit')) addOnloadHook(showUserGroups) function showUserGroups { var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&format=json&callback=showUserGroupsCB&maxage=3600&smaxage=3600&usprop=blockinfo|groups|editcount|registration&list=users&ususers=' + encodeURIComponent(wgTitle); mw.loader.load(url); } function showUserGroupsCB(obj) { var show = window.showUserGroupSettings || false; if(!obj['query'] || !obj['query']['users']) return var user = obj['query']['users']; if(user.length == 0) return user = user[0]; var someHeading = document.getElementsByTagName('h1')[0] || document.getElementsByTagName('h2')[0] if(!someHeading) return var span = document.createElement('span'); var title = 'User:' + user['name'] + ' '; var text = ' '; if(user['invalid'] == '') { if(show && show.IP) text += '[IP] ' else title += '[invalid or IP username] ' } else if(user['missing'] == '') { if(show && show.unregistered) text += '[doesn\'t exist] ' else title += '[not a registered name] ' } else { if(show && show.registered) text += '[exists] ' else title += '[username registered] ' if(user['groups']) { if(show && show.groups || !show) text += ('[' + user['groups'].slice(2) + '] ').replace(/,/gi, ", ") else title += '[' + user['groups'] + '] ' }   if(user['editcount']) { if(show && show.editcount) text += '[' + user['editcount'] + ' edits] ' else title += '[' + user['editcount'] + ' edits] ' }   if(user['registration']) { if(show && show.regdate) text += '[created: ' + user['registration'].split('T')[0] + '] ' else title += '[created: ' + user['registration'] + '] ' }   if(user['blockedby']) { if(show && show.blocked) text += '[blocked] ' else text += '[currently blocked] ' } }  span.setAttribute('style','font-size:80%;'); span.setAttribute('class','detected-userrights'); span.appendChild(document.createTextNode(text)); someHeading.appendChild(span); someHeading.setAttribute('title',title); someHeading.className += ' detected-userrights-heading'; }
 * Fixed this up to use the new API fun stuffs.
 * Shows all groups now
 * nstab-user isn't available in all skins, all skins have at least one h1 or h2 I believe.
 * heading given class="detected-userrights-heading" and text in span class="detected-userrights"
 * Now supports an option system.
 * By setting a datalet true it shows in the header instead of the title.
 * Note, all are assumed false if omitted. All but 'groups' are assumed false if undefined.

/** * This script lets you use a custom summary with the rollback feature * by adding a "sum" link wherever a rollback link appears. When you * click "sum" you are prompted for a custom summary, and the script * adds an additional summary parameter to the rollback URL submitting it. * * For usage and extra options, see the talk page. */ function addSumLink { var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName ? function(a, b, c) { return a.getElementsByClassName(c) } : getElementsByClassName; if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array) for (var i = 0; i < rollbackLinksDisable.length; i++) index[rollbackLinksDisable[i]] = true; if (!('user' in index) && wgCanonicalSpecialPageName == "Contributions" ||       !('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" ||        !('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist") rbnode = gebcn(document.getElementById("bodyContent"), "span", "mw-rollback-link"); else if (!('history' in index) && wgAction == "history") rbnode = gebcn(document.getElementById("pagehistory"), "span", "mw-rollback-link"); else if (!('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2"))) rbnode = gebcn(diffnode, "span", "mw-rollback-link"); for (var i = 0, len = rbnode.length; i < len; i++) addRollbackSummaryLink(rbnode[i]); }; function confirmRollback { var url = this.href; var user = url.match(/[?&]from=([^&]*)/); if (!user) return; user = decodeURIComponent(user[1].replace(/\+/g, " ")); var summary = prompt("Enter a summary to use for rollback.\n\nLeave blank to use the default. $user will be replaced with \"" + user + "\".",                        rollbackSummaryDefault); if (summary == undefined) return false; else if (summary == "") return true; this.href += "&summary=" + encodeURIComponent(summary.replace(/\$user/g, user)); return true; }; function addRollbackSummaryLink(rbnode) { var rblink = rbnode.getElementsByTagName("a")[0]; var alink = rblink.cloneNode(true); alink.className = ""; //don't confuse other scripts alink.firstChild.nodeValue = "sum"; alink.onclick = confirmRollback; rbnode.insertBefore(alink, rblink.nextSibling); rbnode.insertBefore(document.createTextNode(" | "), alink); }; if (typeof rollbackLinksDisable == 'undefined') rollbackLinksDisable = []; if (typeof rollbackSummaryDefault == 'undefined') rollbackSummaryDefault = ""; $(addSumLink);