User:Infinite0694/Mass protecting tool ja.js

/** * Copy from w:User:Timotheus Canens/massprotect.js * https://en.wikipedia.org/wiki/User:Timotheus_Canens/massprotect.js * w:Special:PermaLink/676015629 * @license * @author w:en:User:Timotheus Canens */ // Tim's Mass Protection Tool // Adapted from User:Animum/massdelete.js

function doMassProtect { document.getElementById("wpMassProtectSubmit").disabled = true; var articles = document.getElementById("wpMassProtectPages").value.split("\n"); if(articles.length == 0) return; var text = document.getElementById("wpMassProtectText1").value; var wpEditProtectType = document.getElementById("wpEditProtectType").value,

wpProtectReasonSelection = document.getElementById("wpProtectReasonSelection").value, wpMassProtectSummary = document.getElementById("wpMassProtectSummary").value,

wpCreateProtectType = document.getElementById("wpCreateProtectType").value, wpMoveProtectType = document.getElementById("wpMoveProtectType").value, done = 0, failed = new Array, error = new Array, wpMassProtectExpiry = document.getElementById("wpMassProtectExpiry").value, wpMassProtectExpiry1 = document.getElementById("wpMassProtectExpiry1").value; var protectionstring = "protections=", expirystring = "expiry="; if(wpEditProtectType != "nochange"){ protectionstring += "edit=" + wpEditProtectType; expirystring += encodeURIComponent(wpMassProtectExpiry) + "|"; }   if(wpCreateProtectType != "nochange"){ protectionstring += "create=" + wpCreateProtectType; expirystring += encodeURIComponent(wpMassProtectExpiry == ""? wpMassProtectExpiry1 : wpMassProtectExpiry) + "|"; }   if(wpMoveProtectType != "nochange"){ protectionstring += "move=" + wpMoveProtectType; expirystring += encodeURIComponent(wpMassProtectExpiry == ""? wpMassProtectExpiry1 : wpMassProtectExpiry) + "|"; }   if(protectionstring == "protections=") return; expirystring = expirystring.replace(/\|$/, ''); // remove trailing pipe. for(i=0;i 0) { var req = new XMLHttpRequest; req.open("GET", wgScriptPath + "/api.php?format=json&action=query&prop=info&intoken=protect&titles=" + encodeURIComponent(article), false); req.send(null); var response = eval("(" + req.responseText + ")").query.pages; for(var index in response) { var info = response[index]; var token = info.protecttoken; var postdata = "format=json" + "&action=protect" + "&title=" + encodeURIComponent(article) + "&" + protectionstring + "&" + expirystring

+ "&reason=" + encodeURIComponent(wpProtectReasonSelection == "other" ? wpMassProtectSummary : wpProtectReasonSelection + (wpMassProtectSummary ? ": " + wpMassProtectSummary : ""))

+ "&token=" + encodeURIComponent(token); var req = new XMLHttpRequest; req.open("POST", wgScriptPath + "/api.php", false); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", postdata.length); req.send(postdata); if(eval("(" + req.responseText + ")").protect ) { //If protection successful, add a tag (if page exists), update the count and the button. if(text != ""){ var postdata = "format=json" + "&action=edit&nocreate=1" + "&title=" + encodeURIComponent(article) + "&prependtext=" + encodeURIComponent(text + "\n") + "&summary=" + encodeURIComponent(text) + "&token=" + encodeURIComponent(token); var req = new XMLHttpRequest; req.open("POST", wgScriptPath + "/api.php", false); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", postdata.length); req.send(postdata); }                   done++; document.getElementById("wpMassProtectSubmit").value = "(" + done + ")"; } else { //If not edited, add the title to the "failed" array and a description of the error to the "error" array. failed.push(article); error.push(eval("(" + req.responseText + ")").error.info); }           }        }        if(!articles[i+1]) { document.getElementById("wpMassProtectSubmit").value = "Done (" + edited + ")"; if(failed.length > 0) { var linkedList = ""; for(x=0; x" + failed[x] + ": " + error[x] + ""; //Links the titles in the "failed" array }               document.getElementById("wpMassProtectFailedContainer").innerHTML += ' Failed edits:' + linkedList + ''; }       }    } }

function gettext(title){ var req = new XMLHttpRequest; req.open("GET", wgScriptPath + "/api.php?action=query&prop=revisions&rvprop=content&format=json&indexpageids=1&titles="+encodeURIComponent(title), false); req.send(null); var response = eval('(' + req.responseText + ')'); pageid = response['query']['pageids'][0]; if (pageid == "-1") { delete req; return ''; }   var pagetext = response['query']['pages'][pageid]['revisions'][0]['*']; return pagetext; }

function ProtectExpiry(obj){ var frm=obj.form; var len=obj.options.length; /* プルダウンの項目数 */ if(obj.selectedIndex==eval(len-1)){ /*              入力欄を有効化 */           frm.elements["wpMassProtectExpiry1"].disabled=false; alert("その他欄に入力してください"); }else{ /*               入力欄を無効化 */           frm.elements["wpMassBlockExpiry1"].value=""; frm.elements["wpMassBlockExpiry1"].disabled=true; }   }

function massprotectform { var bodyContent = (skin == "cologneblue" ? "article" : "bodyContent"); document.getElementsByTagName("h1")[0].textContent = "Mass Protection"; document.title = "Mass-protecting tool - Wikipedia, the free encyclopedia"; document.getElementById(bodyContent).innerHTML = 'From Wikipedia, the free encyclopedia ' + '' +' 保護レベルを変更できます. 変更する場合は、保護の方針、半保護の方針に基づいているか確認して下さい. 有効期限のデフォルトは無期限です. 適切な期間・期限を指定してください. 「その他の期間」の記入例（ <a rel="nofollow" class="external text" href="http://www.gnu.org/software/tar/manual/html_node/Date-input-formats.html">GNU標準フォーマット</a> ）："12 hours"、"5 days"、"3 weeks"、"2012-09-25 20:00" （日時は<a href="/wiki/%E5%8D%94%E5%AE%9A%E4%B8%96%E7%95%8C%E6%99%82" title="協定世界時">UTC</a>）</li></ul></li>保護レベルを変更した場合、ページ上で保護テンプレート（<a href="/wiki/Template:%E4%BF%9D%E8%AD%B7" title="Template:保護">Template:保護</a>、<a href="/wiki/Template:%E5%8D%8A%E4%BF%9D%E8%AD%B7" title="Template:半保護">Template:半保護</a>など）を更新してください. </li></ul>' + ' ※警告 ：このツールを濫用した場合、すべて利用者の責任になります. '       + ' '        + '  保護の確認 ' +' 一括保護 ' + '保護対象の記事群(記事名を1行ごとに改行して書くこと): '               + '<textarea tabindex="1" name="wpMassProtectPages" id="wpMassProtectPages" rows="15" cols="80"> '

+ '保護タグを自動的にページに挿入（オプション）: <input type="text" name="wpMassProtectText1" list="Protect" placeholder="テキスト入力もしくはダブルクリック" size="50" autocomplete="off">' +' '

+ ' '       + ' ';

document.getElementById("wpProtectReasonSelection").onchange = function { var maxlength = (document.getElementById("wpProtectReasonSelection").value == "other" ? 255 : 253-document.getElementById("wpProtectReasonSelection").value.length); //It's 25e because of the two characters (": ") in addition to the selected summary. document.getElementById("wpMassProtectSummary").setAttribute("maxlength", maxlength); }

} if(wgNamespaceNumber == -1 && (wgPageName == "Special:MassprotectA" || wgPageName == "Special:MassProtectA") && /autoconfirmed/.test(wgUserGroups)) addOnloadHook(massprotectform); if(wgNamespaceNumber == -1 && (wgPageName == "特別:MassprotectA" || wgPageName == "Special:MassProtectA") && /autoconfirmed/.test(wgUserGroups)) addOnloadHook(massprotectform);