Utilisateur:Simplyphil/monobook.js
Apparence
Note : après avoir enregistré vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
- Firefox / Safari : Maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ou Ctrl-R (⌘-R sur un Mac) ;
- Google Chrome : Appuyez sur Ctrl-Maj-R (⌘-Shift-R sur un Mac) ;
- Internet Explorer : Maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5 ;
- Opera : Allez dans Menu → Settings (Opera → Préférences sur un Mac) et ensuite à Confidentialité & sécurité → Effacer les données d'exploration → Images et fichiers en cache.
//Wikipedia:WikiProject User scripts | Scripts
function format() {
var txt = document.editform.wpTextbox1;
txt.value = typo(txt.value);
}
function typo(str){
// fix divers
str = str.replace(/ /g, " ");
// typographie
str = str.replace(/ -/g, " —");
str = str.replace(/- /g, "— ");
str = str.replace(/ - /g, " — ");
str = str.replace(/ -,/g, " —,");
str = str.replace(/ - ,/g, " —,");
str = str.replace(/( *)—( *)/g, " — ");
str = str.replace(/( *);( *)/g, " ; ");
str = str.replace(/( *)\!( *)/g, " ! ");
str = str.replace(/( *):( *)/g, " : ");
str = str.replace(/( *)\?( *)/g, " ? ");
str = str.replace(/( *),( *)/g, ", ");
str = str.replace(/(\[\[.*?) :/g, "$1:");
str = str.replace(/: (.*?\]\])/g, ":$1");
str = str.replace(/([^'])'([^'])/g, "$1’$2");
str = str.replace(/’ /g, "’");
str = str.replace(/ ’/g, "’");
str = str.replace(/ ’ /g, "’");
str = str.replace(/ '',/g, "'',");
str = str.replace(/ ''\./g, "''.");
str = str.replace(/ \./g, "\.");
str = str.replace(/\.\.\./g, "…");
str = str.replace(/\.\.\.\.+/g, "\.\.\.");
str = str.replace(/etc\.\.+/g, "etc\.");
str = str.replace(/oeu/g, "œu");
str = str.replace(/O[Ee]/g, "Œ");
str = str.replace(/"([^"].*?)"/g, "«$1»");
str = str.replace(/( *)«( *)/g, " « ");
str = str.replace(/( *)»( *)/g, " » ");
str = str.replace(/ « text » /g, "\"text\"");
str = str.replace(/» ,/g, "»,");
str = str.replace(/(\f*)’(\f*)/g, "’");
str = str.replace(/ /gm, " ");
str = str.replace(/^ ([^\s])/gm, "$1");
return str;
}
//trim start and end, trim spaces from the end of lines
function trim(str) {
str = str.replace(/ $/gm, "");
return str.replace(/^\s*|\s*$/g, "");
}
//turns first character to lowercase
function TurnFirstToLower(input) {
if (input != "")
{
var input = trim(input);
var temp = input.substr(0, 1);
return temp.toLowerCase() + input.substr(1, input.length);
}
else
return "";
}
$(function () {
if(document.forms.editform) {
mw.util.addPortletLink('p-cactions', 'javascript:format()', 'typo', 'ca-format', 'Corrections de la mise en page et de la typographie', '', document.getElementById('ca-edit'));
}
});