User:Gomdoli/common.js

/* 위한 Gadget Script
 * by wikipedia:ko:사용자:*devunt, from wikipedia:ko:사용자:*devunt/rollback.js



function addExtRbLink($container) { var $rbnode = $([]), index = {}; var wgCanonicalSpecialPageName = mw.config.get('wgCanonicalSpecialPageName'); var wgAction = mw.config.get('wgAction'); 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" ||        !('history' in index) && wgAction == "history" ||        !('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2"))    ) { $rbnode = $container.find( 'span.mw-rollback-link' ); }	$rbnode.each( function { addExtendedRollbackLink( this ); } ); } function confirmRollback { var url = this.href; var user = url.match(/[?&]from=([^&]*)/); if (!user) return; user = decodeURIComponent(user[1].replace(/\+/g, " ")); var summary = prompt("Summary:",                        rollbackSummaryDefault); if (summary === null) return false; else if (summary === "") return true; this.href += "&summary=" + 'Reverted edits by $2 (talk) to last revision by $1: '.replace(/\$2/g, user) + encodeURIComponent(summary.replace(/\$user/g, user)); return true; }

function rollbackAsBot { this.href += "&bot=1"; return true; } function addExtendedRollbackLink(rbnode) { var rblink = rbnode.getElementsByTagName("a")[0]; var alink = rblink.cloneNode(true); alink.className = ""; alink.firstChild.nodeValue = "(+summary)"; alink.onclick = confirmRollback; rbnode.insertBefore(alink, rblink.nextSibling); rbnode.insertBefore(document.createTextNode(" | "), alink); } if (typeof rollbackLinksDisable == 'undefined') rollbackLinksDisable = []; if (typeof rollbackSummaryDefault == 'undefined') rollbackSummaryDefault = "";

mw.hook( 'wikipage.content' ).add(addExtRbLink);

function userIsInGroup (group) { var wgUserGroups = mw.config.get('wgUserGroups'); if (wgUserGroups) { if (!group || group.length === 0) group = '*'; return wgUserGroups.join (' ').indexOf (group) >= 0; } return false; }