Utilisateur:Seb35/monobook.js
Un article de Wikipédia, l'encyclopédie libre.
Note : Après avoir sauvegardé, vous devez forcer le rechargement de la page pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, IE / Opera : Ctrl-F5, Safari : Cmd-R.
obtenir('AdvancedResearch'); adSearchButtons = Array('l','gg','g','reset','c'); loadJs('Utilisateur:EDUCA33E/LiveRC.js'); obtenir('RestaurationDeluxe'); obtenir('SuppressionDeluxe'); suppressiondeluxeMessages = new Array(); suppressiondeluxeMessages[0] = "[[Wikipédia:Critères d'admissibilité des articles|Publicité ou autopromotion]]"; suppressiondeluxeMessages[1] = "[[Wikipédia:Pages à supprimer/" + wgPageName.replace(/_/, ' ') + "|Suppression suite à PàS]]"; suppressiondeluxeMessages[2] = "Vandalisme"; suppressiondeluxeMessages[3] = "Bac à sable"; //------------------------------------------------------------------------------------------------------------- // Attention : certains de ces scripts sont fait maison spécifiquement pour Opera, et peuvent ne pas marcher pour d'autres navigateurs /**************************************************************/ /* Ajoute deux liens sur les liens rouges en prévisualisation */ /* Auteur : Seb35 */ /**************************************************************/ lr = false; function liensRouges() { if(lr == true) return; lr = true; var allLinks = document.getElementById('bodyContent'); if(!allLinks) return; allLinks = getElementsByTagName('a'); for(i=0; i<allLinks.length; i++) { if(allLinks[i].getAttribute('class') == 'new') { titre = allLinks[i].getAttribute('title'); span = document.createElement('span'); span.innerHTML = ' (' + '<a href="http://www.google.com/search?num=100&as_occt=any&q='+titre+'+site:fr.wikipedia.org">google</a>' + ' ; <a href="/wiki/Special:Whatlinkshere/' + titre.replace(/ /g, '_') + '">liées</a>)'; allLinks[i].nextSibling.parentNode.insertBefore(span, allLinks[i].nextSibling); } } } if(document.getElementById('wpTextbox1')) addOnloadHook(liensRouges); /****************************************/ /* Mettre certains namespaces en mineur */ /****************************************/ function minorEdit() { minor = ',0,8,12,14,104,' if(minor.indexOf(','+wgNamespaceNumber+',') != -1) document.editform[6].checked = true; else document.editform[6].checked = false; } if(/edit/i.test(window.location)) addOnloadHook(minorEdit); /****************************************/ /* Changement de la boîte de navigation */ /* Auteur : Seb35 */ /****************************************/ var isOpen = new Array(); var m; function navigation_main() { d = new Array('janvier','février','mars','avril','mai','juin','juillet','août','septembre','octobre','novembre','décembre'); today = new Date(); date = today.getDate() + '_' + d[today.getMonth()] + '_' + today.getFullYear(); date2 = d[today.getMonth()].charAt(0).toUpperCase()+d[today.getMonth()].substr(1)+'_'+today.getFullYear(); var pages = new Array( 'Administration', new Array('/wiki/Wikipédia:Pages_protégées_à_la_création/' + date2 + '?action=edit', 'WP:PPC', '/wiki/Wikipédia:Requête_aux_administrateurs', 'WP:RA', '/wiki/Wikipédia:Demande_de_suppression_immédiate', 'WP:SI', '/wiki/Wikipédia:Vandalisme_en_cours', 'WP:-(', '/wiki/Wikipédia:Demande_de_protection_de_page', 'Protection', '/wiki/Wikipédia:Demande_d\'intervention_sur_une_page_protégée', 'Intervention', '/wiki/Wikipédia:Demande_de_renommage', 'Renommage', '/wiki/Wikipédia:Demande_de_restauration_de_page', 'Restauration', '/wiki/Wikipédia:Pages_à_supprimer', 'WP:PàS', '/wiki/Wikipédia:Images_à_supprimer', 'WP:IàS', '/wiki/Wikipédia:Pages_soupçonnées_de_violation_de_copyright', 'WP:PCP', '/wiki/Special:Log', 'Journaux', '/wiki/Special:Log/newusers', ' /nouveaux', '/wiki/Special:Allmessages', 'Allmessages', '/wiki/Special:Undelete', 'Undelete', '/wiki/Special:Blockip', 'Blockip', '/wiki/Special:Ipblocklist', 'Ipblocklist' ), 'Maintenance', new Array('/wiki/Special:Recentchanges?hideliu=1&limit=200', 'RC IP', '/wiki/Special:Contributions/newbies', 'RC newbies', '/wiki/Special:Newpages', 'Nouvelles pages', '/wiki/Special:Newimages', 'Nouvelles images', '/wiki/Special:Deadendpages', 'Impasses', '/wiki/Wikipédia:Pages_en_impasse', ' WP:PeI', '/wiki/Special:CrossNamespaceLinks', 'Croisés', '/wiki/Catégorie:Article_pour_le_Wiktionnaire', 'Wiktionnaire', '/wiki/Catégorie:Article_à_wikifier', 'À wikifier', '/wiki/Special:Wantedcategories', 'Wantedcategories', '/wiki/Wikipédia:Pages_à_fusionner', 'WP:PàF', '/wiki/Projet:Maintenance', 'WP:CM' ), 'Autres', new Array('/wiki/Wikipédia:Bulletin_des_administrateurs', 'WP:BA', '/wiki/Wikipédia:Le_Bistro/' +date, 'Le Bistro ' +today.getDate()+ '/' +(today.getMonth()+1), '/wiki/Wikipédia:Conventions_typographiques', 'WP:CTYP', '/wiki/Wikipédia:Conditions_d\'admissibilité des articles', 'WP:Cdada', '/wiki/Wikipédia:Conventions_filmographiques/Présentation_des_films', 'CTYP films', '/wiki/Wikipédia:Modèles', 'Modèles', '/wiki/MediaWiki:JSScripts/AdvancedResearch', 'JS Research', '/wiki/Utilisateur:Seb35/monobook.js', 'Monobook', '/wiki/Projet:Accueil', 'WP:PROJ', '/wiki/Projet:Traduction', 'WP:PT' ) ); var a = document.getElementById('p-Contribuer').getElementsByTagName('ul')[0]; document.getElementById('n-aboutwp').style.display = 'none'; document.getElementById('n-sitesupport').style.display = 'none'; for(i = 0; i<(pages.length)/2; i++) { isOpen[i] = 0; temp = ''; for(j=0; j<(pages[2*i+1].length)/2; j++) temp = temp + '<li><a href="' + pages[2*i+1][2*j] + '">' + pages[2*i+1][2*j+1] + '</a></li>'; a.innerHTML += '<li><a style="cursor:pointer;" onMouseOver="if(isOpen[' + i + '] == 0) m = setTimeout(toggleMenu, 300, ' + (i+1) + ');" onMouseOut="clearTimeout(m);" onClick="clearTimeout(m); toggleMenu(' + (i+1) + ');">' + pages[2*i] + '</a></li>' + '<span id="MenuToggle' + (i+1) + '" style="display:none;">' + temp + '</span>'; } } addOnloadHook(navigation_main); /************************************************/ /* Ouvre un menu créé par la fonction ci-dessus */ /************************************************/ function toggleMenu(v) { if(isOpen[v-1] == 0) { document.getElementById('MenuToggle' + v).style.display = 'inline'; isOpen[v-1] = 1; } else if(isOpen[v-1] == 1) { document.getElementById('MenuToggle' + v).style.display = 'none'; isOpen[v-1] = 0; } } /************************************************/ /* Ajoute des liens vers certains outils sympas */ /************************************************/ function toolbox_main() { a = document.getElementById('p-tb').getElementsByTagName('ul')[0]; a.innerHTML += '<hr />'; if(wgIsArticle) addPortletLink('p-tb', 'http://fr.wiktionary.org/wiki/' + wgTitle.charAt(0).toLowerCase() + wgTitle.substr(1), 'Wiktionnaire'); if(wgPageName == 'Special:Newpages') { addPortletLink('p-tb', 'javascript:clearTimeout(tempsnewpages);document.getElementById(\'newpages-stop\').style.display = \'none\';', 'Arrêter le rechargement', 'newpages-stop'); addPortletLink('p-tb', 'javascript:window.location = window.location.toString();', 'Purger la page'); } if(wgNamespaceNumber != -1) { addPortletLink('p-tb', 'javascript:liensRouges();', 'Liens rouges'); addPortletLink('p-tb', '/wiki/'+wgPageName+'?action=purge', 'Purger la page'); a.innerHTML += '<li><a href="http://www.google.com/search?num=100&q=' + wgTitle + '+site:wikipedia.org+-site:fr.wikipedia.org">Google</a> <a href="http://www.google.com/search?num=100&q=' + wgTitle + '+site:en.wikipedia.org">(en)</a> <a href="http://www.google.com/search?num=100&q=' + wgTitle + '+site:de.wikipedia.org">(de)</a> <a href="http://www.google.com/search?num=100&q=' + wgTitle + '+site:fr.wikipedia.org">(fr)</a></li>'; } if(/Utilisateur:/i.test(wgPageName) || wgPageName == 'Special:Contributions') { if(wgPageName == 'Special:Contributions') { if(/target\=.+/i.test(window.location)) utilisateur = window.location.toString().replace(/.*target\=(.+)/i, '$1').replace(/&/, '>').replace(/(.+)>(?:.*)/, '$1'); else utilisateur = window.location.toString().replace(/.*Special:Contributions\/(.+)/i, '$1'); } else utilisateur = wgTitle.replace(/\//, '>').replace(/(.*)>.*/, '$1'); a.innerHTML += '<hr />'; addPortletLink('p-tb', '/wiki/Special:Log?user=' + utilisateur, 'Journaux'); addPortletLink('p-tb', 'http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=frwiki_p&user=' + utilisateur, 'Ancienneté'); } addPortletLink('p-personal', '/wiki/Utilisateur:Seb35/Potager?action=edit', 'Potager', '', '', '', document.getElementById('pt-preferences')); addPortletLink('p-personal', '/wiki/Special:Log?user=Seb35', 'Actions', '', '', '', document.getElementById('pt-logout')); } addOnloadHook(toolbox_main); // Actualiser automatiquement les nouvelles pages var tempsnewpages; function newpages_begin() { if(wgPageName == 'Special:Newpages') tempsnewpages = setTimeout("window.location = window.location.toString();", 210*1000); } addOnloadHook(newpages_begin); //Sert à prévenir lorsqu'un article vient d'être modifié pour éviter les conflits d'éditions (utilisateur travaillant dessus) function lastContrib() { //Paramètres niveau1 = 100; // Niveau d'alerte très fort niveau2 = 8*60; // Niveau d'alerte fort niveau3 = 25*60; // Niveau d'alerte moyen //Programme (pas besoin de modifier normalement) texte = document.getElementById('lastmod'); if(!texte) return; texte = texte.innerHTML.toString(); resultat = texte.match(/page le ([0-9]{1,2}) ([a-zéû]*) ([0-9]{4}) à ([0-9]{1,2}):([0-9]{1,2})/); last = new Date(Number(resultat[3]), Number(moisFromMot(resultat[2])), Number(resultat[1]), Number(resultat[4]), Number(resultat[5])); now = new Date(); diff = Math.round((now - last)/1000); if(diff <= niveau3) { diffHeures = Math.floor(diff/3600); diffMinutes = Math.floor((diff - diffHeures * 3600)/60); diffSecondes = diff - diffHeures * 3600 - diffMinutes * 60; tit = document.getElementById('contentSub'); tit.innerHTML = '<span style="font-size:8pt;">(<a href="/wiki/' + wgPageName + '?action=history"><span style="' + (diff <= niveau2 ? 'color:red;' : 'color:black;') + (diff <= niveau1 ? ' text-decoration:underline overline;' : '') + '">' + (diffHeures > 0 ? diffHeures + 'h' : '') + (diffMinutes > 0 ? diffMinutes + 'm' : '') + diffSecondes + 's</span></a>)</span> ' + tit.innerHTML; } } function moisFromMot(mot) { tab = new Array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'); for(i=0; i<12; i++) if(mot == tab[i]) return i; return -1; } addOnloadHook(lastContrib); //Quelques raccourcis pour Opera dont les normaux ne sont pas très pratiques function shortcutsOpera(ev) { ctrlTouche = ev.ctrlKey; if(ctrlTouche && ev.keyCode == 32) { if(document.getElementById('wpTextbox1')) document.editform.wpTextbox1.focus(); else window.location = '/w/index.php?title='+wgPageName+'&action=edit'; } if(ctrlTouche && ev.shiftKey) document.adsearch.adinput.focus(); } var ctrlTouche; hookEvent('keydown', shortcutsOpera); //Aide à la wikification var WAOAjax = null; var WAOMaj = false; function WAO() { if(!document.getElementById('wpTextbox1')) return; WAOAjax = sajax_init_object(); coche = WAOCookie(1, 'WAO'); labeltag = document.editform.getElementsByTagName('label'); i = 0; while(labeltag[i].getAttribute('for') != 'wpWatchthis') i++; suivant = labeltag[i].nextSibling; span = document.createElement('span'); span.innerHTML = ' <input type="checkbox" name="WAOCheckbox" id="WAOCheckbox"'+coche+' onclick="WAOCookie(0, \'WAO\', this);" /> <label for="WAOCheckbox">WAO</label>' + '<span id="WAOAutres" style="display:'+(coche ? 'inline' : 'none')+';">' + ' <input type="checkbox" name="WAOAjax" id="WAOAjax"'+WAOCookie(1,'WAOAjax')+' onclick="WAOCookie(0, \'WAOAjax\', this);" /> <label for="WAOAjax">Ajax</label>' + ' <input type="checkbox" name="WAOGoog" id="WAOGoog"'+WAOCookie(1,'WAOGoogle')+' onclick="WAOCookie(0, \'WAOGoogle\', this);" /> <label for="WAOGoog">Google</label>' + ' <input type="checkbox" name="WAOWP" id="WAOWP"'+WAOCookie(1,'WAOWP')+' onclick="WAOCookie(0, \'WAOWP\', this);" /> <label for="WAOWP">Wikipédia</label>' + ' <input type="checkbox" name="WAOAdsearch" id="WAOAdsearch"'+WAOCookie(1,'WAOAdsearch')+' onclick="WAOCookie(0, \'WAOAdsearch\', this);" /> <label for="WAOAdsearch">Rechercher</label>' + '</span>'; suivant.parentNode.insertBefore(span, suivant); if(WAOAjax) { a = document.getElementById('column-one'); a.innerHTML = a.innerHTML + '<div id="p-WAO" class="portlet" style="display:'+(WAOAjax && coche && WAOCookie(1,'WAOAjax') ? 'block' : 'none')+';">' + '<h5>WAO</h5>' + '<div class="pBody">' + '<ul>' + '<li><u>Mot</u> : <span id="WAOMot"></span></li>' + '<li>Google : <span id="WAOGoogle"></span></li>' + '<li>Article : <span id="WAOArticle"></span></li>' + '<li>Pages liées : <span id="WAOLiees"></span></li>' + '</ul>' + '</div>' + '</div>'; } document.editform.wpTextbox1.setAttribute('onkeyup', 'if(event.shiftKey == false) WAOOuvrir();'); document.editform.wpTextbox1.setAttribute('onkeydown', 'WAOMaj = event.shiftKey;'); document.editform.wpTextbox1.setAttribute('onselect', 'if(WAOMaj == false) WAOOuvrir();'); } function WAOCookie(lire, nom, objet) { if(lire) { cookiePos = document.cookie.indexOf(nom+'='); if (cookiePos > -1 && document.cookie.charAt(cookiePos+nom.length+1) == '1') return ' checked="checked"'; else return ''; } else { if(objet.checked) document.cookie = nom+'=1'; else document.cookie = nom+'=0'; if(nom == 'WAO') { if(objet.checked) document.getElementById('WAOAutres').style.display = 'inline'; else document.getElementById('WAOAutres').style.display = 'none'; } if(WAOAjax && (nom == 'WAO' || nom == 'WAOAjax')) { if(document.editform.WAOCheckbox.checked && document.editform.WAOAjax.checked) document.getElementById('p-WAO').style.display = 'block'; else document.getElementById('p-WAO').style.display = 'none'; } } } function WAOOuvrir() { WAOMaj = false; txtarea = document.editform.wpTextbox1; if(!document.editform.WAOCheckbox.checked) return; if(txtarea.selectionStart || txtarea.selectionStart == '0') { startPos = txtarea.selectionStart; endPos = txtarea.selectionEnd; if(startPos == endPos) return; myText = (txtarea.value).substring(startPos, endPos); dat = new Date(); if(myText.length >= 255 || myText.search(/[\f\n\r\t\v]/) != -1) return; if(WAOAjax && document.editform.WAOAjax.checked) { WAOAjax.open('get', wgServer+'/w/api.php?action=query&format=xml&list=backlinks&bllimit=20&prop=info&titles=' + myText, false); WAOAjax.onreadystatechange = WAOResponse; WAOAjax.send(null); } if(document.editform.WAOGoog.checked) { fenetre = window.open('http://www.google.com/search?num=100&q='+myText+'+site:fr.wikipedia.org', 'f1'+dat.getTime(), 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes'); fenetre.blur(); } if(document.editform.WAOWP.checked) { fenetre = window.open('http://fr.wikipedia.org/wiki/'+myText, 'f2'+dat.getTime(), 'menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes'); fenetre.blur(); } if(document.editform.WAOAdsearch.checked) document.adsearch.adinput.value = myText; } } function WAOResponse() { if(WAOAjax.readyState == 4) { xmlDoc = WAOAjax.responseXML; mot = xmlDoc.getElementsByTagName('page')[0].getAttribute('title'); document.getElementById('WAOMot').innerHTML = mot; document.getElementById('WAOGoogle').innerHTML = '<a href="http://www.google.com/search?num=100&as_occt=any&q=' + mot + '+site:fr.wikipedia.org">??</a>'; page = xmlDoc.getElementsByTagName('page'); mot = mot.replace(/ /g, '_'); redirect = (page[0].getAttribute('redirect') == ''); if(page[0].getAttribute('missing') == '') document.getElementById('WAOArticle').innerHTML = 'non'; else document.getElementById('WAOArticle').innerHTML = '<a href="'+wgServer+'/wiki/'+mot+'">'+(redirect ? '<i>Existe !</i>' : 'Existe !')+'</a>'; nb = xmlDoc.getElementsByTagName('bl').length; if(nb == 0) document.getElementById('WAOLiees').innerHTML = '0'; else document.getElementById('WAOLiees').innerHTML = '<a href="'+wgServer+'/wiki/Special:Whatlinkshere/'+mot+'">'+(nb == 20 ? 'beaucoup' : nb)+'</a>'; } } addOnloadHook(WAO);