잔글 (GTX1060님이 사용자:Gomdoli4696/common.js 문서를 사용자:Gomdoli/common.js 문서로 이동했습니다: "Gomdoli4696" 사용자의 이름을 "Gomdoli"(으)로 바꿀 때 문서를 자동으로 이동했습니다) |
|||
(다른 사용자 한 명의 중간 판 23개는 보이지 않습니다) | |||
1번째 줄: | 1번째 줄: | ||
$( | /* | ||
* 롤백 부가 기능 스크립트 | |||
** by [[wikipedia:ko:사용자:*devunt]], from [[wikipedia:ko:미디어위키:Gadget-RollbackComment.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("추가할 편집 요약을 입력하세요.", | |||
rollbackSummaryDefault); | |||
if (summary === null) | |||
return false; | |||
else if (summary === "") | |||
return true; | |||
this.href += "&summary=" + '[[특수:기여/$2|$2]]([[사용자토론:$2|토론]])의 편집을 [[특수:기여/$1|$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 = "(+편집 요약)"; | |||
alink.onclick = confirmRollback; | |||
rbnode.insertBefore(alink, rblink.nextSibling); | |||
rbnode.insertBefore(document.createTextNode(" | "), alink); | |||
if (userIsInGroup('sysop')) | |||
{ | |||
// 관리자라면 (+봇) 버튼 추가 | |||
var blink = rblink.cloneNode(true); | |||
blink.className = ""; | |||
blink.firstChild.nodeValue = "(+봇)"; | |||
blink.onclick = rollbackAsBot; | |||
rbnode.insertBefore(blink, alink.nextSibling); | |||
rbnode.insertBefore(document.createTextNode(" | "), blink); | |||
} | |||
} | |||
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; | |||
} |
2020년 10월 27일 (화) 18:49 기준 최신판
/* * 롤백 부가 기능 스크립트 ** by [[wikipedia:ko:사용자:*devunt]], from [[wikipedia:ko:미디어위키:Gadget-RollbackComment.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("추가할 편집 요약을 입력하세요.", rollbackSummaryDefault); if (summary === null) return false; else if (summary === "") return true; this.href += "&summary=" + '[[특수:기여/$2|$2]]([[사용자토론:$2|토론]])의 편집을 [[특수:기여/$1|$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 = "(+편집 요약)"; alink.onclick = confirmRollback; rbnode.insertBefore(alink, rblink.nextSibling); rbnode.insertBefore(document.createTextNode(" | "), alink); if (userIsInGroup('sysop')) { // 관리자라면 (+봇) 버튼 추가 var blink = rblink.cloneNode(true); blink.className = ""; blink.firstChild.nodeValue = "(+봇)"; blink.onclick = rollbackAsBot; rbnode.insertBefore(blink, alink.nextSibling); rbnode.insertBefore(document.createTextNode(" | "), blink); } } 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; }