User:Nux/monobook.js
From Wikipedia
< User:Nux
Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac); IE: hold Ctrl while clicking Refresh, or press Ctrl-F5; Konqueror:: simply click the Reload button, or press F5; Opera users may need to completely clear their cache in Tools→Preferences.
/* ==== Automatic summaries ==== * Author: [[:pl:User:Adziura|Adam Dziura]] * Fixes: [[:pl:User:Nux|Maciej Jaros]] <pre> */ // main function addOnloadHook(function () { // stop before starting if (window.autoSummariesDone) return; // // check if user is editing and if this is a summary field (not a section header field) var el = document.getElementById('wpSummary'); if (el) { if (el.getAttribute('tabindex')==1) // hack! hopefully will not be changed return // stop ; } else { return; // stop } // // adding element that will hold buttons el = el.nextSibling; var parent = document.createElement('span'); parent.id = 'userSummaryButtonsA' el.parentNode.insertBefore(document.createElement('br'), el) el.parentNode.insertBefore(parent, el) // // adding summary buttons var cl = ''; // class is not needed (as on may style with the element above) // drobne różne addSummaryBtn(parent, 'ort.', 'addSumm("ort.")', cl, 'Poprawiono błąd ortograficzny'); addSummaryBtn(parent, 'styl', 'addSumm("styl")', cl, 'Poprawiono błąd stylistyczny i podobne'); addSummaryBtn(parent, 'int.', 'addSumm("int.")', cl, 'Poprawiono interpukcję'); addSummaryBtn(parent, 'lit.', 'addSumm("lit.")', cl, 'Poprawiono literówkę'); addSummaryBtn(parent, 'ogonki', 'addSumm("polskie znaki")', cl, 'Poprawa polskich znaków'); }); /* Params: * el - parent element to hold buttons * t - text to appear in the button * a - action (as string) to be run after clicking a button; may be more then one function * c - optional class name to be attached to the button * d - a tooltip to be show when one highlights the button */ function addSummaryBtn(el, t, a, c, d) { var btn = document.createElement('a'); btn.appendChild(document.createTextNode(t)); btn.title = d; if (c!='') btn.className = c ; btn.onclick = new Function(a); el.appendChild(btn); } function addSumm(txt) { var wpS = document.editform.wpSummary; if (wpS.value != '' && wpS.value.charAt(wpS.value.length-2) != '/') wpS.value += ', ' + txt else wpS.value += txt ; } // </pre>