User:Tygrrr/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 Modified version of simple:user:Pilotguy/whackamole.js */ //  // ************** // 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 += " in " + a + "" ; } else { message = msg2 ; }   }    f.wpTextbox1.value += message + "   \n" ; f.wpSummary.value = summary ; f.wpMinoredit.checked=true; f.wpWatchthis.checked=false; f.wpTextbox1.focus; if (f.wpTextbox1.scrollTop || true) f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ; } function whackWelcome     { whackEdit ("",     "",       "welcome!"); } function whackWarn1       { whackEdit ("",       "",         "test"); } function whackWarn2       { whackEdit ("",       "",         "test2"); } function whackWarn3       { whackEdit ("",       "",         "test3"); } function whackWarn4       { whackEdit ("",       "",         "test4"); } function whackBlatant     { whackEdit ("",     "",       "test4im"); } function whackArticle     { whackEdit ("", "",   "testarticle"); } function whackArticle2    { whackEdit ("","",  "test2article"); } function whackArticle3    { whackEdit ("","",  "test3article"); } function whackRemove2     { whackEdit ("",      "",        "test2a"); } function whackRemove3     { whackEdit ("",      "",        "test3a"); }

// ************************************************** // 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:{whackWelcome;};void(0);',     'Welcome', 'toolbox_welcome'); whack_addToolboxLink('javascript:{whackWarn1;};void(0);',       'Test1', 'toolbox_warn1'); whack_addToolboxLink('javascript:{whackWarn2;};void(0);',       'Test2', 'toolbox_warn2'); whack_addToolboxLink('javascript:{whackWarn3;};void(0);',       'Test3', 'toolbox_warn3'); whack_addToolboxLink('javascript:{whackWarn4;};void(0);',       'Test4', 'toolbox_warn4'); whack_addToolboxLink('javascript:{whackBlatant;};void(0);',     'Test4im', 'toolbox_blatant'); whack_addToolboxLink('javascript:{whackArticle ;};void(0);',    'Testarticle', 'toolbox_article'); whack_addToolboxLink('javascript:{whackArticle2 ;};void(0);',   'Test2article', 'toolbox_article2'); whack_addToolboxLink('javascript:{whackArticle3 ;};void(0);',   'Test3article', 'toolbox_article3'); whack_addToolboxLink('javascript:{whackRemove2 ;};void(0);',    'Test2a', 'toolbox_remove2'); whack_addToolboxLink('javascript:{whackRemove3 ;};void(0);',    'Test3a', 'toolbox_remove3');  } } // onload window.simpleAddOnload=function(f) { if (window.addEventListener) window.addEventListener("load", f, false); else if (window.attachEvent) window.attachEvent("onload",f); }

simpleAddOnload(playWhackMoles);

//

/***********************************************************************                        EXTRA EDIT BUTTONS // Extra edit page buttons Tools/Editing_tools // This is based on the original code on Wikipedia:Tools/Editing tools // // The original code was on the project page and needed to be cut and paste to the user's // monobook.js page. However, this caused problems with the quote marks. So I have moved // it to its own page. // // I have taken this from simple:user:Huji/monobook.js and modified it. I do not know how to do this from scratch so if you want it for yourself, you're better off using another source. // // See the User:MarkS/Extra edit buttons for changes log function InsertButtonsToToolBar { d = new Date; todayISO = d.getFullYear+"-"; if (d.getMonth > 8) { todayISO += (d.getMonth+1)+"-"; } else { todayISO += "0"+(d.getMonth+1)+"-"; } if (d.getDay > 9) { todayISO += d.getDate; } else { todayISO += "0"+d.getDate; }

//My signature button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/d/d1/Button_mysignature.png", "speedTip": "My sig", "tagOpen": "", "sampleText": ""} //Simple interwiki button mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/c/cb/Button_wikipedia.png", "speedTip": "Simple interwiki", "tagOpen": "simple:",   "tagClose": "", "sampleText": "Simple article"} } $( InsertButtonsToToolBar );

/* Script to warn you if your userpage is changed by another user. By User:ais53. Note that the message persists until you edit your userpage yourself. */ function upm_checkthisisme(xmlreq) { var junk; try {   var ed=xmlreq.responseText.split('"+ed.split('<').join('&lt;').split('>').join('&gt;').split('&').join('&amp;')+""+ " (your userpage, "+      "last change)"; } catch(junk) {}; } $(function{ var a = sajax_init_object;  a.open('GET', mw.config.get('wgServer')+mw.config.get('wgScriptPath')+'/api.php?action=query&prop=revisions&titles=User:'+ encodeURI(wgUserName)+'&rvlimit=1&rvprop=user&format=xml'); a.send('');  a.onreadystatechange = function{if(a.readystate==4) upm_checkthisisme(a)}; });