User:Yugiohdan6/monobook.js

/* Put some functions in the toolbox for the anti-vandal whack-a-mole game. Documented at http://en.wikipedia.org/wiki/User:Kbh3rd/Vandal_warning_toolbox */ //  // **************** //  Google Lookup // **************** function whackGoogleLookup { var q = "" + (window.getSelection ? window.getSelection                                     : document.getSelection ? document.getSelection                                                              : document.selection.createRange.text); if (!q) q = prompt("You didn't select any text. Enter a search phrase:", ""); if (q!=null) // location="http://www.google.com/search?q=" + escape(q).replace(/ /g, "+"); window.open("http://www.google.com/search?q=" + escape(q).replace(/ /g, "+") ,'new-tab') ; } // ************** // Warnings // ************** function whackEdit (message, msg2, summary, level) { var f = document.editform ; var tbox = document.editform.wpTextbox1 ; var a = "" + (window.getSelection ? window.getSelection                                     : document.getSelection ? document.getSelection                                                              : document.selection.createRange.text); if (msg2 != "") { a = prompt ("Article name?\n(Empty+OK for a generic message; Cancel aborts.)", a) ; if (a == null) return ; if (a != null && a != "") { message = message.replace(/\|/,"|"+a) ; summary += " in " + a + "" ; } else { message = msg2 ; }   }    f.wpTextbox1.value += "\n\n" + message + " \n" ; f.wpSummary.value = summary ; if (level > 0) { f.wpSummary.value += " /"+level+"/" ; } f.wpMinoredit.checked=false; f.wpWatchthis.checked=false ; f.wpTextbox1.focus; if (f.wpTextbox1.scrollTop || true) f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ; } function whackSelf  (x) { whackEdit (" ~", " ~","Self-reverted test", 0); } function whackWarn  (x) { whackEdit (" ~",    " ~",      "Experimenting", x); } function whackVandal (x) { whackEdit (" ~",   " ~",   "Vandalizing", x); } function whackBlank (x) { whackEdit (" ~",  " ~", "Blanking", x); } function whackErrors (x) { whackEdit (" ~",  " ~",  "Introducing errors", x); } function whackNPOV  (x) { whackEdit (" ~",  " ~", "NPOV", x); } function whackSpam  (x) { whackEdit (" ~",  " ~", "Spamming", x); } function whackAds   (x) { whackEdit (" ~",  " ~", "Advertising", x); } function whackBlocked(x) { whackEdit ("", "", "** BLOCKED **", x); } function whackBlocked2{whackEdit (""     + "You have been temporarily blocked from editing because of your disruptive edits."      + " You are invited to contribute"      + " in a constructive manner as soon as the block expires.", "", "Blocked"); } // ************************************************** // Installation // ************************************************** window.whack_addlilink=function(tabs, n, url, name, id, title, key){ var ix ; var li = document.createElement('li'); if (n > 0) { li.appendChild(document.createTextNode(name)) ; for (ix = 1 ; ix <= n ; ix++) { var na = document.createElement('a'); na.href = url.replace(/XX/g, ix) ; na.appendChild(document.createTextNode(" "+ix)); li.appendChild(na); }   } else { var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); li.appendChild(na); }   if(id) li.id = id; 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; } window.whack_addToolboxLink=function(n, url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; whack_addlilink(tb, n, url, name, id); } window.playWhackMoles=function { if (document.title.match("Editing User talk:") ) { whack_addlilink (document.getElementById('p-tb').getElementsByTagName('ul')[0],        0, "http://en.wikipedia.org/wiki/Wikipedia:Template_messages/User_talk_namespace#Multi_level_templates",         "Warning Templates:", "uTemplates") ; whack_addToolboxLink(3, 'javascript:{whackWarn(XX);};void(0);',  'Test', 'toolbox_warn'); whack_addToolboxLink(1, 'javascript:{whackSelf(XX);};void(0);',  'Self Test', 'toolbox_selftest'); whack_addToolboxLink(4, 'javascript:{whackVandal(XX);};void(0);', 'Vandal', 'toolbox_warn2'); whack_addToolboxLink(4, 'javascript:{whackBlank(XX);};void(0);', 'Blank', 'toolbox_warn3'); whack_addToolboxLink(3, 'javascript:{whackErrors(XX);};void(0);', 'Errors', 'toolbox_warn4'); whack_addToolboxLink(4, 'javascript:{whackNPOV(XX);};void(0);',  'NPOV', 'toolbox_warn2a'); whack_addToolboxLink(4, 'javascript:{whackSpam(XX);};void(0);',  'Spam', 'toolbox_blatant'); whack_addToolboxLink(4, 'javascript:{whackAds(XX);};void(0);',   'Ads', 'toolbox_blatant'); whack_addToolboxLink(3, 'javascript:{whackBlocked(XX);};void(0);', 'BLOCK', 'toolbox_block'); } else { whack_addToolboxLink(0, 'javascript:{whackGoogleLookup;};void(0);', 'Google', 'toolbox_googlelookup'); } } // onload window.simpleAddOnload=function(f) { if (window.addEventListener) window.addEventListener("load", f, false); else if (window.attachEvent) window.attachEvent("onload",f); } simpleAddOnload(playWhackMoles); //