User:GeorgeMoney/JKwhackamole.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 Original version by User:Kbh3rd. Modified by User:Jacek_Kendysz */ //  // **************** //  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); message = msg2 ;

f.wpTextbox1.value += "\r\n==February 2007==" f.wpTextbox1.value += "\n" + message + " ~" ; 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 whackTest1      { whackEdit ("-", "",       ""); } function whackTest2      { whackEdit ("-", "",       ""); } function whackTest3      { whackEdit ("-", "",       ""); } function whackVandalism1 { whackEdit ("-", "",  ""); } function whackVandalism2 { whackEdit ("-", "",  ""); } function whackVandalism3 { whackEdit ("-", "",  ""); } function whackVandalism4 { whackEdit ("-", "",  ""); } function whackDelete1    { whackEdit ("-", "",     ""); } function whackDelete2    { whackEdit ("-", "",     ""); } function whackDelete3    { whackEdit ("-", "",     ""); } function whackDelete4    { whackEdit ("-", "",     ""); } function dummyli         { whack_addToolboxLink('#', '. ', null, true); } // ************************************************** // Installation // ************************************************** window.whack_addlilink=function(tabs, url, name, id, title, key, raw){ var na = document.createElement('a'); na.href = url; if(raw) na.innerHTML = name; else 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, raw){ var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; whack_addlilink(tb, url, name, id, null, null, raw); } window.playWhackMoles=function { if (document.title.match("Editing User talk:") ) { dummyli; dummyli; whack_addToolboxLink('javascript:{whackTest1;};void(0);',      'test1',      'toolbox_test1'); whack_addToolboxLink('javascript:{whackTest2 ;};void(0);',     'test2',      'toolbox_test2'); whack_addToolboxLink('javascript:{whackTest3;};void(0);',      'test3',      'toolbox_test3'); dummyli; whack_addToolboxLink('javascript:{whackVandalism1;};void(0);', 'vandalism1', 'toolbox_vandalism1'); whack_addToolboxLink('javascript:{whackVandalism2;};void(0);', 'vandalism2', 'toolbox_vandalism2'); whack_addToolboxLink('javascript:{whackVandalism3;};void(0);', 'vandalism3', 'toolbox_vandalism3'); whack_addToolboxLink('javascript:{whackVandalism4;};void(0);', 'vandalism4', 'toolbox_vandalism4'); dummyli; whack_addToolboxLink('javascript:{whackDelete1;};void(0);',    'delete1',    'toolbox_delete1'); whack_addToolboxLink('javascript:{whackDelete2 ;};void(0);',   'delete2',    'toolbox_delete2'); whack_addToolboxLink('javascript:{whackDelete3 ;};void(0);',   'delete3',    'toolbox_delete3'); whack_addToolboxLink('javascript:{whackDelete4 ;};void(0);',   'delete4',    'toolbox_delete4'); } 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); //