미디어위키:Gadget-Rollback-Comment.js: 두 판 사이의 차이
백괴게임>탈퇴한 회원2 (새 문서: function addExtRbLink() { var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName ? function(a, b, c) { return a.getElementsByClassName(c) }...) |
백괴게임>유한림 잔글 (개선) |
||
1번째 줄: | 1번째 줄: | ||
function addExtRbLink() { | |||
var rbnode = [] | function addExtRbLink($container) { | ||
var $rbnode = $([]), index = {}; | |||
if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array) | if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array) | ||
for (var i = 0; i < rollbackLinksDisable.length; i++) | for (var i = 0; i < rollbackLinksDisable.length; i++) | ||
index[rollbackLinksDisable[i]] = true; | index[rollbackLinksDisable[i]] = true; | ||
if (!('user' in index) && wgCanonicalSpecialPageName == "Contributions" || | if ( | ||
!('user' in index) && wgCanonicalSpecialPageName == "Contributions" || | |||
!('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" || | !('recent' in index) && wgCanonicalSpecialPageName == "Recentchanges" || | ||
!('watchlist' in index) && wgCanonicalSpecialPageName == "Watchlist" | !('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 = | } | ||
$rbnode.each( function () { addExtendedRollbackLink( this ); } ); | |||
}; | }; | ||
29번째 줄: | 28번째 줄: | ||
else if (summary == "") | else if (summary == "") | ||
return true; | return true; | ||
this.href += "&summary=" + '[[ | this.href += "&summary=" + '[[Special:Contributions/$2|$2]]([[User talk:$2|토론]])의 편집을 전부 되돌림: '.replace(/\$2/g, user) + encodeURIComponent(summary.replace(/\$user/g, user)); | ||
return true; | return true; | ||
}; | }; | ||
42번째 줄: | 41번째 줄: | ||
var alink = rblink.cloneNode(true); | var alink = rblink.cloneNode(true); | ||
alink.className = ""; | alink.className = ""; | ||
alink.firstChild.nodeValue = "(+ 편집 요약)"; | alink.firstChild.nodeValue = "(+편집 요약)"; | ||
alink.onclick = confirmRollback; | alink.onclick = confirmRollback; | ||
rbnode.insertBefore(alink, rblink.nextSibling); | rbnode.insertBefore(alink, rblink.nextSibling); | ||
50번째 줄: | 49번째 줄: | ||
var blink = rblink.cloneNode(true); | var blink = rblink.cloneNode(true); | ||
blink.className = ""; | blink.className = ""; | ||
blink.firstChild.nodeValue = "(+ 봇)"; | blink.firstChild.nodeValue = "(+봇)"; | ||
blink.onclick = rollbackAsBot; | blink.onclick = rollbackAsBot; | ||
rbnode.insertBefore(blink, alink.nextSibling); | rbnode.insertBefore(blink, alink.nextSibling); |
2018년 1월 22일 (월) 20:33 기준 최신판
function addExtRbLink($container) {
var $rbnode = $([]), index = {};
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("추가할 편집 요약을 입력하세요\n\n$user 는 편집이 되돌려질 사용자 이름으로 치환됩니다.",
rollbackSummaryDefault);
if (summary == undefined)
return false;
else if (summary == "")
return true;
this.href += "&summary=" + '[[Special:Contributions/$2|$2]]([[User talk:$2|토론]])의 편집을 전부 되돌림: '.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)
{
if (wgUserGroups) {
if (!group || group.length == 0) group = '*';
return wgUserGroups.join (' ').indexOf (group) >= 0;
}
return false;
}