Utilisateur:Elemiah/monobook.js
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) ;
Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.importScript('Utilisateur:Elemiah/automationTool.js');
//Bistro d'aujourd'hui
function TodayDate() {
m = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre");
today = new Date();
day = today.getDate();
year = today.getYear();
if (year < 2000)
year = year + 1900;
return (day + " " + m[today.getMonth()] + " " + year);
}
function getWeekNr()
{
var today = new Date();
Year = takeYear(today);
Month = today.getMonth();
Day = today.getDate();
now = Date.UTC(Year,Month,Day+1,0,0,0);
var Firstday = new Date();
Firstday.setYear(Year);
Firstday.setMonth(0);
Firstday.setDate(1);
then = Date.UTC(Year,0,1,0,0,0);
var Compensation = Firstday.getDay();
if (Compensation > 3) Compensation -= 4;
else Compensation += 3;
NumberOfWeek = Math.round((((now-then)/86400000)+Compensation)/7);
return NumberOfWeek;
}
function takeYear(theDate)
{
x = theDate.getYear();
var y = x % 100;
y += (y < 38) ? 2000 : 1900;
return y;
}
function Semaine_courante() {
today = new Date();
year = today.getYear();
if (year < 2000)
year = year + 1900;
return ("semaine " + getWeekNr() + " " + year );
}
// Rajout de lien dans les onglets en haut de la page !
// Rajout de lien dans le menu de gauche !
function Menu() {
var tDate = TodayDate();
var tDate_court = tDate.substr(0,tDate.length-5);
var tSemaine = Semaine_courante();
var a = document.getElementById("p-navigation");
if (a) {
b = a.getElementsByTagName("ul");
if (b.length > 0) {
b[0].innerHTML = b[0].innerHTML
+ '<li><span title="La page du jour">'
+ '<a href="/wiki/'+ tDate_court +'">La page du '+tDate_court+'</a></span></li>'
+ '<li><span title="Le Bistrot du jour">'
+ '<a href="/wiki/Wikipédia:Le Bistro/'+ tDate +'">Le Bistro</a></span>'
+ " - " +'<span title="Le Bistrot trié par nb de modifs">'
+ '<a href="/wiki/Utilisateur:Escalabot/Liste_des_messages_du_bistro_tri%C3%A9s_par_nombre_de_modifications">(nb)</a></span>'
+ " - " +'<span title="Le Bistrot trié par date">'
+ '<a href="/wiki/Utilisateur:Escalabot/Liste_des_messages_du_bistro_tri%C3%A9s_par_date">(date)</a></span></li>'
+ '<li><span title="Wikimag">'
+ '<a href="/wiki/Wikipédia:Wikimag">Wikmag</a></span>'
+ " - " +'<span title="Accueil de la communauté">'
+ '<a href="/wiki/Wikipédia:Accueil_de_la_communauté">Communauté</a></span></li>'
+ '<li><span title="Page courante PàS">'
+ '<a href="/wiki/Wikipédia:Pages_à_supprimer">PàSupr</a></span>'
+ " - " + '<span title="Page courante IàS">'
+ '<a href="/wiki/Wikipédia:Images_à_supprimer">Image à Supr</a></span></li>'
+ '<li><span title="Recherche Google">'
+ '<a href="http://www.google.fr/custom?sa=Google+Search&domains=fr.wikipedia.org;wikipedia.org&sitesearch=fr.wikipedia.org">Recherche Google</a></span></li>'
}
}
var a = document.getElementById("p-Contribuer");
if (a) {
b = a.getElementsByTagName("ul");
if (b.length > 0) {
b[0].innerHTML = b[0].innerHTML
+ '<li><span title="L\'accueil communautaire">'
+ '<a href="/wiki/Wikipédia:Accueil">Communauté</a></span>'
+ " - " + '<span title="Aide.">'
+ '<a href="/wiki/Aide:Sommaire">Aide</a></span></li>'
}
}
}
$(Menu);
// Ajout dans la page de suivi de modification de contrôle pour sélectionner plus rapidement des pages
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=0;
var b=0;
var interfaceMsg = new Array();
var regexpList = new Array();
// Expressions régulières et liens de l'interface
interfaceMsg[a++] = "<b>Tout cocher</b>";
regexpList[b++] = "^.*";
interfaceMsg[a++] = "Utilisateurs";
regexpList[b++] = "^Utilisateur:";
interfaceMsg[a++] = "Wikipédia:*";
regexpList[b++] = "^Wikipédia:";
interfaceMsg[a++] = "Sous-pages de PàS";
regexpList[b++] = "^Wikipédia:Pages à supprimer\/";
interfaceMsg[a++] = "Sous-pages de PàV";
regexpList[b++] = "^Wikipédia:Pages à vérifier\/";
interfaceMsg[a++] = "Pages du bistro";
regexpList[b++] = "^Wikipédia:Le Bistro\/";
interfaceMsg[a++] = "Images";
regexpList[b++] = "^Image:";
interfaceMsg[a++] = "Modèles";
regexpList[b++] = "^Modèle:";
interfaceMsg[a++] = "Aide";
regexpList[b++] = "^Aide:";
interfaceMsg[a++] = "Catégories";
regexpList[b++] = "^Catégorie:";
interfaceMsg[a++] = "Portails";
regexpList[b++] = "^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);
// Fonction pour rajouter un bouton a une toolbar de l'interface
// voir : http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/addLink
function addlilink(tabs, url, name, id, title, key){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
if(id)
{
if(key && title)
{
ta[id] = [key, title];
}
else if(key)
{
ta[id] = [key, ''];
}
else if(title)
{
ta[id] = ['', title];
}
}
// re-render the title and accesskeys from existing code in wikibits.js
if(typeof akeytt !== 'undefined') akeytt();
return li;
}
// Fonction pour rajouter un onglet
// voir : http://en.wikipedia.org/w/index.php?title=Wikipedia:WikiProject_User_scripts/Scripts/Add_tab&action=edit
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
return addlilink(tabs, url, name, id, title, key)
};
//Fonction de rajout d'un onglet derniere differences sur cet article et toutes les differences depuis ma derniere edition
// addLastDiff
// Voir : http://en.wikipedia.org/w/index.php?title=User:JesseW/monobook.js&oldid=20755510
function addModifDiffOnglet() {
//var l=addTab("http://fr.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'der', '');
//l.lastChild.title="Show most recent diff";
if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
do_since_I_last_edited()
}
else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) {
var thetitle=document.title.slice(0, String(document.title).indexOf(" - "));
//var l=addlilink(tabs, "/w/index.php?title="+thetitle+"&action=history&gotosince=true", '/moi', '');
//l.lastChild.title="Changes since I last edited";
}
var tabs = document.getElementById("p-cactions")
if (tabs)
{
var tabs2 = tabs.getElementsByTagName("ul");
if(tabs2.length > 0)
{
tabs2[0].innerHTML = tabs2[0].innerHTML
+'<li id="ca-modif"><font style="color: blue; padding-left: 0em"><a href="http://fr.wikipedia.org/w/index.php?title=' + thetitle + '&diff=cur&oldid=prev">'
+ 'diff</a></font>'
+ '<a href="http://fr.wikipedia.org/w/index.php?title=' + thetitle + '&action=history&gotosince=true">'
+ '/moi</a>'
+ '</li>';
}
}
};
function do_since_I_last_edited() {
var csub=document.getElementById("contentSub");
var msg=document.createElement("p");
msg.appendChild(document.createTextNode
("Parsing history... please wait..."));
msg.className="error";
csub.insertBefore(msg, csub.firstChild)
var username=document.getElementById("pt-userpage").textContent;
var hists=document.getElementById("pagehistory").getElementsByTagName('li');
for (n=0;n<hists.length;n++) {
if (hists[n].getElementsByTagName("span")[0].getElementsByTagName('a')[0].textContent==username) {
document.location=hists[n].childNodes[1].href;
return;
}
}
msg.replaceChild(document.createTextNode
("You have not edited this page! (recently)"),
msg.firstChild);
}
$(addModifDiffOnglet);
//Rajoute sur une page utilisateur plusieurs onglets : edit count, page déplacé, contribs, et block logs
// voir : http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/User_tabs
function addOnglets() {
if (document.title.indexOf("Utilisateur:") == 0 || document.title.indexOf("Discussion Utilisateur:") == 0) {
if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history
return;
}
username_a = document.URL.match(/:.*:(.*)/);
username=username_a[1];
var a = document.getElementById("p-cactions");
if (a)
{
b = a.getElementsByTagName("ul");
if(b.length > 0)
{
b[0].innerHTML = b[0].innerHTML
+ '<li id="ca-user-info"><font style="color: blue; font-weight: bold; padding-left: 0em"><a href="http://fr.wikipedia.org/wiki/Special:Contributions/' + username + '">contrib</a></font>'
+ '<a href="http://fr.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=' + username + '">'
+ 'movs</a>'
+ '<a href="http://fr.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=' + username + '">'
+ 'logs</a>'
+ '<a href="http://wikiscan.org/?menu=userstats&user=' + username + '">'
+ 'editC</a>'
+ '</li>';
}
}
}
};
$(addOnglets);
// adds a 'logs for this page' link to the navigation bar
// if the page is a user's page, talk page or subpage, the link will go to logs for the user instead
// if the page is a special page, then no link is displayed
// voir : http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Logs_link
function addLogsLink() {
// get page title
var pagetitleRe=/[^:]*:\/\/fr\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?#]*)/;
ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' ');
// if this is a user, show the logs for the user rather than the page
if( (window.location.href.indexOf("Utilisateur:") != -1) || (window.location.href.indexOf("Discussion_Utilisateur:") != -1) ) {
regDropSubpages = /[User|User_talk]:([^&?\/]*)[\/]?.*/;
user = regDropSubpages.exec(ptitle)[1];
url = "http://fr.wikipedia.org/w/index.php?title=Special%3ALog&user=" + user;
} else if(window.location.href.indexOf("Special:") != -1) {
// don't display link for special pages
return;
} else {
url = "http://fr.wikipedia.org/w/index.php?title=Special%3ALog&page=" + ptitle;
}
tabsE = document.getElementById("p-tb").getElementsByTagName('ul')[0];
l = addlilink(tabsE, url, "Logs", "pt-logs");
};
if (window.addEventListener) window.addEventListener("load", addLogsLink, false);
else if (window.attachEvent) window.attachEvent("onload", addLogsLink);