User:Glacier Wolf/global.js

// ***************************************************************** // Custom edit buttons // ***************************************************************** // "Whine" button - initial idea by Jack, lots of helpful tweaks // by Splarka (http://www.wikia.com/wiki/User:Splarka) if (mwCustomEditButtons) { mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/3/3b/Button_template_alt.png", "speedTip": "", "tagOpen": "", "sampleText": "subst:w:User:Glacier Wolf"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/1/11/Button_Nuvola_apps_edu_lang.png", "speedTip": "", "tagOpen": "", "sampleText": "subst:w:User:Glacier Wolf/talk"}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://images.wikia.com/central/images/2/28/Button_info.png", "speedTip": "Whine about protection (new wiki, main page)", "tagOpen": "Hi there, and congratulations on the new Wikia you've just founded! I see you've protected the main page of this wiki project. It's against Wikia's protection policy to protect the main page before any vandalism has happened. Full protection of the main page prevents a lot of constructive edits - not everyone tries to harm the project.", "tagClose": "--" + "", "sampleText": "You can use the autoconfirm protection level to protect the main page from anonymous and very new users. It's a very common mistake to protect the main page unneccessarily. In most cases, main page protection does more bad than good. I'd suggest also reading Wikia's help page about the main page. Please consider reducing or completely removing the protection from the Main Page. Thanks in advance. "}; }

// function appendScript(url) { var scriptElem = document.createElement('script'); scriptElem.setAttribute('src',url); scriptElem.setAttribute('type','text/javascript'); document.getElementsByTagName('head')[0].appendChild(scriptElem); } appendScript('http://www.wikia.com/index.php?title=User:Splarka/fastdelete.js&action=raw&ctype=text/javascript&dontcountme=s') appendScript('http://www.wikia.com/index.php?title=User:Glacier_Wolf/revert.js&action=raw&ctype=text/javascript&dontcountme=s')

function addRollback { if(wgPageName == 'Special:Recentchanges' && fcktest != true) { items = document.getElementsByTagName('ul')[0]; items = items.getElementsByTagName('li'); for(i = 0; i < items.length; i++) { checker = items[i].getElementsByTagName('a')[0].innerHTML; if(checker != 'diff') continue; var uname = items[i].getElementsByTagName('a')[3].innerHTML; var title = items[i].getElementsByTagName('a')[2].getAttribute('href'); title = title.substring(6,title.length); items[i].appendChild(document.createTextNode(' [')); newlink = document.createElement('a'); thetext = document.createTextNode('rollback'); newlink.appendChild(thetext); newlink.setAttribute('href', '/index.php?title='+title+'&action=history&rolldown=true&uname='+escape(uname)); items[i].appendChild(newlink); items[i].appendChild(document.createTextNode(']')); //items[i].innerHTML += ' [rollback]'; }   } } function addHistRollback { if(document.title.indexOf("- History") != -1 && fcktest != true) { item = document.getElementById('pagehistory').getElementsByTagName('li')[0]; newlink = document.createElement('a'); thetext = document.createTextNode('rollback'); newlink.appendChild(thetext); newlink.setAttribute('onClick', 'rollbackLast'); newlink.setAttribute('href', 'javascript:rollbackLast'); item.appendChild(document.createTextNode(' [')); item.appendChild(newlink); item.appendChild(document.createTextNode(']')); //item.innerHTML += ' [rollback]'; } } function addContRollback { if(wgPageName != "Special:Contributions") return;

lilinks = document.getElementsByTagName('ul')[0].getElementsByTagName('li'); for(i = 0; i < lilinks.length; i++) { str = lilinks[i].getElementsByTagName('strong'); ahr = lilinks[i].getElementsByTagName('a')[0]; if(str[0] == null || !ahr) continue; if(str[0].innerHTML.indexOf('(top)') == -1) continue;

spec = location.href.indexOf('Special:Contributions/'); copyout = location.href.substring(spec, location.href.length); copyout = copyout.substring(22,copyout.length); thelink = ahr.getAttribute('href'); lilinks[i].appendChild(document.createTextNode(' [')); newlink = document.createElement('a'); thetext = document.createTextNode('rollback'); newlink.appendChild(thetext); newlink.setAttribute('href', thelink + '&rolldown=true&uname='+escape(copyout)); lilinks[i].appendChild(newlink); lilinks[i].appendChild(document.createTextNode(']')); } } function rollbackLast { uname = document.getElementById('pagehistory'); unamea = uname.getElementsByTagName('li'); unamer = unamea[0].getElementsByTagName('a')[2].innerHTML; for(i = 1; i < unamea.length; i++) { if(unamea[i].getElementsByTagName('a')[3].innerHTML != unamer) { gohere = unamea[i].getElementsByTagName('a')[2].getAttribute('href'); lastpe = unamea[i].getElementsByTagName('a')[3].innerHTML; break; }   }    if(gohere) location.href = gohere + '&saverevision=true&unamea=' + unamer + '&unameb=' + lastpe; } function getLastRevision { if(document.title.indexOf("- History") == -1 || location.href.indexOf("rolldown=true") == -1) return; uname = document.getElementById('pagehistory'); unamea = uname.getElementsByTagName('li'); unamer = unamea[0].getElementsByTagName('a')[2].innerHTML; if(location.href.indexOf('uname='+escape(unamer)) == -1) { alert('Edit conflict, revert cancelled.'); return; }   for(i = 1; i < unamea.length; i++) { if(unamea[i].getElementsByTagName('a')[3].innerHTML != unamer) { gohere = unamea[i].getElementsByTagName('a')[2].getAttribute('href'); lastpe = unamea[i].getElementsByTagName('a')[3].innerHTML; break; }   }    if(gohere) location.href = gohere + '&saverevision=true&unamea=' + unamer + '&unameb=' + lastpe; } function goToEditPage { if(location.href.indexOf("saverevision=true") == -1) return;

edittab = document.getElementById('ca-edit').getElementsByTagName('a')[0]; editref = edittab.getAttribute('href'); location.href = editref + '&rollbacksave=true&unamea=' + queryString('unamea') + '&unameb=' + queryString('unameb'); } function saveEditPage { if(location.href.indexOf("rollbacksave=true") == -1) return; unamea = unescape(queryString('unamea')); unameb = unescape(queryString('unameb')); esumm = document.getElementById('wpSummary'); esumm.value = 'Reverted edit(s) of ' + unamea + ' (talk) to last version by ' + unameb; document.getElementById('wpMinoredit').checked = true; theform = document.getElementById('editform'); theform.submit; } var fcktest = false; function loadInitCrap { if(fcktest == true) return; addRollback; getLastRevision; goToEditPage; saveEditPage; addHistRollback; addContRollback; } mybrowser = navigator.userAgent; if(mybrowser.search(/MSIE/i) != -1 || mybrowser.search(/Safari/i) != -1) {   addOnLoadHook(loadInitCrap); } else if(mybrowser.search(/Firefox/i) == -1) { document.addEventListener('load', loadInitCrap, false); } else { document.addEventListener('DOMContentLoaded', loadInitCrap, false); } function queryString(p) { var re = RegExp('[&?]' + p + '=([^&]*)'); var matches;

if (matches = re.exec(document.location)) { try { return decodeURI(matches[1]); } catch (e) { }   }    return null; };