Utensa:Nick1915/monobook.js

Da Wikipedia, l'ençiclopedia libara.

Ocio: Daspò ver salvà, podaria esare neçesario snetare ła cache dal propio navegadore web par vedare i canbiamenti.

  • Firefox / Safari: tegner strucà el boton de łe letare grande Shift e schiciare sora Ricarga, o se nò struca Ctrl-F5 o Ctrl-R (⌘-R so Mac)
  • Google Chrome: strucare Ctrl-Shift-R (⌘-Shift-R so on Mac)
  • Internet Explorer / Edge: tegner strucà el boton Ctrl e schiciare so Ajorna, o sinò Ctrl-F5
  • Opera: Va in tel Menu → Inpostasion (Opera → Prefarense so on Mac) e pò in Privacy & sicuresa → Sneta dati del navegadore → Imajini e file in te ła cache.
/* <nowiki> */
function fixformat(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = txt.value
        .replace(/\’/g, "'")
        .replace(/E' /g, "È ")
        .replace(/É /g, "È ")
        .replace(/ pò/g, " po'")
        .replace(/ e'/g, " è")
        .replace(/ é/g, " è")
        .replace(/ nè /g, " né ")
        .replace(/ ne' /g, " né ")
        .replace(/piu'/g, "più")
        .replace(/ quà/g, " qua")
        .replace(/qual'è/g, "qual è")
        .replace(/affinchè/g, "affinché")
        .replace(/affinche'/g, "affinché")
        .replace(/benchè/g, "benché")
        .replace(/benche'/g, "benché")
        .replace(/perchè/g, "perché")
        .replace(/perche'/g, "perché")
        .replace(/poichè/g, "perché")
        .replace(/poiche'/g, "poiché")
        .replace(/ sè /g, " sé ")
        .replace(/<\/?(b|strong)>/gi, "'''")
        .replace(/<\/?(i|em|var)>/gi, "''")
         //.replace(/\{\{([Ss]u[bp])\|([^}]+)\}\}/g, "{{subst:$1|$2}}")
         //.replace(/<\/div +>/gi, "</div>");
    form.wpSummary.value += "";
    form.wpMinoredit.checked = true;
}

function replace(){
    var s = prompt("Search regexp?");
    if(s){
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}

function moveprotect(){
  document.getElementById('wpReasonProtect').value = "Protect from moves only";
  document.getElementById('wpMoveOnly').checked = true;
}

function welcome(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += '{{subst:benve|- ~~~~}}';
    form.wpSummary.value = 'welcome';
    form.wpMinoredit.checked = true;
}

function cancella(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    if(txt.value.lenght < 200) form.wpSummary.value = 'Cancella subito (Contenuto: "' + txt.value + '")';
    txt.value = '{{cancella subito}}\n' + txt.value;
    form.wpSummary.value = 'cancella subito';
    form.wpMinoredit.checked = true;  
}

function aiutare(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{da aiutare mese|motivo=informazioni insufficienti ([[Aiuto:Wikipedia non è un dizionario|WND]])|febbraio 2006}}\n' + txt.value;
    form.wpSummary.value = 'aiutare';
    form.wpMinoredit.checked = true;  
}

function wikificare(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = '{{wik|dicembre 2005}}\n' + txt.value;
    form.wpSummary.value = 'wikificare';
    form.wpMinoredit.checked = true;  
}

function vote_plus(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '+1 - ~~~~';
    form.wpSummary.value = '+1';
    form.wpMinoredit.checked = true;
}

function vote_minus(){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value += '-1 - ~~~~';
    form.wpSummary.value = '-1';
    form.wpMinoredit.checked = true;
}

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    na.accesskey = key;
    var pref = 'alt-';
    if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-';
    if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-';
    if(key && title) na.title = title + ' [' + pref + key + ']';
    else if(title) na.title = title;
    else if(key) na.title = '[' + pref + key + ']';
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);
}

function addPurge(){
    var x = document.getElementById('ca-history');
    if(!x) return;
    if(x.children) x = x.children[0].href;
    else x = x.childNodes[0].href;
    addTab(x.replace(/=history/, "=purge"), 'agg.', 'ca-purge', 'Aggiorna la cache per questa pagina', 'g');
}

function addEditSection0(){
    if(!document.getElementById) return;
    var x = document.getElementById('ca-edit');
    if(!x) return;
    var y = document.createElement('LI');
    y.id = 'ca-edit-0';
    if(x.className == 'selected'){
      if(/&action=edit&section=0$/.test(window.location.href)){
        x.className = 'istalk';
        y.className = 'selected';
      } else {
        x.className = 'selected istalk';
      }
    } else if(x.className == 'selected istalk'){
      if(/&action=edit&section=0$/.test(window.location.href)){
        x.className = 'istalk';
        y.className = 'selected istalk';
      } else {
        y.className = 'istalk';
      }
    } else {
      y.className = x.className;
      x.className = 'istalk';
    }
    var z = document.createElement('A');
    if(x.children){
        z.href = x.children[0].href + '&section=0';
        z.appendChild(document.createTextNode('0'));
        y.appendChild(z);
        document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
    }else{
        z.href = x.childNodes[0].href + '&section=0';
        z.appendChild(document.createTextNode('0'));
        y.appendChild(z);
        document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
    }
    z.title = 'Modifica la sezione zero di questa pagina';
    akeytt();
}

function changeLinks(){
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'Le mie discussioni';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Preferenze';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Osservati speciali';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'Contributi';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Esci';
    if(document.getElementById('ca-talk'))
        document.getElementById('ca-talk').firstChild.innerHTML = 'Discussione';
    if(document.getElementById('ca-edit'))
        document.getElementById('ca-edit').firstChild.innerHTML = 'Modifica';
    if(document.getElementById('ca-nstab-wp'))
        document.getElementById('ca-nstab-wp').firstChild.innerHTML = 'Articolo';
}
function addForceSummary(){
    if(!/&action=edit/.test(window.location.href)) return;
    if(/&section=new/.test(window.location.href)) return;
    if(!document.forms.editform) return;
    document.forms.editform.wpSave.onclick = forceSummary;
}

function forceSummary(){
    var form = document.forms.editform;
    if(!form.wpSummary.value.replace(/^(\/\*.*\*\/)? *(.*) *$/,'$2')){
      var r = prompt('Salvi senza scrivere nulla nel campo oggetto?\nPer inserire un testo scrivi qui sotto:',form.wpSummary.value);
      if(r == null) return false;
      form.wpSummary.value = r;
    }
    return true;
}

function morelinks(){
   if(document.title.indexOf("Modifica di Discussioni utente:") == 0){
        addTab('javascript:replace()', 'Sostituisci');
        addTab('javascript:welcome()', 'Benvenuto');
    }else if(document.title.indexOf("Modifica ") == 0){
        if(document.title.indexOf("Modifica di Wikipedia:Pagine da cancellare/") == 0){
            addTab('javascript:vote_plus()', '+1');
            addTab('javascript:vote_minus()', '-1');
        } else {
            addTab('javascript:replace()', 'Replace');
            addTab('javascript:fixformat()', 'Format');
            //addTab('javascript:cancella()', 'Cancella');
            addTab('javascript:aiutare()', 'Help');
            //addTab('javascript:wikificare()', 'W');
    //}else if(document.title.indexOf("Confirm delete - Delete") == 0){
    //    addTab('javascript:vfddelete()', 'VFD');
    //}else if(document.title.indexOf("Confirm protection - Protect") == 0){
    //    addTab('javascript:moveprotect()', 'MV');
        }    
    }
}

function addToolBoxLinks(){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Speciale:Newpages', 'Pagine nuove', 't-newpages');
    addlilink(tb, '/wiki/Speciale:Shortpages', 'Pagine brevi', 't-shortpages');
//    addlilink(tb, '/wiki/Wikipedia:Ultime_modifiche', 'Ultime modifiche', 'open issues');
}

function strip_namespace(target){
    var colon = target.indexOf(':');
    if(colon != -1){
        var spaces = ['Utente', 'Wikipedia', 'Immagine', 'MediaWiki', 'Template', 'Aiuto', 'Categoria'];
        var ns = target.substring(0, colon);
        if(ns == '' || ns == 'Talk') return target.substring(colon + 1);
        else
            for(var i = 0; i < spaces.length; ++i)
                if(ns == spaces[i] || ns == spaces[i] + '_talk') return target.substring(colon + 1);
    }
    return target;
}


// Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&ip=username" is present.
function do_blockip_stuff(){
    var form = document.getElementById('blockip');
    // focus on Reason field
    form.wpBlockReason.focus();
    var target = getParam('ip');
    if(target == '') return;

    // add "blocklog" tab
    addTab('/wiki/Speciale:Log/block?page=Utente:' + target, 'blocklog', 'ca-blocklog');
}

// Adds "block" and "blocklog" tabs to User: and User talk: pages.
function add_block_tab(){
    var c1 = document.getElementById('column-one');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];

    // use the "edit this page" tab to get already-tidied url
    var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
    // cut everything up to "title=" from the start and everything past "&action=edit" from the end
    editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
    editlk = editlk.substring(editlk.indexOf(':') + 1);
    var slloc = editlk.indexOf('/');
    if(slloc > 0) editlk = editlk.substring(0, slloc);

    // add "block" tab
    addTab('/wiki/Speciale:Blockip?ip=' + editlk, 'block', 'ca-block');

    // add "blocklog" tab
    addTab('/wiki/Speciale:Log/block?page=Utente:' + editlk, 'blocklog', 'ca-blocklog');
}

function blockip()
{
  if(document.title.indexOf('Utente:') == 0 || document.title.indexOf('Discussioni utente:') == 0)
      add_block_tab();
  else if(document.title.indexOf('Block user') == 0) // could stand to be more robust
      do_blockip_stuff();
}

function getParam(name){
    if(location.search){
        for(var x in location.search.substring(1).split('&')){
            var eq = x.indexOf('=');
            if(x.substring(0, eq) == name) return x.substring(eq + 1);
        }
    }
    return '';
}

function myLoadFuncs(){
    addPurge();
    //addEditSection0();
    changeLinks();
    //addForceSummary();
    morelinks();
    addToolBoxLinks();
    //blockip();
}
if (window.addEventListener) window.addEventListener("load",myLoadFuncs,false);
else if (window.attachEvent) window.attachEvent("onload",myLoadFuncs);
else{
    window._old_ABCD_onload = window.onload;
    window.onload = function(){
        window._old_ABCD_onload();
        myLoadFuncs();
    }
}

//--------------------------------------------------------

//Da qui tutto il merito è di [[Utente:Timendum]]. Grazie!

//ToolbarButton
function ToolbarButton() {
  var toolbar = null;
  toolbar = document.getElementById("toolbar");
  if (toolbar == null)
    return;
  
  var today = new Date();
  var anno= today.getYear()+1900;
  var tmp= today.getMonth()+1;
  switch (tmp)
  {
     case 1:
        var mese="gennaio"
        break;
     case 2:
        var mese="febbraio"
        break;
     case 3:
        var mese="marzo"
        break;
     case 4:
        var mese="aprile"
        break;
     case 5:
        var mese="maggio"
        break;
     case 6:
        var mese="giugno"
        break;
     case 7:
        var mese="luglio"
        break;
     case 8:
        var mese="agosto"
        break;
     case 9:
        var mese="settembre"
        break;
     case 10:
        var mese="ottobre"
        break;
     case 11:
        var mese="novembre"
        break;
     case 12:
        var mese="dicembre"
        break;
  }
  
// pulsante DA WIKIFICARE
  tmp = document.createElement("a");
  tmp.id = 'tb-wik';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{wik|'+mese+' '+anno+'}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{wik}}";document.getElementById("wpMinoredit").checked=1;})();';
  var imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/7/71/Wikifichino.gif');
  imag.setAttribute('alt','[Wik]');
  imag.setAttribute('title','{{wikificare}}');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

// pulsante DA AIUTARE
  tmp = document.createElement("a");
  tmp.id = 'tb-aiu';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{da aiutare mese|motivo=[[WND]], informazioni non sufficienti e da contestualizzare "+(prompt("Motivo"))+"|'+mese+' '+anno+'}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{da aiutare}} ";})();';
  imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/2/23/Aiutino.gif');
  imag.setAttribute('alt','[Aiu]');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

// pulsante STUB
  tmp = document.createElement("a");
  tmp.id = 'tb-wik';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{stub}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{stub}}";document.getElementById("wpMinoredit").checked=1;})();';
  var imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/1/11/Stubber.png');
  imag.setAttribute('alt','[Stub]');
  imag.setAttribute('title','{{stub}}');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);
  
// pulsante TEST
    tmp = document.createElement("a");
    tmp.id = 'tb-tes';
    tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Test}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"Avviso test";document.getElementById("wpMinoredit").checked=1;})();';
    imag = document.createElement("img");
    imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/4/40/Wiki_test.GIF');
    imag.setAttribute('alt','[Tes]');
    imag.setAttribute('title','Test');
    tmp.appendChild(imag);
    toolbar.appendChild(tmp);

// pulsante VANDALISMO
tmp = document.createElement("a");
  tmp.id = 'tb-vnd';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Vandalismo}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"Avviso vandalismo";document.getElementById("wpMinoredit").checked=1;})();';
  imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/6/64/Wiki_vand.gif');
  imag.setAttribute('alt','[Vnd]');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);

// pulsante AVVISO CONTROLCOPY
tmp = document.createElement("a");
  tmp.id = 'tb-vnd';
  tmp.href = 'javascript:(function() {wpTextbox1=document.getElementById("wpTextbox1");wpTextbox1.value="{{Controlcopy|firma=~~~|motivo=probabile copia di materiale già pubblicato altrove e dunque non originale}}\\n"+wpTextbox1.value;summ=document.getElementById("wpSummary");summ.value=summ.value+"+{{Controlcopy}}!";document.getElementById("wpMinoredit").checked=1;})();';
  imag = document.createElement("img");
  imag.setAttribute('src','http://upload.wikimedia.org/wikipedia/it/7/75/Wiki_c_copy.gif');
  imag.setAttribute('alt','[Vnd]');
  tmp.appendChild(imag);
  toolbar.appendChild(tmp);
}

addLoadEvent(ToolbarButton);

// WikiSign
var wikisign_pre = '- ~~~~';
var wikisign_post = '';
function WikiSign() {
  arra = document.getElementsByTagName("a");
  for ( i=0; i < arra.length;i++ ) {
    if ( arra[i].getAttribute("href") == "javascript:insertTags('--~~~~','','');" ) {
      arra[i].setAttribute("href", "javascript:insertTags('"+wikisign_pre+"','"+wikisign_post+"','');");
      break;
    }
  }
}
addLoadEvent(WikiSign);

//Add an "invert" button in Undeletion page (source: http://en.wikipedia.org/wiki/User:Cryptic/toggleundelete.js)

function toggle_undelete()
{
  var f = document.getElementById("undelete");
  if (f)
    {
      var inputs = f.getElementsByTagName("input");
      var i;
      for (i = 0; i < inputs.length; ++i)
        if (inputs[i].type == "checkbox")
          inputs[i].checked = !inputs[i].checked;
    }
}

function setup_toggle_undelete()
{
  if (document.title.indexOf("Vedi e recupera pagine cancellate") == 0)
    {
      var f = document.getElementById("undelete");
      if (f)
        {
          var h2 = f.getElementsByTagName("h2")[0];
          if (h2)
            {
              var button = document.createElement('input');
              button.type = "button";
              button.value = "Inverti";
              button.setAttribute('onClick', 'toggle_undelete()');
              f.insertBefore(button, h2);
            }
        }
    }
}

$(setup_toggle_undelete);

/* </nowiki> */

//Add an "invert" button in Undeletion page (source: http://en.wikipedia.org/wiki/User:Cryptic/toggleundelete.js)

function toggle_undelete()
{
  var f = document.getElementById("undelete");
  if (f)
    {
      var inputs = f.getElementsByTagName("input");
      var i;
      for (i = 0; i < inputs.length; ++i)
        if (inputs[i].type == "checkbox")
          inputs[i].checked = !inputs[i].checked;
    }
}

function setup_toggle_undelete()
{
  if (document.title.indexOf("Vedi e recupera pagine cancellate") == 0)
    {
      var f = document.getElementById("undelete");
      if (f)
        {
          var h2 = f.getElementsByTagName("h2")[0];
          if (h2)
            {
              var button = document.createElement('input');
              button.type = "button";
              button.value = "Inverti";
              button.setAttribute('onClick', 'toggle_undelete()');
              f.insertBefore(button, h2);
            }
        }
    }
}

$(setup_toggle_undelete);
Traesto fora da Wikipèdia - L'ençiclopedia łìbara e cołaboradiva in łéngua Vèneta "https://vec.wikipedia.org/w/index.php?title=Utensa:Nick1915/monobook.js&oldid=962671"