User:Insineratehymn/uncyclopedia.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes.
- Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
- Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
- Opera, Konqueror and Safari users can just click the Reload button.
- Chrome: press Ctrl+F5 or Shift+F5
//<nowiki>
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/wiki/User:Villahj_Ideeut/QVFD.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/index.php?title=User:Spang/quickedit.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/index.php?title=User:Volte/jumpdown.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/index.php?title=User:Volte/redflags.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/index.php?title=User:Olipro/autotalk.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/index.php?title=User:Olipro/rollback.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="'
+ 'http://uncyclopedia.wikia.com/index.php?title=User:SckrTrckrBot/uncyclopedia.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
function main() {
var newbox = initNewBox(); //Create a new sidebar box
var enableOldForumEdit = true
recentChangesHighlights(); //borrowed from Spang
blockHighlights(); //created it myself
highlightShortNewpages();
addRevert(); //Add a "Revert To Here" link to every diff page
addHistoryEdit(); //Add "edit" links to the history page to provide a way to directly edit each revision
setEditForm(); //Automate the submission of forms by auto-filling textboxes and auto-pushing buttons
addLinks(newbox); //Populate the sidebar box
addTabs(); //Add tabs to the top (NRV, MTU, Google, en.wp)
flagUsers(); //Flag users on Recent Changes
KillLameWikiaAds(); // Got this from UNKNOWNFILE's js
//NO LONGER NECESSARY
//
//addRecentContribs(); //In the Recent Changes page, add 'contribs' link to each user
};
// self-explanatory
function KillLameWikiaAds() {
for(var i=0; UserName = document.getElementsByTagName("div")[i]; i++) {
if ((document.getElementById('class') == "ad-left")&&(UserName.getAttribute('id') == "graphicalspotlight1")) {
var ViewerName = document.getElementById('ad-left').firstChild.innerHTML;
UserName.innerHTML = '';
} else {
document.Write('blah');
}
}
}
function enableOldForumEdit () {}
function recentChangesHighlights() {
if (wgPageName == 'Special:Recentchanges') {
var targetContent = document.getElementById('bodyContent');
var rows = targetContent.getElementsByTagName ("li");
for (var l = 0; l < rows.length; l++) {
liHTML = rows[l].innerHTML
liText = rows[l].textContent;
if (liHTML.indexOf('/wiki/Special:Log/') != -1) {
rows[l].style.backgroundColor = '#DDF';
}
if (liHTML.indexOf('/wiki/Special:Log/block') != -1 || liHTML.indexOf('/wiki/Special:Log/delete') != -1) {
rows[l].style.backgroundColor = '#FEE';
}
if (liHTML.indexOf('class="newpage"') != -1) {
rows[l].style.backgroundColor = '#DFD';
}
if (liText.indexOf('Blanked the page') != -1 || liHTML.indexOf('<strong class="mw-plusminus-neg">') != -1) {
rows[l].style.backgroundColor = '#FAA';
}
if (liText.indexOf('Quoticide','quoticide') != -1) {
rows[l].style.backgroundColor = '#EFA';
}
if (liText.indexOf('spelling fixes') != -1) {
rows[l].style.backgroundColor = '#DFA';
}
}
}
}
function blockHighlights() {
if (wgPageName == 'Special:Ipblocklist') {
var targetContent = document.getElementById('bodyContent');
var rows = targetContent.getElementsByTagName ("li");
for (var l = 0; l < rows.length; l++) {
liHTML = rows[l].innerHTML
liText = rows[l].textContent;
if (liHTML.indexOf('infinite') != -1) {
rows[l].style.backgroundColor = '#FAA';
}
}
}
}
function highlightShortNewpages () {
if (window.location.href.indexOf("Special:Newpages") != -1) {
var targetContent = document.getElementById('bodyContent');
var links = targetContent.getElementsByTagName ("li");
for (var l = 0; l < links.length; l++) {
liContent = links[l].textContent;
sizeText = liContent.substring(liContent.indexOf('[')+1,liContent.indexOf('bytes]'));
sizeBytes = sizeText.replace(',', '');
if (sizeBytes > 10000) {
links[l].className = 'new-long';
}
if (sizeBytes < 1500) {
links[l].className = 'new-shortish';
}
if (sizeBytes < 1000) {
links[l].className = 'new-short';
}
if (sizeBytes < 100) {
links[l].className = 'new-shortest';
}
}
}
}
function addRecentContribs() {
if (document.title != 'Recent changes - Uncyclopedia') return;
var xp_talkLinks = document.evaluate("//a[contains(@href, 'User_talk') and .='Talk']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var curLink;
var i;
for (i = 0; i < xp_talkLinks.snapshotLength; i++) {
var n = i + 1;
var newLink;
var linkSpan;
var bar;
var re;
curLink = xp_talkLinks.snapshotItem(i);
if (curLink.href.indexOf("/index.php") > 0) {
re = RegExp("title=User_talk:(.*)&");
} else {
re = RegExp("wiki/User_talk:(.*)");
}
var matches = re.exec(curLink.href);
newLink = document.createElement("a");
bar = document.createElement("span");
linkSpan = document.createElement("span");
newLink.href = "http://uncyclopedia.wikia.com/wiki/Special:Contributions/" + matches[1];
newLink.textContent = "contribs";
linkSpan.setAttribute("class", "plainlinks");
linkSpan.appendChild(newLink);
bar.textContent = " | ";
insertAfter(curLink.parentNode, bar, curLink);
insertAfter(curLink.parentNode, linkSpan, bar);
}
}
function initNewBox() {
var sidebar = document.getElementById('column-one');
var outer = document.createElement('div');
var heading = document.createElement('h5');
var newbox = document.createElement('div');
var list = document.createElement('ul');
outer.setAttribute('class', 'portlet');
newbox.setAttribute('class', 'pBody');
heading.textContent = 'newbox';
outer.appendChild(heading);
outer.appendChild(newbox);
newbox.appendChild(list);
sidebar.appendChild(outer);
return list;
}
function addLinks(newbox) {
addToolboxLink('VFH', '/wiki/Uncyclopedia:VFH/summary', newbox);
addToolboxLink('VFP', '/wiki/Uncyclopedia:VFP', newbox);
addToolboxLink('VFD', '/wiki/Uncyclopedia:VFD', newbox);
addToolboxLink('QVFD', '/wiki/Uncyclopedia:QuickVFD', newbox);
addToolboxLink('Ban Patrol', '/wiki/Uncyclopedia:Ban_Patrol', newbox);
addToolboxLink('Grue Army', '/wiki/User:High_Gen._Grue/GrueArmy', newbox);
addToolboxLink('WotM', '/wiki/Uncyclopedia:Writer_of_the_Month', newbox);
addToolboxLink('UotM', '/wiki/Uncyclopedia:Uncyclopedian_of_the_Month', newbox);
addToolboxLink('NotM', '/wiki/Uncyclopedia:Noob_of_the_Month', newbox);
addToolboxLink('PotM', '/wiki/Uncyclopedia:Potatochopper_of_the_Month', newbox);
addToolboxLink('UGotM', '/wiki/Uncyclopedia:Useless_Gobshite_of_the_Month', newbox);
addToolboxLink('Village Dump', '/wiki/Uncyclopedia:Village_Dump', newbox);
addToolboxLink('JavaScript Edit', '/index.php?title=User:Insineratehymn/uncyclopedia.js&action=edit', newbox);
addToolboxLink('JavaScript Refresh', '/index.php?title=User:Insineratehymn/uncyclopedia.js&action=raw&ctype=text/javascript&dontcountme=s', newbox);
}
function addTabs() {
if (document.getElementById('editform')) {
var nrvTab = addTab('ICU', '#');
var uglyTab = addTab('Ugly', '#');
var welcomeTab = addTab('Welcome', '#');
var vanityTab = addTab('Vanity2', '#');
var vfdTab = addTab('VFD', '#');
var rewriteTab = addTab('Rewrite', '#');
uglyTab.addEventListener('click', makeUgly, false);
nrvTab.addEventListener('click', makeNrv, false);
welcomeTab.addEventListener('click', makeWelcome, false);
vanityTab.addEventListener('click', makeVanity, false);
vfdTab.addEventListener('click', makeVFD, false);
rewriteTab.addEventListener('click', makeRewrite, false);
} else {
var re = RegExp("(.*) - Uncyclopedia");
var matches;
var pageTitle;
if (matches = re.exec(document.title)) pageTitle = matches[1];
addTab('Google', 'http://www.google.com/search?hl=en&lr=&safe=off&q=%22' + pageTitle + '%22');
addTab('Wikipedia', 'http://www.google.com/search?q=site:wikipedia.org&q=%22' + pageTitle + '%22');
}
}
function addTab(text, url) {
var tabs = document.getElementById('ca-edit').parentNode;
if (!tabs) return false;
var newTab = document.createElement("li");
newTab.innerHTML = '<a href="' + url + '">' + text + '</a>';
tabs.appendChild(newTab);
return newTab;
}
function addToolboxLink(text, url, parent) {
var newLink = document.createElement("li");
newLink.innerHTML = '<a href="' + url + '">' + text + '</a>';
parent.appendChild(newLink);
return newLink;
};
function addHistoryEdit() {
var pageHistory = document.getElementById('pagehistory');
if (!pageHistory) return;
var links = document.evaluate("//li[input[@type='radio']]", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var xp_name1 = document.evaluate("//li[input[@type='radio']][1]/descendant::a[last()]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!xp_name1) return;
var name1 = xp_name1.singleNodeValue;
var curLink;
var i;
for (i = 0; i < links.snapshotLength; i++) {
var n = i + 1;
curLink = links.snapshotItem(i);
var xp_name2 = document.evaluate("//li[input[@type='radio']][" + n + "]/descendant::input/following::a[2]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!xp_name2) return;
var xp_link = document.evaluate("//li[input[@type='radio']][" + n + "]/descendant::input/following::a[1]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!xp_link) return;
var name2 = xp_name2.singleNodeValue;
var link = xp_link.singleNodeValue;
if (i == 0) {
curLink.innerHTML = '(edit) ' + curLink.innerHTML;
} else {
curLink.innerHTML = '(<span class="plainlinks"><a href="' + link.href + '&action=edit&setwatch=0&setsummary=Reverted edit of [[User:' + name1.textContent + '|' + name1.textContent + ']] to previous version by ' + name2.textContent + '">edit</a></span>) ' + curLink.innerHTML;
}
}
};
function makeNrv() {
var fix = prompt('Enter fix message, or leave blank');
if (fix == null) return;
var sub = prompt('Enter sub template name, or leave blank\nOptions: format, short, notfunny, random, encyclopedic, list, and original');
if (sub == null) return;
document.editform.wpSummary.value = '+ICU: This article is crappy, but you have the power to improve it!';
document.editform.wpMinoredit.checked = true;
document.editform.wpWatchthis.checked = false;
var txt = document.editform.wpTextbox1;
if(txt.value.length > 0) txt.value += '\n';
txt.value += '{{ICU|~~~~~|fix=' + fix + '|sub=' + sub + '}}';
document.editform.wpSave.focus();
};
function makeUgly() {
var editarea = document.getElementsByName("wpTextbox1")[0];
if (editarea) editarea.value = "{{ugly}}\n\n" + editarea.value;
var summary = document.getElementsByName("wpSummary")[0];
if (summary) summary.value = "+{{ugly}}";
var watch = document.getElementById("wpWatchthis");
if (watch) watch.checked = false;
};
function makeWelcome() {
var editarea = document.getElementsByName("wpTextbox1")[0];
if (editarea) editarea.value = "{{subst:User:Insineratehymn/welcome}}--~~~~\n\n" + editarea.value;
var summary = document.getElementsByName("wpSummary")[0];
if (summary) summary.value = "Welcome to Uncyclopedia!";
var watch = document.getElementById("wpWatchthis");
if (watch) watch.checked = false;
};
function makeVanity() {
var editarea = document.getElementsByName("wpTextbox1")[0];
if (editarea) editarea.value = "{{vanity2|~~~~~}}\n\n" + editarea.value;
var summary = document.getElementsByName("wpSummary")[0];
if (summary) summary.value = "+Vanity2: 7 days until execution";
var watch = document.getElementById("wpWatchthis");
if (watch) watch.checked = false;
};
function makeVFD() {
var editarea = document.getElementsByName("wpTextbox1")[0];
if (editarea) editarea.value = "{{VFD}}\n" + editarea.value;
var summary = document.getElementsByName("wpSummary")[0];
if (summary) summary.value = "+VFD: Decide this article's fate [[UN:VFD|here]].";
var watch = document.getElementById("wpWatchthis");
if (watch) watch.checked = false;
};
function makeRewrite() {
var weight = prompt('Enter the rewrite weight or leave blank for thematic or default\n\nOptions: soft, medium, hard');
if (weight == null) return;
var character = '';
if (weight == '')
character = prompt('Enter the character for thematic rewrite or leave blank for default\n\nOptions: mrt, ermey, simon, trump');
if (character == null) return;
document.editform.wpSummary.value = '+Rewrite: Get off your butt and whip this article into shape.';
document.editform.wpMinoredit.checked = true;
document.editform.wpWatchthis.checked = false;
var txt = document.editform.wpTextbox1;
var current = txt.value;
if (character == '')
{
if (weight == '')
{ txt.value = "{{Rewrite}}\n" + current; }
else
{ txt.value = "{{Rewrite|" + weight + "}}\n" + current; }
}
else
{ txt.value = "{{Rewrite|character=" + character + "}}\n" + current; };
document.editform.wpSave.focus();
};
function setEditForm() {
var editform = document.getElementById("editform");
if (!editform) return;
var summaryText = queryString('setsummary');
if (summaryText) {
var summary = document.getElementsByName("wpSummary")[0];
if (summary) summary.value = summaryText;
}
var setMinor = queryString('setminor');
if (setMinor) {
var minor = document.getElementById("wpMinoredit");
if (minor) minor.checked = (setMinor == '1');
}
var setWatch = queryString('setwatch');
if (setWatch) {
var watch = document.getElementById("wpWatchthis");
if (watch) watch.checked = (setWatch == '1');
}
var setSubmit = queryString('setsubmit');
if (setSubmit) {
var btn = document.getElementById(setSubmit);
if (document.getElementById("editform") && btn) {
btn.textContent += " (auto clicking...)";
btn.click();
}
}
};
function addRevert() {
if(!queryString("diff")) return;
var xp_link = document.evaluate("//a[starts-with(., 'Revision')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!xp_link) return;
var link = xp_link.singleNodeValue;
var xp_name1 = document.evaluate("/descendant::a[.='Talk'][1]/preceding-sibling::a", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!xp_name1) return;
var xp_name2 = document.evaluate("/descendant::a[.='Talk'][2]/preceding-sibling::a", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (!xp_name2) return;
var name1 = xp_name1.singleNodeValue;
var name2 = xp_name2.singleNodeValue;
var linkSpan = document.createElement("span");
var revertLink = document.createElement("a");
var summaryText = "Reverted edit of [[Special:Contributions/" + name2.textContent + "|" + name2.textContent + "]] to previous one by " + name1.textContent
linkSpan.innerHTML = " ";
revertLink.innerHTML = "[Revert to here]";
revertLink.href = link.href + "&action=edit&setsubmit=wpSave&setsummary=" + summaryText + "&setwatch=0";
insertAfter(link.parentNode, linkSpan, link);
insertAfter(link.parentNode, revertLink, linkSpan);
};
function insertAfter(parent, node, referenceNode) {
if(referenceNode.nextSibling) {
return parent.insertBefore(node, referenceNode.nextSibling);
} else {
return parent.appendChild(node);
}
};
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches[1]);
} catch (e) {
}
}
return null;
};
window.addEventListener('load', main, false);
//</nowiki>