User:WikiMasterGhibif/capitalize.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
This user script seems to have a documentation page at User:WikiMasterGhibif/capitalize. |
var addToolbarButtonsUrl = '//en.wikipedia.org/w/index.php?title='
+ 'User:V111P/js/addToolbarButtons.js&action=raw&ctype=text/javascript';
// Backlink: [[User:V111P/js/addToolbarButtons.js]]
mw.loader.using('jquery.textSelection'); // it's loaded by default, but just in case
var textArea = $('#wpTextbox1');
var myToolbarButton = {
id: 'myButton',
tooltip:'decapitalize selection',
callback: function myCallback ()
{
var sel = textArea.textSelection('getSelection');
sel = sel.replace(/\r/g, ''); // IE before 9 doesn't remove the \r's
// manipulate the text in the sel variable
sel = sel.replace(/A/g, 'a'); // for example. Replaces space with underscore
sel = sel.replace(/B/g, 'b');
sel = sel.replace(/C/g, 'c');
sel = sel.replace(/D/g, 'd');
sel = sel.replace(/E/g, 'e');
sel = sel.replace(/F/g, 'f');
sel = sel.replace(/G/g, 'g');
sel = sel.replace(/H/g, 'h');
sel = sel.replace(/I/g, 'i');
sel = sel.replace(/J/g, 'j');
sel = sel.replace(/K/g, 'k');
sel = sel.replace(/L/g, 'l');
sel = sel.replace(/M/g, 'm');
sel = sel.replace(/N/g, 'n');
sel = sel.replace(/O/g, 'o');
sel = sel.replace(/P/g, 'p');
sel = sel.replace(/Q/g, 'q');
sel = sel.replace(/R/g, 'r');
sel = sel.replace(/S/g, 's');
sel = sel.replace(/T/g, 't');
sel = sel.replace(/U/g, 'u');
sel = sel.replace(/V/g, 'v');
sel = sel.replace(/W/g, 'w');
sel = sel.replace(/X/g, 'x');
sel = sel.replace(/Y/g, 'y');
sel = sel.replace(/Z/g, 'z');
// replace the selected text in the textarea with the new text
textArea.textSelection('encapsulateSelection', {pre: sel, replace: true});
}
};
if (mw.libs.addToolbarButtons)
mw.libs.addToolbarButtons(myToolbarButton);
else {
var tbs = window.toolbarButtonsToAdd = window.toolbarButtonsToAdd || [];
tbs.push(myToolbarButton);
mw.loader.load(addToolbarButtonsUrl);
}
//IT WORKS NOW!!!!!