User:Edouard-lopez/monobook.js

// ta['n-RC'] = new Array('R','Modifications récentes.'); ta['t-euplode'] = new Array('U','Importer une image ou un son.');

////////////////////////////////////////////////////////////////////////////////

function googleOnglet { 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 + '' + '' + 'A_G' + '' + 'en' + '' + 'co' + '' + 'fr' + '' + 'ja' + ''; }       }      } $(googleOnglet);

////////////////////////////////////////////////////////////////////////////////

function MiluxeBar { if (document.createTextNode) { var toolbar = document.getElementById("toolbar"); if (!toolbar) return; ///// zone personnalisable //// var messages = new Array // le texte a été splitté sinon Mediawiki casse tout... messages[0] = "\\n" + "~\\n"; messages[1] = "\\n" + "~" + " - " + "" + "" + "~" + " \\n"; messages[2] = ""; messages[3] = ""; messages[4] = "[" + "[Category:" + "]]"; messages[5] = " "; messages[6] = "= ="; messages[7] = "== =="; messages[8] = "=== ==="; messages[9] = ": "; messages[10] = "* "; messages[11] = "# "; messages[12] = " "; messages[13] = " "; messages[14] = " "; messages[15] = "undefined"; messages[16] = "undefined"; messages[17] = "";

var images = new Array images[0] = "http://upload.wikimedia.org/wikipedia/commons/0/04/User_red.png"; images[1] = "http://upload.wikimedia.org/wikipedia/commons/7/74/User_suit.png"; // http://upload.wikimedia.org/wikipedia/commons/b/bd/Crystal_clock.png images[2] = "http://upload.wikimedia.org/wikipedia/commons/4/49/Icons-mini-page_find.gif"; // http://upload.wikimedia.org/wikipedia/commons/d/dd/Crystal_kghostview.png images[3] = "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Crystal_128_keyboard_layout.png/16px-Crystal_128_keyboard_layout.png"; images[4] = "http://upload.wikimedia.org/wikipedia/commons/1/18/Icons-mini-page_bookmark.gif"; images[5] = "http://upload.wikimedia.org/wikipedia/commons/5/52/Arrow_rotate_clockwise.png"; images[6] = "http://upload.wikimedia.org/wikipedia/commons/7/71/Text_heading_1.png"; images[7] = "http://upload.wikimedia.org/wikipedia/commons/6/65/Text_heading_2.png"; images[8] = "http://upload.wikimedia.org/wikipedia/commons/c/ce/Text_heading_3.png"; images[9] = "http://upload.wikimedia.org/wikipedia/commons/8/8a/Text_indent.png"; images[10] = "http://upload.wikimedia.org/wikipedia/commons/2/2b/Text_list_bullets.png"; images[11] = "http://upload.wikimedia.org/wikipedia/commons/7/7d/Text_list_numbers.png"; images[12] = "http://upload.wikimedia.org/wikipedia/commons/6/63/Text_strikethrough.png"; images[13] = "http://upload.wikimedia.org/wikipedia/commons/c/cb/Text_underline.png"; images[14] = "http://upload.wikimedia.org/wikipedia/commons/e/e2/Text_smallcaps.png"; images[15] = "http://upload.wikimedia.org/wikipedia/commons/c/c6/Text_subscript.png"; images[16] = "http://upload.wikimedia.org/wikipedia/commons/e/e5/Text_superscript.png"; images[17] = ""

var commentaires = new Array commentaires[0] = ""; commentaires[1] = ""; commentaires[2] = ""; commentaires[3] = ""; commentaires[4] = ""; commentaires[5] = ""; commentaires[6] = ""; commentaires[7] = ""; commentaires[8] = ""; commentaires[9] = ""; commentaires[10] = ""; commentaires[11] = ""; commentaires[12] = ""; commentaires[13] = ""; commentaires[14] = ""; commentaires[15] = ""; commentaires[16] = ""; commentaires[17] = "";

////////////////////////////////

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(nwsum) { if (nwsum!="") { document.editform.wpSummary.value = nwsum; } }

$(MiluxeBar);

////////////////////////////////////////////////////////////////////////////////

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);

function News_Aide_RC { var a = document.getElementById("p-navigation"); if (a) {   b = a.getElementsByTagName("ul"); if(b.length > 0) {     b[0].innerHTML = b[0].innerHTML + 'News | Help</a> | <a style="display: inline" id="n-RC" title="Modifications récentes"href="/w/index.php?title=Special:Recentchanges">RC</a></li>' } } } $(News_Aide_RC);

function Bistro_PaS_PaF { var a = document.getElementById("p-navigation"); if (a) {   b = a.getElementsByTagName("ul"); if(b.length > 0) {     b[0].innerHTML = b[0].innerHTML + '<li><a style="display: inline" id="n-bistro" title="Wikipedia:Village pump" href="/w/index.php?title=Wikip%C3%A9dia:Village_pump&action=purge">Village_pump</a></li>' } } } $(Bistro_PaS_PaF);

function Vand_CSS_JS { var a = document.getElementById("p-navigation"); if (a) {   b = a.getElementsByTagName("ul"); if(b.length > 0) {     b[0].innerHTML = b[0].innerHTML + '<li><a style="display: inline" id="n-CSS" title="User:lyhana8/monobook.css" href="/w/index.php?title=User:lyhana8/monobook.css">CSS</a> | <a style="display: inline" id="n-JS" title="User:lyhana8/monobook.js"href="/w/index.php?title=User:lyhana8/monobook.js">JS</a></li>' } } }

$(Vand_CSS_JS);

function euplode { var a = document.getElementById("p-tb"); if (a) {   b = a.getElementsByTagName("ul"); if(b.length > 0) {     b[0].innerHTML = b[0].innerHTML + '<li> ' + '<a href="/wiki/Special:Upload">' + 'Import media</a> </li>' } } } $(euplode);

function OptimizedShortPages { if (document.URL.indexOf("http://fr.wikipedia.org/wiki/Special:Shortpages")!=0) return; var mainNode = document.getElementsByTagName("ol"); var allArticles = mainNode[0].getElementsByTagName("li"); for (i=0; i<allArticles.length; i++) { var articleName = allArticles[i].childNodes[0].getAttribute("title");

var historyElement = document.createElement("a"); var histUrl     = "/w/index.php?title=" + articleName + "&action=history" historyElement.setAttribute("href", histUrl); var historyText = document.createTextNode("… (hist) "); historyElement.appendChild(historyText); insertAfter(allArticles[i], historyElement, allArticles[i].childNodes[1]); var relatedElement = document.createElement("a"); var relatedUrl = "/wiki/Special:Whatlinkshere/" + articleName relatedElement.setAttribute("href", relatedUrl); var relatedText = document.createTextNode(" (liens) "); relatedElement.appendChild(relatedText); var diffElement = document.createElement("a"); var diffUrl     = "/w/index.php?title=" + articleName + "&diff=0" diffElement.setAttribute("href", diffUrl); var diffText = document.createTextNode(" (diff) "); diffElement.appendChild(diffText); insertAfter(allArticles[i], relatedElement, historyElement); insertAfter(allArticles[i], diffElement, relatedElement); insertAfter(allArticles[i], document.createTextNode(allArticles[i].childNodes[1].data), diffElement); allArticles[i].removeChild(allArticles[i].childNodes[1]); } }

$(OptimizedShortPages);

function morelinks { var tabs = document.getElementById('p-cactions').cloneNode(true); tabs.id = 'mytabs'; var listitems = tabs.getElementsByTagName('LI'); for (i=0;i<listitems.length;i++) { if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id; } document.getElementById('column-content').appendChild(tabs); } if (window.addEventListener) window.addEventListener("load",morelinks,false); else if (window.attachEvent) window.attachEvent("onload",morelinks);

// - // XMLHttpRequest support // - if (document.implementation.createDocument) { var xmlparser = new DOMParser; }

function XMLParse(string) { if (document.implementation.createDocument) { return xmlparser.parseFromString(string, "text/xml"); } else if (window.ActiveXObject) { var xmldoc = new ActiveXObject("Microsoft.XMLDOM"); xmldoc.async = "false"; ret = xmldoc.loadXML(string); if (!ret) return null; return xmldoc.documentElement; } return null; }

var xmlhttp;

function HTTPClient { var http; if(window.XMLHttpRequest) { http = new XMLHttpRequest; } else if (window.ActiveXObject) { try { http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { http = false; }   }  }  return http; }

// - // Our nice Revert functions // - var gml_vandal, gml_editor, gml_url;

function PerformRevert { var l, token = '', revert = false; // Look for '&fakeaction=rollback' in URL gml_url = location.pathname; l = location.search.substring(1).split('&'); for (i = 0; i < l.length; i++) { var n = l[i].indexOf('='); var name = l[i].substring(0, n); if (name == 'fakeaction') { if (l[i].substring(n + 1) == 'rollback') revert = true; } else if (name == 'vandal') { gml_vandal = unescape(l[i].substring(n + 1)); } else if (name == 'token') { token = unescape(l[i].substring(n + 1)); } else if (name == 'title') { gml_url += '?' + l[i]; } }  if (!revert) return; document.getElementById('bodyContent').innerHTML = 'Please wait, reverting edits by ' + gml_vandal + '...'; // Avoid XSS kiddies by using a special token if (token == '' || token != hex_md5(gml_url + gml_vandal + document.cookie)) { document.getElementById('bodyContent').innerHTML += ' Bad authentication token!'; return; }

xmlhttp = HTTPClient; if (!xmlhttp) return; document.getElementById('bodyContent').innerHTML += ' Getting article history...'; xmlhttp.open("GET", gml_url + '&action=history&limit=50', true); xmlhttp.onreadystatechange = RevertStepTwo; xmlhttp.send(null); }

function RevertStepTwo { if (xmlhttp.readyState != 4) return var l; var oldid; // Get the vandal and new editor names gml_editor = ''; doc = XMLParse(xmlhttp.responseText); l = doc.getElementById('pagehistory').getElementsByTagName('li'); //l = doc.selectSingleNode('//*[@id="pagehistory"]').getElementsByTagName('li'); for (i = 0; i < l.length; i++) { var name = l[i].getElementsByTagName('span')[0].getElementsByTagName('a')[0].innerHTML; if (i == 0 && name != gml_vandal) { document.getElementById('bodyContent').innerHTML += ' Error: ' + gml_vandal + ' is not the last editor!'; return; } else if (i > 0 && name != gml_vandal) { oldid = l[i].getElementsByTagName('input')[0].value; gml_editor = name; break; } }  if (gml_editor == '') { document.getElementById('bodyContent').innerHTML += ' Error: ' + gml_vandal + ' is the only editor!'; return; }

xmlhttp = HTTPClient; if (!xmlhttp) return; document.getElementById('bodyContent').innerHTML += ' Getting article edit form (GET' + gml_url + '&action=edit&oldid=' + oldid + ')...'; xmlhttp.open('GET', gml_url + '&action=edit&oldid=' + oldid, true); xmlhttp.onreadystatechange = RevertStepThree; xmlhttp.send(null); }

function RevertStepThree { if (xmlhttp.readyState != 4) return var form, newform, l; // Insert the downloaded form in our current page, using // only hidden form inputs. doc = XMLParse(xmlhttp.responseText); form = doc.getElementById('editform'); newform = document.createElement('form'); l = form.getElementsByTagName('textarea'); for (i = l.length; i--; ) { var t = document.createElement('input'); t.type = 'hidden'; t.name = l[i].name; t.value = l[i].innerHTML; newform.appendChild(t); } l = form.getElementsByTagName('input'); for (i = l.length; i--; ) { if (l[i].name == 'wpSummary') { l[i].value = revertpage.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal); } else if (l[i].name == 'wpMinoredit') { l[i].value = '1'; } else if (l[i].name == 'wpWatchthis') { if (!l[i].checked) continue; // Donâ€™t touch the "watch" status l[i].value = "on"; } else if (l[i].name == 'wpPreview') { continue; } else if (l[i].name == 'wpDiff') { continue; }   l[i].type = 'hidden'; newform.appendChild(l[i]); } newform.name = form.name; newform.method = form.method; newform.id = form.id; newform.action = form.action; document.getElementById('bodyContent').innerHTML += ' Submitting form...'; document.getElementById('bodyContent').appendChild(newform); // Submit the form newform.submit; }

// - // 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')[1].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) + '   [<a href="' + article + '&fakeaction=rollback&vandal=' + vandal + '&token=' + hex_md5(article + vandal + document.cookie) + '">' + rollbacklink + '</a>] ' + 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('&amp;diff=0') != -1) {      if (t.indexOf(' (') != -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); }

// - // Fonction ImageUse – Merci Anakin // -

function ImageUse {  var imagename = document.getElementById('ca-nstab-image').firstChild.href; imagename = imagename.substring(imagename.indexOf("Image:") + 6); if(imagename) {    var li = document.createElement('li'); li.id = 'ca-imageuse';

var a = document.createElement('a'); a.appendChild(document.createTextNode("Voir l'utilisation")); a.href = 'http://www.juelich.de/avatar/check-usage/check-usage.php?filename=' + imagename + '&template';

li.appendChild(a);

document.getElementById('ca-watch').parentNode.appendChild(li); } } if (window.addEventListener) window.addEventListener('load', ImageUse, false); else if (window.attachEvent) window.attachEvent ('onload', ImageUse);

// auteur : Utilisateur:Anakin // dernière version : 08 décembre 2005 function startSearch { var textsearch = document.getElementById('searchInput').value;

var link = "http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?search="; link = link + textsearch; link = link + "&timeout=120&minor=1";

window.location = link; }

function globalSearch { var pSearchElement = document.getElementById('searchform');

var newElement = document.createElement("input"); newElement.setAttribute("type", "button"); newElement.setAttribute("name", "globalsearch"); newElement.setAttribute("class", "searchButton"); newElement.setAttribute("value", "Recherche globale"); newElement.setAttribute("onClick", "startSearch");

pSearchElement.appendChild(newElement); } $(globalSearch);

// Auteur : Anakin // Dernière mise à jour : 11 décembre 2005 function CategoryTree { var element = document.getElementById('ca-nstab-category'); if (element) {   var categoryname = element.firstChild.href; categoryname = categoryname.substring(7);

var wikiname = categoryname.substring(0, categoryname.indexOf('.'));

var indexofname = categoryname.indexOf(":") + 1; categoryname = categoryname.substring(indexofname);

var indexofampercent = categoryname.indexOf("&"); if (indexofampercent != -1) categoryname = categoryname.substring(0, indexofampercent);

var li = document.createElement('li'); li.id = 'ca-categorytree';

var a = document.createElement('a'); a.appendChild(document.createTextNode("Arborescence")); a.href = 'http://tools.wikimedia.de/~daniel/WikiSense/CategoryTree.php?wiki=' + wikiname + '&art=on&cat=' + categoryname;

li.appendChild(a);

document.getElementById('ca-nstab-category').parentNode.appendChild(li); } } $(CategoryTree);

////////////////////////////////////// function ResumeDeluxeModif(content) {   if (document.editform.wpSummary.value != 0) document.editform.wpSummary.value += ' - '; document.editform.wpSummary.value += content; }

// Résumé Deluxe // Fonction ResumeDeluxeModif // // Code : Dake function ResumeDeluxe {   // vous pouvez ajouter vos messages ci-dessous - attention aux apostrophes et aux // guillemets qui peuvent casser le script var messages = new Array messages[0] = "restructuration"; messages[1] = "ortho"; messages[2] = "categories"; messages[3] = "interwiki"; messages[4] = "links (wikification)"; messages[5] = "stub flag"; messages[6] = "translation flag"; messages[7] = "answer"; messages[8] = "pictures";

// texte dans les boutons (pour éviter de prendre trop de place) var labelBoutons = new Array labelBoutons[0] = "structur"; labelBoutons[1] = "ortho"; labelBoutons[2] = "cat"; labelBoutons[3] = "interwiki"; labelBoutons[4] = "wiki"; labelBoutons[5] = "ébauche"; labelBoutons[6] = "trad"; labelBoutons[7] = "ans"; labelBoutons[8] = "pic"; var nombreBoutonsParLigne = 20; // ne rien toucher ci-dessous var mainNode = document.getElementById("wpSummaryLabel"); if (!mainNode) return;

var summaryNode = mainNode; var formButtons = document.createElement("form");

for (var i = 0; i < messages.length; i++) {       if (i%nombreBoutonsParLigne == 0) formButtons.appendChild(document.createElement("p"));

var nodeInput = document.createElement("input"); nodeInput.setAttribute("type", "button"); nodeInput.setAttribute("value", labelBoutons[i]); nodeInput.setAttribute("onClick", "ResumeDeluxeModif('" + messages[i] + "')");

formButtons.appendChild(nodeInput); }   summaryNode.appendChild(formButtons); }

$(ResumeDeluxe); //