User:Voice of All/Protection/monobook.js: Difference between revisions

Content deleted Content added
m Add pipe.
m Remove legacy globals per phab:T72470 (via WP:JWB)
 
(14 intermediate revisions by 3 users not shown)
Line 1:
//<pre><nowiki>
 
//This function sets the selected values on the Confirm protection page
addOnloadHook(WP_PP_helper);
function WP_PP_helper()
{
if (document.title.indexOf('Wikipedia:List of protected pages') !=0 && document.title.indexOf('Protected pages') !=0 ) return;
if (document.title.indexOf('/') !=-1) return;
if (___location.href.search(/&action=/) !=-1) return;
addTab("javascript:addProtectReasons()", "Show reasons", "ca-reasons", "Show reasons", "");
}
 
//
var li_prot = 0;
function addProtectReasons()
{
if (!document.getElementsByTagName('ul')[0])
{alert('There are no elements in this list.'); return;}
if (!document.getElementsByTagName('ul')[0].getElementsByTagName('li')[0])
{alert('There are no elements in this list.'); return;}
var ls = document.getElementsByTagName('ul')[0].getElementsByTagName('li');
if (document.getElementById('contentSub').innerHTML.indexOf('Inserting log date and reasons for these items.') !=-1)
{alert('Results already shown.'); return;}
document.getElementById('contentSub').innerHTML += '<br>Inserting log date and reasons for these items.<br>';
consec_addReasons();
}
 
function consec_addReasons()
{
if (document.getElementsByTagName('ul')[0].getElementsByTagName('li')[li_prot])
{
var name = document.getElementsByTagName('ul')[0].getElementsByTagName('li')[li_prot].getElementsByTagName('a')[0].innerHTML;
var URL = '/w/index.php?title=Special:Log&limit=1&type=protect&page=' + escape(name) + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = fetch_log_contents;
xml_http.send(null);
}
else
{
document.getElementById('bodyContent').innerHTML = '<strong><span style="color:darkblue;">Log comments and dates inserted</span></strong><br>' + document.getElementById('bodyContent').innerHTML;
var l =document.getElementById('bodyContent').getElementsByTagName('li');
for (var i=0; i<l.length; i++)
{
var title = l[i].getElementsByTagName('a')[0].title;
var href = l[i].getElementsByTagName('a')[0].href;
if (title)
{
l[i].innerHTML = '<a href=javascript:WP_PP_unprotect("' + href.split('/wiki/')[1] + '")><strong>(release)</strong></a> ' + l[i].innerHTML;
}
}
}
}
 
function fetch_log_contents()
{
if (xml_http.readyState != 4) return;
var Done=0;
var xmlpage = xml_http.responseText.split("<div id='article'>")[1].split('<!-- end content -->')[0];
//UTC done
if (xmlpage.indexOf('<ul>') == -1)
{
document.getElementsByTagName('li')[li_prot].innerHTML += '<span style="color:red;"><strong> (error)</strong></span>';
}
else
{
//Current time
xmlpage = xmlpage.split('<ul>')[1].split('</ul>')[0];
if (xmlpage.indexOf('<li>') == -1)
{
document.getElementsByTagName('li')[li_prot].innerHTML += '<span style="color:red;"><strong> (error)</strong></span>';
}
else
{
var now = new Date();
var curtime = now.toUTCString().replace(/GMT/, "UTC");
var li_html = xmlpage.split('<li>')[1].split('</li>')[0];
var lasttime = li_html.split(' <a href=')[0].split(' <A href=')[0].split('<a href=')[0].split('<A href=')[0];
var totdays = getElapsedTime(curtime,lasttime);
totdays = Math.round((100)*totdays)/100;
var reason = li_html.split('<span class="comment">(')[1].split(')</span>')[0];
reason = reason.split(' [edit=')[0].split(' [move=')[0].split('[edit=')[0].split('[move=')[0];
if ( reason=='' ) reason = 'none given';
document.getElementsByTagName('li')[li_prot].innerHTML += '<br>[<strong>' + totdays + ' days old</strong>] <i>(' + reason + ')</i>';
}
}
li_prot += 1;
consec_addReasons();
}
 
function WP_PP_unprotect(title)
{
var URL = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=' + escape(title) + '&action=edit&jsaction=release';
window.open(URL,'WP:AUTOunpro:' + title,'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
}
Line 97 ⟶ 9:
function jssubmitclose()
{
var form = document.getElementById('editform').submit();
form.submit();
}
 
Line 143 ⟶ 54:
function protection_tabs()
{
if(document.getElementById('ca-protect'))
{document.getElementById('ca-protect').firstChild.innerHTML = '<span style="color:black;">protect</span>';}
if(document.getElementById('ca-unprotect'))
{document.getElementById('ca-unprotect').firstChild.innerHTML = '<strong>unprotect</strong>';}
var non_art = /Talk:| talk:|User:|MediaWiki:|Image:|Wikipedia:|Template:|Portal:|Help:|Main Page|Category:/;
if (document.title.indexOf("Editing ") != -1)
{
if(document.getElementById('ca-watch'))
{document.getElementById('ca-watch').firstChild.innerHTML = '[w]';}
if(document.getElementById('ca-unwatch'))
{document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';}
if (document.title.search(non_art) != -1)
{document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';}
if(document.getElementById('ca-protect'))
{document.getElementById('ca-protect').firstChild.innerHTML = '<span style="color:black;">P (off)</span>';}
if(document.getElementById('ca-unprotect'))
{document.getElementById('ca-unprotect').firstChild.innerHTML = '<strong>P (on)</strong>';}
if (document.title.indexOf("Editing User talk:") != -1)
{
Line 181 ⟶ 78:
addlilink(respfunc, 'javascript:rfpps()',"semi-pro", '');
addlilink(respfunc, 'javascript:rfppp()',"full-pro", '');
addlilink(respfunc, 'javascript:rfppm()',"salt-pro", '');
addlilink(respfunc, 'javascript:rfppm()',"move-pro", '');
addlilink(respfunc, 'javascript:rfpprv()',"!semi-pro", '');
Line 329 ⟶ 225:
else if (txtbox.value.search('\\{\\{(tl\\|)[Mm]oveprotect(ed)\\}\\}') != -1)
{var z_check = 'notag';}
else if (txtbox.value.search(/\{\{[Ss]protect|\{\{[Pp]rotect/) != -1)
{var z_check = 'notag';}
else
Line 433 ⟶ 329:
document.editform.wpTextbox1.value = '{{sprotected' + '}}\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value += '+{{sprotected' + '}}';
 
window1 = window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + type + '&jsaction=' + act + 'plist&jsaction=' + jstarget,
'WP:PP add',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
window2 = window.open('http://en.wikipedia.org/w/index.php?title=' + target.replace(/&/g,"%26") + '&action=protect&jsaction=sprotect',
'Page protect',
Line 493 ⟶ 387:
document.editform.wpTextbox1.value = '{{Vprotected' + '}}\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value += '+{{Vprotected' + '}}';
window1 = window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + type + '&jsaction=' + act + 'plist&jsaction=' + jstarget,
'WP:PP add',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
window2 = window.open('http://en.wikipedia.org/w/index.php?title=' + target.replace(/&/g,"%26") + '&action=protect&jsaction=fprotect',
'Page protect',
Line 539 ⟶ 430:
document.editform.wpTextbox1.value = '{{protected' + '}}\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value += '+{{protected' + '}}';
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + otherpro + '&jsaction=oplist&jsaction=' + jstarget,
'WP:PP add',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
window.open('http://en.wikipedia.org/w/index.php?title=' + target.replace(/&/g,"%26") + '&action=protect&jsaction=fprotect',
'Page protect',
Line 583 ⟶ 471:
document.editform.wpTextbox1.value = '{{sprotected' + '}}\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value += '+{{sprotected' + '}}';
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + otherpro + '&jsaction=oplist&jsaction=' + target,
'targetname',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
window.open('http://en.wikipedia.org/w/index.php?title=' + target.replace(/&/g,"%26") + '&action=protect&jsaction=sprotect',
'targetnameo',
Line 603 ⟶ 488:
{
var original = document.editform.wpTextbox1.value;
jstarget = URLEncoding(mw.config.get('wgTitle'));
if(m = document.editform.wpTextbox1.value.match(/\{\{(\w\w-|)semi-protected(2|)\}\}/) )
{
Line 679 ⟶ 564:
{
alert("Error: There is no recognized protection tag on this page.");
___location.href = 'http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgTitle').replace(/&/g,"%26") + '&action=protect&jsaction=unprotect';
return;
}
Line 691 ⟶ 576:
document.editform.wpSummary.value += 'Unprotected page -- removing tag';
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(whattag,'');
window.open('http://en.wikipedia.org/w/index.php?title=' + mw.config.get('wgTitle').replace(/&/g,"%26") + '&action=protect&jsaction=unprotect' + auto,
'WP:unpro:' + mw.config.get('wgTitle'),
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
jssubmitclose();
Line 1,038 ⟶ 923:
{
if (reg == 'a')
{
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + anontalk + '&jsaction=pdelist&jsaction=' + jstarget,
'WP:PP remove',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
gonotagged = 'yes';
}
else if (reg == 'r')
{
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + regtalk + '&jsaction=pdelist&jsaction=' + jstarget,
'Page unprotect',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
gonotagged = 'yes';
}
Line 1,060 ⟶ 939:
var level = prompt("Page no longer semi or fully protected (enter *s* or *f*)?");
if (level == 's')
{
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + usersemi + '&jsaction=pdelist&jsaction=' + jstarget,
'WP:PP remove',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
gonotagged = 'yes';
}
else if (level == 'f')
{
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + userfull + '&jsaction=pdelist&jsaction=' + target,
'Page unprotect',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
gonotagged = 'yes';
}
Line 1,102 ⟶ 975:
var whattag_upper = tagtype.substring(0,1).toUpperCase() + tagtype.substring(1,whattag.length);
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('{{' + tagtype + '}}','');
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('{{' + whattag_upper + '}}','');
var windowpp = window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit&section=' + type + '&jsaction=pdelist&jsaction=' + jstarget,
'WP:PP remove',
'___location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
var windowcp = window.open('http://en.wikipedia.org/w/index.php?title=' + target.replace(/&/g,"%26") + '&action=protect&jsaction=unprotect',
'Page unprotect',
Line 1,131 ⟶ 1,001:
}
}
else if (document___location.titlehref.indexOf('Confirm protection&action=protect') !==0-1)
{
var auto = '0';
Line 1,179 ⟶ 1,049:
edit.getElementsByTagName('option')[2].selected=false;
document.getElementById('mwProtect-reason').value = 'Heavy vandalism from multiple sources.';
document.getElementById('mwProtect-expiryexpires').value = '5 days';
}
if (action == 'fprotect')
Line 1,192 ⟶ 1,062:
edit.getElementsByTagName('option')[2].selected=true;
document.getElementById('mwProtect-reason').value = 'Users engaging in edit warring.';
document.getElementById('mwProtect-expiryexpires').value = 'infinite';
}
if (auto=='1') {document.getElementsByTagName('form')[0].click();}
Line 1,206 ⟶ 1,076:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting support.svg{{RFPP|20px]] '''Fully protected'''p}} due to [[Wikipedia:Edit war|revert warring]]. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page fully protected";
}
Line 1,215 ⟶ 1,085:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting support.svg{{RFPP|20px]] '''Semi-protected'''s}} due to heavy [[vandalism]]. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page semi-protected";
}
 
function rfpps()
{
var f = document.editform, t = f.wpTextbox1;
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting support.svg|20px]] '''SALTed''' to [[Wikipedia:Protected deleted pages|prevent re-creation]]. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page salted to prevent re-creation";
}
 
Line 1,233 ⟶ 1,094:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting support.svg{{RFPP|20px]] '''Move-protected'''m}} due to excessive renaming. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page move-protected";
}
Line 1,242 ⟶ 1,103:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting keep.svg{{RFPP|20px]] '''Un-protected.'''u}} It's been protected for long enough. Hopefully things have calmed down since then. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page un-protected";
}
Line 1,265 ⟶ 1,126:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting wait.svg{{RFPP|20px]]d}} Page " + value + "[http://en.wikipedia.org/w/index.php?title=Special:Log/protect&user=" + usera + "] by [[user:" + user + "|" + user + "]]" + ". " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: " + value + " by another Sysop";
}
Line 1,274 ⟶ 1,135:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting delete.svg{{RFPP|20px]]d}} It's still too soon to un-protect since the wave of [[Wikipedia:Vandalism|vandalism]] will likely continue immediately after un-protection. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: un-protection request denied";
}
Line 1,283 ⟶ 1,144:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting delete.svg{{RFPP|20px]]d}} The [[WP:AGF|reasonable]] issues that started the [[Wikipedia:Edit war|revert war]] do not yet seem to have been resolved. It is also too soon to assume that the editors have lost enough interest. Consider adding <no" + "wiki>{{Editprotected}}</nowiki> to the page's talk page to request small modifications, or making a '''significant edit request''' on this page for large edits that are agreed upon. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: un-protection request denied";
}
Line 1,292 ⟶ 1,153:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting delete.svg{{RFPP|20px]]d}} There is not enough recent activity to [[Wikipedia:Protection_policy#Uses|justify]] [[Wikipedia:Protection policy|protection]] at this time. For now, be sure to use descriptive [[Wikipedia:Edit summary|edit summaries]] and discuss edits on [[Wikipedia:Talk pages|talk]]. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: protection request denied";
}
Line 1,301 ⟶ 1,162:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting delete.svg{{RFPP|20px]]d}} There is not enough recent activity to [[Wikipedia:Protection_policy#Uses|justify]] [[Wikipedia:Semi-protection_policy|protection]] at this time. Just [[watchlist]] and revert any vandalism. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: protection request denied";
}
Line 1,310 ⟶ 1,171:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting delete.svg{{RFPP|20px]] The user has been [[WP:BLOCK|blocked]] from editing.b}} " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: user blocked";
}
Line 1,319 ⟶ 1,180:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting comment.svg{{RFPP|20px]]n}} The page is now monitored for changes by a [[User:VoABot II|bot]]. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page monitored by bot";
}
Line 1,328 ⟶ 1,189:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting wait.svg{{RFPP|20px]]ap}} The page is already protected. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page already protected";
}
Line 1,337 ⟶ 1,198:
if (t.value.length > 0)
t.value += '\n';
t.value +=":[[Image:Pictogram voting comment.svg{{RFPP|20px]]au}} The page is not actually protected. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "Response: page was not protected";
}
 
function URLEncoding(input)
{
var encodedInputString=escape(input);
encodedInputString=encodedInputString.replace(/\+/g, "%2B");
encodedInputString=encodedInputString.replace(/\//g,"%2F");
encodedInputString=encodedInputString.replace(/&/g,"%26");
var outputurl=encodedInputString;
return outputurl;
}
 
 
//</nowiki></pre>