Utilisateur:Bananaflo/monobook.js
Apparence
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.// <pre> <nowiki>
//auteur : Utilisateur:Dake
function DeluxeBar() {
if (document.createTextNode) {
var toolbar = document.getElementById("toolbar");
if (!toolbar) return;
var messages = new Array()
// le texte a été splitté sinon Mediawiki casse tout...
messages[0] = "{{subst:" + "Bienvenue sur ta page" + "}}" + "~~" + "~~";
messages[1] = "{{subst:" + "Bienvenue" + "}}" + "--" + "~~" + "~~";
messages[2] = "{{subst:" + "Bienvenue vandale" + "}}" + "--" + "~~" + "~~";
messages[3] = "{{subst:" + "Bienvenue débutant" + "}}" + "~~" + "~~";
messages[4] = "{{subst:" + "test1" + "}}" + "~~" + "~~";
messages[5] = "{{subst:" + "test2" + "}}" + "~~" + "~~";
messages[6] = "{{subst:" + "test3" + "}}" + "~~" + "~~";
messages[7] = "{{subst:" + "Bienvenue spammeur" + "}}" + "~~" + "~~";
messages[8] = "{{subst:" + "Motivation modif" + "|page=" + "}}" + "~~" + "~~";
messages[9] = "{{subst:" + "Bienvenue copyvio" + "}}" + "~~" + "~~";
var images = new Array()
images[0] = "http://upload.wikimedia.org/wikipedia/fr/1/12/Button_accueilA.png";
images[1] = "http://upload.wikimedia.org/wikipedia/fr/e/eb/Button_accueilB.png";
images[2] = "http://upload.wikimedia.org/wikipedia/fr/0/00/Button_vandale.png";
images[3] = "http://upload.wikimedia.org/wikipedia/fr/Image:Button_bombe.png";
images[4] = "http://upload.wikimedia.org/wikipedia/commons/1/1d/Bouton_Vandale1.png";
images[5] = "http://upload.wikimedia.org/wikipedia/commons/c/cc/Bouton_Vandale2.png";
images[6] = "http://upload.wikimedia.org/wikipedia/commons/e/e4/Bouton_Vandale3.png";
images[7] = "http://upload.wikimedia.org/wikipedia/fr/f/fb/Button_spam2.png";
images[8] = "http://upload.wikimedia.org/wikipedia/commons/7/74/Button_oeil.png";
images[9] = "http://upload.wikimedia.org/wikipedia/fr/e/e5/Button_copyvio.png"
var commentaires = new Array()
commentaires[0] = "Bienvenue sur ta page !"
commentaires[1] = "Bienvenue !"
commentaires[2] = "Avertissement vandalisme 0"
commentaires[3] = "Bienvenue débutant";
commentaires[4] = "Avertissement vandalisme 1" ;
commentaires[5] = "Avertissement vandalisme 2"
commentaires[6] = "Avertissement vandalisme 3"
commentaires[7] = "Avertissement spam"
commentaires[8] = "Commentez vos modifications"
commentaires[9] = "Avertissement violation de copyright"
////////////////////////////////
for (var i=0;i<messages.length;i++) {
var img = document.createElement("img");
img.setAttribute("src", images[i]);
var ref = document.createElement("a");
ref.setAttribute("href", "javascript:insertTags('', \"" + messages[i] + "\", '');" +
"javascript:changeSummary(\"" + commentaires[i] + "\");" );
ref.appendChild(img);
toolbar.appendChild(ref);
}
}
}
function changeSummary(sampleText) {
document.editform.wpSummary.value = sampleText;
}
$(DeluxeBar);
function addToSummary(str)
{
document.editform.wpSummary.value += " " + str
}
function DeluxeSummary()
{
var sumLbl = document.getElementById("wpSummaryLabel")
if (sumLbl)
{
//élargissement boite de résumé
var sumInput = document.getElementById("wpSummary")
sumInput.style.width = "90%"
var titles = new Array()
titles.push("ébauche")
titles.push("+ cat ")
titles.push("+ wiki ")
titles.push("+ interwiki")
titles.push("+ portail ")
titles.push("vandalisme ")
titles.push("spam")
titles.push("Cor leins int")
titles.push("Blanchit")
titles.push("MeP")
titles.push("ortho/gram")
titles.push("retouches")
titles.push("ajInfo")
titles.push("recat")
var inputs = new Array()
inputs.push("+ {{ébauche}}")
inputs.push("+ catégorie")
inputs.push("+ wikification")
inputs.push("+ liens interwiki")
inputs.push("+ bandeau portail")
inputs.push("Revert:vandalisme")
inputs.push("Revert:Lien externe non pertinent")
inputs.push("correction lien interne")
inputs.push("Blanchit:bac à sable")
inputs.push("mise en page")
inputs.push("correction orthographe/grammaire")
inputs.push("diverses retouches")
inputs.push("ajout d’infos")
inputs.push("changement catégorie")
inputs.push("bac à sable")
var str = ""
for (var cpt = 0; cpt < titles.length; cpt ++)
{
str += "<a href=\"javascript:addToSummary('" + inputs[cpt] + "')\""
+ " class=\"sumLink\" title=\"Ajouter '" + inputs[cpt] +"' dans la boîte de résumé\">"
+ titles[cpt]
+ " ·</a> "
}
sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML
}
}
$(DeluxeSummary);
// Onglet Purge
function OngletPurge() {
var a = document.getElementById("p-cactions");
if (a)
{
var pageName = document.title.replace(" - Wikipédia", "");
b = a.getElementsByTagName("ul");
if(b.length > 0)
{
b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-nstab-user">'
+ '<a href="/w/index.php?action=purge&title=' + pageName + '">purger</a>'
+ '</li>';
}
}
}
// Onglet Purge
$(OngletPurge);
// Modification de l'onglet Google de Dake par GôTô
function getArticleName()
{
var strOut = document.title
// case search
if (strOut == "Rechercher - Wikipédia")
return document.getElementById("lsearchbox").value
// case article being modified
strOut = strOut.replace("modification de ", "").replace(" - Modifier", "")
strOut = strOut.replace(" - Prévisualiser", "")
strOut = strOut.replace(" - Wikipédia", "")
return strOut
}
var whichWiki = "en"
function setWiki()
{
var newWiki = document.getElementById("elmtWhichWiki").value
// trim
newWiki = newWiki.replace(/ /g, "")
if (/com(mon)?/.test(newWiki))
newWiki = "commons"
else if (/méta/.test(newWiki))
newWiki = "meta"
// no need to change
if (newWiki == whichWiki)
return
var elmt = document.getElementById("whichW")
// it was a wikipedia and now it's a wikimedia (commons or meta)
if (/commons|meta/.test(newWiki) && !(/commons|meta/.test(whichWiki)))
{
elmt.href = elmt.href.replace(".wikipedia.org", ".wikimedia.org")
elmt.title = elmt.title.replace(".wikipedia.org", ".wikimedia.org")
}
// it was a wikimedia (commons or meta) and now it's a wikipedia
else if (/commons|meta/.test(whichWiki) && !(/commons|meta/.test(newWiki)))
{
elmt.href = elmt.href.replace(".wikimedia.org", ".wikipedia.org")
elmt.title = elmt.title.replace(".wikimedia.org", ".wikipedia.org")
}
// in any case
elmt.href = elmt.href.replace("http://" + whichWiki, "http://" + newWiki)
elmt.title = elmt.title.replace("sur " + whichWiki, "sur " + newWiki)
whichWiki = newWiki
}
// auteur : Utilisateur:Dake
function OngletGoogle() {
var a = document.getElementById("p-cactions");
if (a)
{
var pageName = document.title.replace(" - Wikipédia", "");
b = a.getElementsByTagName("ul");
if(b.length > 0)
{
b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-nstab-user"><img src="http://www.google.com/intl/en/logos/Logo_60wht.gif" height="20px">'
+ '<a href="http://www.google.fr/search?num=20&hl=en&safe=off&q=site%3Afr.wikipedia.org+' + pageName + '&btnG=Search">'
+ '(fr)</a>'
+ '<a href="http://www.google.fr/search?num=20&hl=en&safe=off&q=' + pageName + '&btnG=Search">'
+ '(web)</a>'
+ '</li>';
}
}
}
$(OngletGoogle);
// by GôTô :)
function customSpecialChars()
{
var elmtP = document.getElementById("editpage-copywarn")
if (elmtP == undefined)
return // not editing mode
elmtP = elmtP.getElementsByTagName("P")[0]
//for adding instead of replacing, switch the comments
//var str = ""
var str = "Caractères spéciaux: "
// add your links here ; Note for newbies: accesskey = shortcut (ALT+accesskey) -- don't forget there are shortcuts already in use: e -> edit ; a -> article ; etc.
str += "<a href=\"javascript:insertTags('«','»','')\" accesskey=\"<\">«»</a> "
str += "<a href=\"javascript:insertTags('ô','', '')\" accesskey=\"o\">ô</a> "
str += "<a href=\"javascript:insertTags('ê','', '')\" accesskey=\"é\">ê</a> "
//for adding instead of replacing, switch the comments
//elmtP.innerHTML += str
elmtP.innerHTML = str
}
function disambiguationHook ()
{
var toto = document.title;
// le texte de l'homonymie
var old_text = "presse";
// la nouvelle description de l'homonymie
var new_text = "presse écrite";
if (toto.match(/^modification/)) {
var text = document.getElementById("wpTextbox1");
var index = 0;
remplace = false;
while (true) {
var position = text.value.indexOf("["+old_text+"]",position);
if (position == -1)
break;
var beginLine = text.value.lastIndexOf("\n",position);
var endLine = text.value.indexOf("\n",position);
if ( window.confirm("Remplacer dans "+text.value.substring(beginLine,endLine))) {
var aremplacer = (text.value.substring(0,position)+ "[" + new_text +"|"+old_text + "]" + text.value.substring(position+2+old_text.length) );
text.value = aremplacer;
remplace = true;
}
position +=1;
}
if (remplace) {
document.getElementById("wpSummary").value ="Correction des [[Wikipédia:Projet/Liens vers les pages d'homonymie|liens vers les pages d'homonymie]] ("+new_text+")"
}
}
}
//la ligne suivante à commenter pour desactiver le hook
$( disambiguationHook );
// -----------------------------------------------------------------------------
// Add revert buttons to the page
// -----------------------------------------------------------------------------
function AddRevertButtons() {
var l, article = '', vandal;
// Add 'revert' links to a diff page
l = document.getElementById('bodyContent').getElementsByTagName('td');
for (i = 0; i < l.length; i++) {
if (l[i].className == 'diff-otitle') {
article = l[i].getElementsByTagName('a')[0].href.split('&')[0].replace(/[^\/]*\/\/[^\/]*/, '');
} else if (l[i].className == 'diff-ntitle') {
var toplink = l[i].getElementsByTagName('a')[0].href;
vandal = l[i].getElementsByTagName('a')[2].title.split(':')[1];
var t = l[i].innerHTML
n = t.indexOf('</a>) <br') + t.indexOf('</A>) <BR') + 1; // XXX: WOW HACK!!!!
if (n >= 0 && article != '' && toplink.indexOf('oldid=') == -1) {
l[i].innerHTML = t.substring(0, n + 5) + ' <strong>[<a href="' + article + '&fakeaction=rollback&vandal=' + vandal + '&token=' + hex_md5(article + vandal + document.cookie) + '">' + rollbacklink + '</a>]</strong> ' + t.substring(n + 5, t.length);
}
}
}
// Add 'revert' links to a contributions page
if (location.href.indexOf(':Contributions') != -1) {
var c = document.getElementById('contentSub');
var a = c.getElementsByTagName('a');
if (a.length >= 2) {
vandal = a[0].innerHTML;
} else {
vandal = c.innerHTML.replace(/ \(.*/, '').replace(/.* /, '');
}
l = document.getElementById('bodyContent').getElementsByTagName('li');
for (i = 0; i < l.length; i++) {
var t = l[i].innerHTML
// If we are already a sysop on this wiki, abort
if (t.indexOf('>' + rollbacklink + '</a>]') != -1)
break;
//if (t.indexOf('&diff=0') != -1) {
if (t.indexOf('<strong> (') != -1) {
article = l[i].getElementsByTagName('a')[0].href.split('&')[0].replace(/[^\/]*\/\/[^\/]*/, '');
l[i].innerHTML += ' [<a href="' + article + '&fakeaction=rollback&vandal=' + vandal + '&token=' + hex_md5(article + vandal + document.cookie) + '">' + rollbacklink + '</a>]';
}
}
}
}
// -----------------------------------------------------------------------------
// Modify the page once it is loaded
// -----------------------------------------------------------------------------
if (window.addEventListener) {
window.addEventListener("load", PerformRevert, false);
window.addEventListener("load", AddRevertButtons, false);
} else if (window.attachEvent) {
window.attachEvent("onload", PerformRevert);
window.attachEvent("onload", AddRevertButtons);
}
var suiviManagerAllPages = new Array();
function SuiviManagerRegexp(regexp)
{
var match = new RegExp(regexp);
for (var i=0;i<suiviManagerAllPages.length;i++) {
var pageName = suiviManagerAllPages[i].childNodes[0].getAttribute("value");
if (match.test(pageName)) {
suiviManagerAllPages[i].childNodes[0].checked=true;
}
}
}
function SuiviManagerLiensRouges()
{
for (var i=0;i<suiviManagerAllPages.length;i++) {
var pageClass = suiviManagerAllPages[i].childNodes[1].getAttribute("class");
if (pageClass && pageClass=="new") {
suiviManagerAllPages[i].childNodes[0].checked=true;
}
}
}
function SuiviManagerDeselect()
{
for (var i=0;i<suiviManagerAllPages.length;i++) {
suiviManagerAllPages[i].childNodes[0].checked=false;
}
}
function SuiviManager() {
if (mw.config.get('wgCanonicalSpecialPageName') !== 'EditWatchlist') return;
var a=-1;
var interfaceMsg = new Array();
var regexpList = new Array();
//////////////////////////////////////////////////
// Expressions régulières et liens de l'interface
//
// besoin d'aide pour les regexp ?
// http://www.commentcamarche.net/javascript/jsregexp.php3
//////////////////////////////////////////////////
interfaceMsg[++a] = "<b>Tout cocher</b>";
regexpList[a] = "^.*";
interfaceMsg[++a] = "Utilisateurs";
regexpList[a] = "^Utilisateur:";
interfaceMsg[++a] = "Wikipédia:*";
regexpList[a] = "^Wikipédia:";
interfaceMsg[++a] = "Sous-pages de PàS";
regexpList[a] = "^Wikipédia:Pages à supprimer\/";
interfaceMsg[++a] = "Sous-pages de PàV";
regexpList[a] = "^Wikipédia:Pages à vérifier\/";
interfaceMsg[++a] = "Pages du bistro";
regexpList[a] = "^Wikipédia:Le Bistro\/";
interfaceMsg[++a] = "Images";
regexpList[a] = "^Image:";
interfaceMsg[++a] = "Modèles";
regexpList[a] = "^Modèle:";
interfaceMsg[++a] = "Aide";
regexpList[a] = "^Aide:";
interfaceMsg[++a] = "Catégories";
regexpList[a] = "^Catégorie:";
interfaceMsg[++a] = "Portails";
regexpList[a] = "^Portail:";
//////////////////////////////////////////////////
var topTag = document.getElementById("contentSub")
// récupère toutes les pages
var watchlist = document.getElementsByTagName("ul");
for (u=0;u<watchlist.length;u++) {
var entries = watchlist[u].getElementsByTagName("li");
for (i=0;i<entries.length;i++) {
suiviManagerAllPages.push(entries[i]);
}
}
// prépare la mini-interface
var str = "<div style=\"background-color:#8ecfe4;font-size:1px;height:8px;border:1px solid #AAAAAA;-moz-border-radius-topright:0.5em;-moz-border-radius-topleft:0.5em;\"></div>"
+ "<div style=\"border:1px solid #6ac1de;border-top:0px solid white;padding:5px 5px 0 5px;margin-bottom:3ex;\"><p>"
+ "<div style=\"float: left; text-align: left; white-space: nowrap;\"></div>"
for (var cpt = 0; cpt < interfaceMsg.length; cpt ++) {
str += "<a href=\"javascript:SuiviManagerRegexp('" + regexpList[cpt] + "')\">"
+ interfaceMsg[cpt]
+ " ·</a> "
}
str += "<a href=\"javascript:SuiviManagerLiensRouges()\">"
+ "Retirer les liens rouges"
+ " ·</a> "
str += "<a href=\"javascript:SuiviManagerDeselect()\">"
+ "<b>Enlever toutes les coches</b>"
+ " ·</a> "
topTag.innerHTML = topTag.innerHTML + "<br clear=all />" + str + "<p></div>"
}
$(SuiviManager);
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}
function OptimizedSuivi()
{
if (document.URL.indexOf("http://fr.wikipedia.org/wiki/Special:Watchlist")==0 ||
document.URL.indexOf("http://fr.wikipedia.org/w/index.php?title=Special:Watchlist")==0 ){
var allDays = document.getElementsByTagName("ul");
for (i=0; i<allDays.length; i++) {
if (allDays[i].getAttribute("class") == "special") {
var artList = allDays[i].getElementsByTagName("li");
for (j=0; j<artList.length; j++) {
var elem = artList[j];
var aTag = elem.getElementsByTagName("a");
var articleName = aTag[0].getAttribute("title");
var stopWatch = "/w/index.php?title=" + articleName + "&action=unwatch"
var newElement = document.createElement("a");
newElement.setAttribute("href",stopWatch);
var newText = document.createTextNode("stop");
newElement.appendChild(newText);
var newPar = document.createTextNode(") (")
// séparation des cas (nouvel article, ou déjà existant)
if (aTag[0].childNodes[0].data == "diff") {
insertAfter(elem, newPar, aTag[1]);
} else {
insertAfter(elem, newPar, aTag[0]);
}
insertAfter(elem, newElement, newPar);
}
}
}
}
}
$(OptimizedSuivi);
/* Lien Editcount */
var tabAction = "p-cactions";
function addECButton()
{
if ( window.location.href.indexOf('Contributions') < 0) return;
var c = document.getElementById('contentSub');
var a = c.getElementsByTagName('a');
name = a[0].innerHTML;
var l = document.getElementById(tabAction);
t = l.innerHTML;
ind = t.toLowerCase().indexOf("</ul>");
before = t.substring(0,ind);
after = t.substring(ind);
pitem = "<li><a href='http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user="+escape(name)+"&dbname=frwiki_p'>"+
"<div id='EditCount' style='display:inline;'>" +
"Editcount" +
"</div></a></li>";
l.innerHTML = before + pitem + after ;
}
$(addECButton);
//---------------------------------------------------------------------------------------------Objets (cookies)
document.write('<script type="text/javascript" src="'
+ 'http://fr.wikipedia.org/w/index.php?title=Utilisateur:GôTô/objects.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
function getArticleName()
{
var strOut = document.title
// case search
if (strOut == "Rechercher - Wikipédia")
return document.getElementById("lsearchbox").value
// case article being modified
strOut = strOut.replace("modification de ", "").replace(" - Modifier", "")
strOut = strOut.replace(" - Prévisualiser", "").replace(" - Wikipédia", "")
return strOut
}
function addWatchUserLinks() {
var a = document.getElementById("p-search")
if (a)
a = a.getElementsByTagName("div")[0]
if (a)
{
var str = a.innerHTML + ' <a class="searchLink" href="javascript:watchUser(document.getElementById(\'searchInput\').value)" title="Mettre en évidence les contributions de cet utilisateur">'
+ 'watch user</a>'
+ ' <a class="searchLink" href="javascript:unwatchUser(document.getElementById(\'searchInput\').value)" title="Ne plus mettre en évidence les contributions de cet utilisateur">'
+ 'unwatch user</a>'
a.innerHTML = str
}
}
function watchUser(usr) {
if (!isUserWatched(usr)) {
var all = cookies.get("watchUser")
cookies.set("watchUser", (all ? all + usr + "/" : usr + "/"))
highlightWatchedUsers()
}
}
function unwatchUser(usr) {
if (!isUserWatched(usr))
return
var all = cookies.get("watchUser").split("/")
var out = ""
for (var cpt = 0 ; cpt < all.length ; cpt++)
if (all[cpt] != usr && all[cpt])
out += all[cpt] + "/"
cookies.set("watchUser", out)
highlightWatchedUsers()
}
function isUserWatched(usr) {
var all = cookies.get("watchUser")
if (!all)
return null
for (var cpt = 0 ; cpt < all.split("/").length ; cpt++)
if (all.split("/")[cpt] == usr)
return 1
return null
}
function highlightWatchedUsers() {
if (getArticleName() != "Modifications récentes")
return
var uls = document.getElementsByTagName("ul")
var ul = uls[0]
for (var cpt = 1 ; cpt < uls.length && ul.className != "special" ; cpt++)
ul = uls[cpt]
var lis = ul.getElementsByTagName("li")
for (var cpt = 0 ; cpt < lis.length ; cpt++) {
var usr = lis[cpt].getElementsByTagName("a")[3].innerHTML
if (lis[cpt].getElementsByTagName("span")) {
var spans = lis[cpt].getElementsByTagName("span")
for (var cpt2 = 0 ; cpt2 < spans.length ; cpt2++)
if (spans[cpt2].className == "newpage")
var usr = lis[cpt].getElementsByTagName("a")[2].innerHTML
}
if (isUserWatched(usr))
lis[cpt].className = "userWatched"
else
lis[cpt].className = ""
}
}
$(highlightWatchedUsers);
$(addWatchUserLinks);
//</pre> </nowiki></pre>