User:Pilotguy/whackamole.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) { 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.)\n(Cancel now aborts.)", a) ; if (a == null) return ; if (a != null && a != "") { message = message.replace(/\|/,"|"+a) ; summary +=" " + a + "" ; } else { message = msg2 ; }   }    f.wpTextbox1.value += "\n\n" + message + " ~ \n" ; f.wpSummary.value = summary ; f.wpMinoredit.checked=false; f.wpWatchthis.checked=false; f.wpTextbox1.focus; if (f.wpTextbox1.scrollTop || true) f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ; } function whackWarn1  { whackEdit ("",    "",   "Experimenting"); } function whackSelf   { whackEdit ("", "","Self-reverted test"); } function whackWarn2  { whackEdit ("",    "",   "Nonsense edit"); } function whackWarn3  { whackEdit ("",    "",   "Please stop vandalizing"); } function whackWarn4  { whackEdit ("",    "",   "Last chance to stop vandalizing"); } function whackBlank  { whackEdit ("",   "",  "Blanking"); } function whackBlank2  { whackEdit ("",   "",  "Continued Blanking"); } function whackBlank3  { whackEdit ("",   "",  "Please stop blanking pages"); } function whackBlank4  { whackEdit ("",   "",  "Last chance to stop blanking pages"); } function whackBlatant { whackEdit ("",      "",      "Blatant vandalism"); } function whackBlocked { whackEdit ("",     "",  "Blocked"); } function whackBlockedIndef { whackEdit ("",     "",  "Blocked Indefinitely"); } function whackSpam   { whackEdit ("",     "",    "Spam"); } function whackSpam2   { whackEdit ("",     "",    "Please stop spamming"); } function whackSpam3   { whackEdit ("",     "",    "Last chance to stop spamming"); } function whackUpv2    { whackEdit ("",  "", "Userpage vandalism"); }

// ************************************************** // Installation // ************************************************** window.whack_addlilink=function(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; } window.whack_addToolboxLink=function(url, name, id){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; whack_addlilink(tb, url, name, id); } window.playWhackMoles=function { if (document.title.match("Editing User talk:") ) { whack_addToolboxLink('javascript:{whackWarn1;};void(0);',  'warn Test1', 'toolbox_warn1'); whack_addToolboxLink('javascript:{whackSelf ;};void(0);',  'warn Self Test', 'toolbox_selftest'); whack_addToolboxLink('javascript:{whackWarn2;};void(0);',  'warn Nonsense', 'toolbox_warn2'); whack_addToolboxLink('javascript:{whackWarn3;};void(0);',  'warn Please stop', 'toolbox_warn3'); whack_addToolboxLink('javascript:{whackWarn4;};void(0);',  'warn Last chance', 'toolbox_warn4'); whack_addToolboxLink('javascript:{whackBlank;};void(0);',  'warn Blanking', 'toolbox_warn1a'); whack_addToolboxLink('javascript:{whackBlank2;};void(0);',  'warn Blank2', 'toolbox_warn2a'); whack_addToolboxLink('javascript:{whackBlank3;};void(0);',  'warn Blank3', 'toolbox_warn3a'); whack_addToolboxLink('javascript:{whackBlank4;};void(0);',  'warn Blank4', 'toolbox_warn4a'); whack_addToolboxLink('javascript:{whackBlatant;};void(0);', 'warn Blatant', 'toolbox_blatant'); whack_addToolboxLink('javascript:{whackBlocked;};void(0);','warn *BLOCKED*', 'toolbox_block'); whack_addToolboxLink('javascript:{whackBlockedIndef;};void(0);','warn *BLOCKED-Indef', 'toolbox_block'); whack_addToolboxLink('javascript:{whackSpam ;};void(0);',  'warn Spam', 'toolbox_spam'); whack_addToolboxLink('javascript:{whackSpam2 ;};void(0);',  'warn Spam2', 'toolbox_spam'); whack_addToolboxLink('javascript:{whackSpam3 ;};void(0);',  'warn Spam3', 'toolbox_spam'); whack_addToolboxLink('javascript:{whackUpv2 ;};void(0);','warn Upv2', 'toolbox_Upv2'); } else { whack_addToolboxLink('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);

//