User:Voice of All/AutoUpdate/monobook.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
The accompanying .css page for this skin can be added at User:Voice of All/AutoUpdate/monobook.css. |
//<pre><nowiki>
//---------------------------------------------------------------
// =-=-=- HELPER FUNCTIONS -=-=-=
function addlilink(tabs, url, name, id, title, key){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
if(id)
{
if(key && title)
{
ta[id] = [key, title];
}
else if(key)
{
ta[id] = [key, ''];
}
else if(title)
{
ta[id] = ['', title];
}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function addToolboxLink(url, name, id){
var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
addlilink(tb, url, name, id);
}
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
return addlilink(tabs, url, name, id, title, key);
}
function addLink(where, url, name, id, title, key, after){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
if(after) {
tabs.insertBefore(li,document.getElementById(after));
} else {
tabs.appendChild(li);
}
if(id) {
if(key && title) { ta[id] = [key, title]; }
else if(key) { ta[id] = [key, '']; }
else if(title) { ta[id] = ['', title];}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function URLEncoding(input)
{
var encodedInputString=escape(input);
encodedInputString=encodedInputString.replace("+", "%2B");
encodedInputString=encodedInputString.replace("/", "%2F");
var outputurl=encodedInputString;
return outputurl;
}
//---------------------------------------------------------------
////////////////////////////////////////////////////////////////
//*****************************************************
//PROTECTION JS
//*****************************************************
//*****************************************************
//This is for if people skrew with the WP:PP page layout
var movesec = 7;
var artfull = 10;
var artsemi = 11;
var otherpro = 13;
var userfull = 16;
var usersemi = 17;
var regtalk = 18;
var anontalk = 19;
//End of WP:PP constants
//*****************************************************
//*****************************************************
//Cat update
addOnloadHook(addcatupdate)
function addcatupdate()
{
var undefined;
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
if (location.href.indexOf('Category:Semi-protected') != -1)
{
addTab("javascript:updatepcat()", "{{Update WP:PP}}", "ca-wppup", "Update article WP:PP listings", "");
}
else if (location.href.indexOf('Category:Protected') != -1)
{
addTab("javascript:updatepcat()", "{{Update WP:PP}}", "ca-wppup", "Update article WP:PP listings", "");
}
}
//END
function updatepcat()
{
var k = 0;
var thescript = '';
var undefined;
if (document.title.indexOf('Category:Semi-protected') != -1 || document.title.indexOf('Category:Protected') != -1)
{
var l = document.getElementById('bodyContent').getElementsByTagName('a');
if (document.title.indexOf('Category:Semi-protected') != -1) {var value = 'S';}
else if (document.title.indexOf('Category:Protected') != -1) {var value = 'P';}
for (i = 0; i < l.length; i++)
{
var Name = l[i].innerHTML;
if (l[i].title.split(':')[1] != undefined || l[i].href.split('a:')[1] != undefined || l[i].href.split('g:')[1] != undefined || l[i].href.split('i:')[1] != undefined || l[i].href.split('e:')[1] != undefined || l[i].href.split('y:')[1] != undefined || Name.indexOf(':') != -1 || Name.indexOf('rotected') != -1 || Name.indexOf('search') != -1 || Name.indexOf('navigation') != -1 || Name.indexOf('rotection') != -1 || Name.indexOf('#') != -1 || l[i].nodeName.indexOf(':') != -1){update = 'no';}
else {k = k + 1; thescript += '|E#' + k + '|' + Name;}
}
var z = k + 1;
thescript += '|E#' + z;
thescript = URLEncoding(thescript);
if (value == 'S')
{
location.href = 'http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit§ion=' + artsemi + '&fakeaction=Sjslist&faketarget=' + thescript;
}
else if (value == 'P')
{
location.href = 'http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit§ion=' + artfull + '&fakeaction=Pjslist&faketarget=' + thescript;
}
}
}
addOnloadHook(pautolistcheck)
function pautolistcheck()
{
var undefined;
var action = '';
var target = '';
if (location.search)
{
var l = location.search.substring(1).split('&');
for (var i = 0; i < l.length; ++i)
{
var eq = l[i].indexOf('=');
var name = l[i].substring(0, eq);
if (name == 'fakeaction')
action = l[i].substring(eq + 1);
else if (name == 'faketarget')
target = unescape(location.href.split('&faketarget=')[1]);
}
}
if (action == 'Pjslist' || action == 'Sjslist')
{
if (action == 'Pjslist'){var type = 'F';}
else if (action == 'Sjslist'){var type = 'S';}
var z = 0;
var pages_notlisted = '';
var original = document.editform.wpTextbox1.value;
var f = document.editform, t = f.wpTextbox1;
f.wpSummary.value += 'JS: Adding pages not listed:';
for (i = 1; i < 250; i++)
{
if (target.split('|E#' + i + '|')[1] != undefined)
{
var j = i + 1;
if (target.split('|E#' + i + '|')[1].split('|E#' + j)[0] != undefined)
{
var page_name = target.split('|E#' + i + '|')[1].split('|E#' + j)[0];
plistcheck(page_name);
if (document.editform.wpTextbox1.value.indexOf(page_name + '}}') == -1)
{z = z + 1; var h = z + 1; pages_notlisted += '|P' + z + '|' + page_name + '|P' + h + '|';}
}
}
else
{
var error = 'yes';
}
}
if (document.editform.wpTextbox1.value == original)
{alert('No entries added, the list is currently up to date'); window.back(); return;}
pages_notlisted = URLEncoding(pages_notlisted);
window.open('http://en.wikipedia.org/w/index.php?title=Special:Log&type=protect&user=&page=&limit=5000&offset=0' + '&fakeaction=' + type + 'sumfind&faketarget=' + pages_notlisted,
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
}
//END
addOnloadHook(plistsumfind)
function plistsumfind()
{
var undefined;
var action = '';
var target = '';
if (location.search)
{
var l = location.search.substring(1).split('&');
for (var i = 0; i < l.length; ++i)
{
var eq = l[i].indexOf('=');
var name = l[i].substring(0, eq);
if (name == 'fakeaction')
action = l[i].substring(eq + 1);
else if (name == 'faketarget')
target = unescape(location.href.split('&faketarget=')[1]);
}
}
if (action == 'Fsumfind' || action == 'Ssumfind')
{
if (action == 'Fsumfind'){var type = artfull; var cat = 'F';}
else if (action == 'Ssumfind'){var type = artsemi; var cat = 'S';}
var Txt = '';
var Summary = '';
var Username = '';
l = document.getElementById('bodyContent').getElementsByTagName('li');
for (i = 0; i < l.length; i++)
{
if (l[i].innerHTML.indexOf(' protected ') != -1)
{
if (target.indexOf(l[i].getElementsByTagName('a')[1]) != -1)
{
Username = l[i].getElementsByTagName('a')[0];
Summary = l[i].document.getElementById('span').innerHTML.split(' [')[0];
var Name = l[i].getElementsByTagName('a')[1];
Txt += '{{article|' + Name + '}}' + Summary + ' -- [[User:' + Username + '|' + Username + ']]';
}
}
}
//END of FOR loop
Txt = URLEncoding(Txt);
location.href = 'http://en.wikipedia.org/w/index.php?title=Wikipedia:List_of_protected_pages&action=edit§ion=' + type + '&fakeaction=' + cat + 'addtext&faketarget=' + Txt;
}
}
addOnloadHook(addptext)
function addptext()
{
var undefined;
var action = '';
var target = '';
if (location.search)
{
var l = location.search.substring(1).split('&');
for (var i = 0; i < l.length; ++i)
{
var eq = l[i].indexOf('=');
var name = l[i].substring(0, eq);
if (name == 'fakeaction')
action = l[i].substring(eq + 1);
else if (name == 'faketarget')
target = unescape(location.href.split('&faketarget=')[1]);
}
}
if (action == 'Saddtext' || action == 'Faddtext')
{
if (action == 'Saddtext'){var cat = '[[Category:Semi-protected]]';}
else if (action == 'Faddtext'){var cat = '[[Category:Protected]]';}
var f = document.editform, t = f.wpTextbox1;
t.value += target;
f.wpSummary.value += "Updating protected pages from " + cat;
}
}
function plistcheck(input)
{
var f = document.editform, t = f.wpTextbox1;
var target = input;
var pagename = target;
var original = document.editform.wpTextbox1.value;
var username = pagename.split("User:")[1];
var usertalk = pagename.split("User talk:")[1];
var thepage = "*{{article|" + target + "}}";
var thepage2 = "* {{article|" + target + "}}";
var lapage = "*{{la|" + target + "}}";
var theuser = "*[[" + target + "]]";
var vandaltalk = "*{{vandal|" + usertalk + "}}";
if (document.editform.wpTextbox1.value.split(theuser)[1] != undefined)
{
var errorl = 'yes';
}
else if (document.editform.wpTextbox1.value.split(vandaltalk)[1] != undefined)
{
var errorl = 'yes';
}
else if (document.editform.wpTextbox1.value.split(thepage)[1] != undefined)
{
var errorl = 'yes';
}
else if (document.editform.wpTextbox1.value.split(thepage2)[1] != undefined)
{
var errorl = 'yes';
}
else if (document.editform.wpTextbox1.value.split(lapage)[1] != undefined)
{
var errorl = 'yes';
}
else
{
form = document.getElementById('bodyContent');
l = form.getElementsByTagName('input');
for (i = 0; i < l.length; i++)
{
if (l[i].name == 'wpMinoredit')
{l[i].value = '1'; l[i].checked=true;}
}
if (t.value.length > 0)
t.value += '\r';
t.value +="*{{article|" + pagename + "}}. Added from category page. " + "~" + "~" + "~" + "~";
f.wpSummary.value += "[[" + pagename + "]]/";
alert('Article "' + pagename + '" not found; added to list.');
//window.open('http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=protect&user=&page=' + pagename,
//'targetname' + pagename,
//'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
}
//</nowiki></pre>