User:Alex brollo/imgAreaSelect.js

From Wikisource
Jump to navigation Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

//<source lang="javascript">
// ==UserScript==
// @ShortcutManager
// @name filtro tabella irc
// @namespace lRVtKVeCdYJq
// @key Alt+f
// @include http://tools.wmflabs.org/*
// ==/UserScript==
function filtra() {var comando=prompt("Condizione di filtro (campo contiene testo):"); comando=comando.split(" contiene "); test(comando[0],comando[1]);}

function test(campo, testo) {$("tbody tr").css("display","none");$("td."+campo+":contains('"+testo+"')").parent().css("display","table-row");}

filtra()

// ==UserScript==
// @ShortcutManager
// @name Shortcut for empty pages
// @namespace h1Hv6IfIxhvW
// @key Alt+0
// @include *wikisource.org/w/*
// ==/UserScript==
/*scriviBox("{{RigaIntestazione|||}}","0");
scriviBox("");
$("input[type=radio][value=0]").click();
$("#wpSave").click();*/

scriviBox("{{Iwpage|it}}");
$("input[type=radio][value=0]").click();
$("#wpSave").click();




// ==UserScript==
// @ShortcutManager
// @name Saves SAL 75% after acrepl()
// @namespace h1Hv6IfIxhvW
// @key Alt+3
// @include *wikisource.org/w/*
// ==/UserScript==
x=leggiBox();
x=x.replace(/\ ([;,:?])/g,"$1");
newRi();
$("input[type=radio][value=3]").click();




// ==UserScript==
// @ShortcutManager
// @name Saves page with a SAL 50%
// @namespace h1Hv6IfIxhvW
// @key Alt+2
// @include *wikisource.org/w/*
// ==/UserScript==
$("input[type=radio][value=2]").click();
$("#wpSave").click();





// ==UserScript==
// @ShortcutManager
// @name Corregge la J in ? nella selezione
// @namespace h1Hv6IfIxhvW
// @key Ctrl+Alt+j
// @include *it.wikisource.org/w/*
// ==/UserScript==
theta();





// ==UserScript==
// @ShortcutManager
// @name deep postOCR
// @namespace h1Hv6IfIxhvW
// @key Alt+6
// @include *wikisource.org/w/*
// ==/UserScript==
x=leggiBox(); 
x=x.replace(/\ ([;,:?”])/g,"$1").replace(/“ /g,"“").replace(/ \n/g,"\n");
scriviBox(x);

// ==UserScript==
// @ShortcutManager
// @name replace common mistakes saved in cor
// @namespace h1Hv6IfIxhvW
// @key Alt+1
// @include *it.wikisource.org/w/*
// ==/UserScript==
for (i in cor) {regexRepl(i,cor[i]);}






// ==UserScript==
// @ShortcutManager
// @name Edit page key
// @namespace h1Hv6IfIxhvW
// @key Alt+c
// @include *it.wikisource.org/wiki/*
// ==/UserScript==
window.location=$("#ca-edit a").attr("href");



// ==UserScript==
// @ShortcutManager
// @name Salva con sal 4
// @namespace h1Hv6IfIxhvW
// @key Alt+4
// @include *wikisource.org/w/*
// ==/UserScript==
Virgolette();
$("input[type=radio][value=4]").click();
$("#wpSave").click();


// ==UserScript==
// @ShortcutManager
// @name Applica annotazione a lato su un testo selezionato
// @namespace h1Hv6IfIxhvW
// @key Alt+8
// @include */w/*
// ==/UserScript==
t=selection();
t[1]=t[1].split("\n");
for (i=0;i<t[1].length;i+=1) {
   t[1][i]=$.trim(t[1][i]);
   if (t[1][i].length>1) {
      t[1][i]="{{Annotazione a lato|"+t[1][i]+"}}";
      }
   }
t[1]=t[1].join("\n");
scriviBox(t.join(""));



// ==UserScript==
// @ShortcutManager
// @name Aggiunge un tl|Var
// @namespace h1Hv6IfIxhvW
// @key Alt+7
// @include */w/*
// ==/UserScript==
t=selection();
t[1]="{{Var|"+t[1]+"|"+t[1]+"}}";
scriviBox(t.join(""));



// ==UserScript==
// @ShortcutManager
// @name Premi Salva dopo Enter in spanForm
// @namespace h1Hv6IfIxhvW
// @key Alt+Enter
// @include */w/*
// ==/UserScript==
if (document.activeElement.id=="spanForm") $("#spanForm").next().click();



// ==UserScript==
// @ShortcutManager
// @name view OCR from Talk page
// @namespace h1Hv6IfIxhvW
// @key Alt+o
// @include *it.wikisource.org/w/*
// ==/UserScript==
var ocr=$.ajax({url:"http://it.wikisource.org/w/index.php?action=raw&title=Discussioni pagina:"+wgTitle,async:false}).responseText;
$("#showboxContent")
   .css("overflow","auto")
   .css("height","130px")
   .css("position","absolute")
   .css("width","100%")
   .append(ocr);

$("#showbox").css("height","150px").css("display","block");

testoOld=find_stringa(leggiBox(),"<poem>","</poem>",0);
testo=testoOld.split("\n");
for (i=0; i<testo.length;i+=1) {testo[i]=testo[i].substring(0,1).toLocaleUpperCase()+testo[i].substring(1);}
testo=testo.join("\n");
scriviBox(leggiBox().replace(testoOld,testo)
    .replace(/«/g,"“")
    .replace(/»/g,"„")
    .replace(/í/g,"ì")
    .replace("<!--fine-->",""));
if (testo.indexOf("{{Centrato")==-1)  {testo=testo.replace("<poem>","{{Centrato|"+$("#ca-ns0_0 a").attr("title").replace("Pagina transclusa in Sonetti romaneschi/I/","").toLocaleUpperCase()+"}}\n\n<poem>");}




// ==UserScript==
// @ShortcutManager
// @name attiva intoolbar (preliminare)
// @namespace h1Hv6IfIxhvW
// @key Alt+Shift+9
// @include */w/*
// ==/UserScript==
scegliCarattere=function (span){sel=selection();sel[1]=$(span).text();scriviBox(sel.join(""));$("#intoolbar").remove();}

h='<div id="intoolbar" style="position:fixed;top:0; left:0; border:2px solid red; z-index:2000; background-color:white;" ondoubleclick="$(this).remove()"><p></p></div>'
$(h).appendTo($("#content"));

variants={"a":"aÁÂÀÄÃAÅÆáàâäãaåæ","o":"oÓÒÔÖŒØóò?ôöõœø","e":"eÉÈèÊêËë??EeE´e´EeEe","i":"iÍíÌìÎîÏïIiIiI´i´Ii","u":"uÚúÙùÛûÜüUuUuUuUuUuU´u´","a":"a????????????????????????????????"};
t=variants[selection()[1]].split("");
tt="";for(i=0;i<t.length;i+=1){tt+="<span>"+t[i]+"</span> ";}
$("#intoolbar p").append($(tt));
$("#intoolbar span").attr("onclick","scegliCarattere(this)");



// ==UserScript==
// @ShortcutManager
// @name converte una vocale selezionata in vocale+~ dentro tl|Var
// @namespace h1Hv6IfIxhvW
// @key Alt+9
// @include *wikisource.org/w/*
// ==/UserScript==
sel=selection(); 
selc=sel[1];
switch(selc) {
case "a":
  sel[1]="{{Var|ã|an}}";
  break;
case "u":
  sel[1]="{{Var|u|un}}";
  break;
case "o":
  sel[1]="{{Var|õ|on}}";
  break;
case "e":
  sel[1]="{{Var|?|en}}";
  break;
case "i":
  sel[1]="{{Var|i|in}}";
  break;
}
scriviBox(sel.join(""));


// ==UserScript==
// @ShortcutManager
// @name inserisce il template RigaIndice/Belli sul testo grezzo
// @namespace h1Hv6IfIxhvW
// @key Alt+b
// @include */w/*
// ==/UserScript==
var t=leggiBox();
t=t.replace("Pag.","„");
t=t.replace(/(\d+\.) +([^„\n]+) +(„) +(\d+)/g,"{{RigaIndice/Belli|$1|$2|$3|$4|312}}").replace(/\<poem\>/g,"").replace(/\<\/poem\>/g,"");
t=t.replace("„","{{Pt|Pag.|„}}");
scriviBox(t);
scriviBox(leggiBox(0)+'\n<table width="100%" cellspacing="0">',0);

// ==UserScript==
// @ShortcutManager
// @name newSections
// @namespace uA6OOWZEmzLQ
// @key Ctrl+Shift+s
// @include *it.wikisource.org/w/*
// ==/UserScript==
function newSections() {
    var s=sel();
    if (s[1][2].indexOf("<section end=s2 />")==-1) {
        s[1][0]="<section begin=s1 />"+s[1][0]+"<section end=s1 />";
        s[1][2]="<section begin=s2 />"+s[1][2]+"<section end=s2 />"; 
    }
    else {
        s[1][0]=s[1][0]+"<section end=s2 />";
        s[1][2]="<section begin=s3 />"+s[1][2].replace("<section end=s2 />","<section end=s3 />");    
    }
    s[0].value=s[1][0]+s[1][1]+s[1][2];
    return;
}

newSections();

// ==UserScript==
// @ShortcutManager
// @name Aggiunta campi form Ultime Modifiche
// @namespace lRVtKVeCdYJq
// @key 
// @include *Speciale:UltimeModifiche*
// ==/UserScript==
$('<label for "field1Name">Filtra per campo. Nome: </label><input name="field1Name" size="15" value="" class="field1-name-input"><label for "field1Content">Valore: </label> <input name="field1Content" size="30" value="" class="field1-content-input">').insertAfter($(".mw-tagfilter-input"));

// ==UserScript==
// @ShortcutManager
// @name Shots filter
// @namespace lRVtKVeCdYJq
// @key Alt+5
// @include *Speciale:UltimeModifiche*
// ==/UserScript==
var campo="";
switch($('.field1-name-input').val())
{
case "utente":
  campo="mw-userlink";break;
case "pagina":
  campo="mw-changeslist-title";break;
default:
  campo="errore";console.log("Errore");
}
$(".mw-line-even,.mw-line-odd").css("display","none");
$("."+campo+":contains('"+$('.field1-content-input').val()+"')").parents("li").css("display","block");

// ==UserScript==
// @ShortcutManager
// @name Applica tl|Pg a tutti i numeri di pagina
// @namespace lRVtKVeCdYJq
// @key Ctrl+Alt+l
// @include */w/*
// ==/UserScript==
t=leggiBox();t=t.replace(/,/g,", ").replace(/d\./g,"di").replace(/  /," ").replace(/. V/g, ".\n\nV");
t=t.replace(/5(\d\d)/g,"3$1").replace(/Trenlo/g, "Trento");
t=t.replace(/ (\d+)/g," {{Pg|$1}}");
scriviBox(t);

// ==UserScript==
// @ShortcutManager
// @name edit next page
// @namespace lRVtKVeCdYJq
// @key 
// @include *it.wikisource.org/wiki/Pagina:*
// ==/UserScript==
a=$('<div style="position:fixed; z-index:2000; top:50px; right:700px"><a title="Edita la pagina seguente"><img src="//upload.wikimedia.org/wikipedia/commons/c/c7/RightGold.gif"></a></div>');
$("a",a).attr("href","/w/index.php?title="+escape(wgPageName.match(/(Pagina:[^/]+\/)/)[1])+(wgTitle.match(/\/(\d+)/)[1]*1+1)+"&action=edit");
$(a).appendTo($("body"));

// ==UserScript==
// @ShortcutManager
// @name Adds an empty span with an id pagename+djvupagenumber
// @namespace lRVtKVeCdYJq
// @key Alt+o
// @include *en.wikisource.org/w/*
// ==/UserScript==
scriviBox('<span id="pagename'+wgPageName.match(/\/(\d+)/)[1]+'"></span>'+leggiBox());

// ==UserScript==
// @ShortcutManager
// @name adds a left margin template to selection
// @namespace lRVtKVeCdYJq
// @key Alt+Shift+7
// @include *en.wikisource.org/w/*
// ==/UserScript==
t=selection();t[1]="{{left margin|2em}}"+t[1]+"</div>"; scriviBox(t.join(""));

// ==UserScript==
// @ShortcutManager
// @name New ri+ delete " characters ath rth row beginning
// @namespace lRVtKVeCdYJq
// @key Alt+Shift+1
// @include *en.wikisource.org/w/*
// ==/UserScript==
t=leggiBox();
t=t.replace(/\n["'] /g," ");
scriviBox(t);
newRi();

// ==UserScript==
// @ShortcutManager
// @name aggiunge un DRM-i
// @namespace lRVtKVeCdYJq
// @key Alt+F1
// @include *en.wikisource.org/w/*
// ==/UserScript==
t=selection();
testo=t[1].split("\n");
for (i=0;i<testo.length;i+=1) {
testo[i]=testo[i].replace(/(\d+)/g,"{{Pag|$1}}");
if (testo[i].indexOf("|{{")==-1){
   if (testo[i].indexOf("{{")!=-1) {
       
        testo[i]=testo[i].replace("{{","|{{");
        }
   } 
   testo[i]="{{DRM-i|"+testo[i]+"|}}";
}
t[1]=testo.join("\n");
scriviBox(t.join(""));

// ==UserScript==
// @ShortcutManager
// @name deletes training virgolette
// @namespace lRVtKVeCdYJq
// @key Alt+F2
// @include *
// ==/UserScript==
scriviBox(leggiBox().replace(/\n["'] /g," "));

// ==UserScript==
// @ShortcutManager
// @name rende draggabile il box caratteri speciali; aggiunge ger()
// @namespace lRVtKVeCdYJq
// @key 
// @include *la.wikisource.org/w/*
// ==/UserScript==
function ger() {
   t=leggiBox().split("\n");
   
       for (i=0;i<t.length;i+=1) {
	   if (/, /.test(t[i])==true) {
            t[i]=t[i].replace(/, (.+)/,", ''$1''");
       } 
   }
   scriviBox(t.join("\n")); 
}

$(document).ready($("#specialchars-wrapper").resizable().draggable(););

// ==UserScript==
// @ShortcutManager
// @name Converte c,s,z in lettere dolci
// @namespace lRVtKVeCdYJq
// @key Alt+9
// @include */wikisource.org/w/*
// ==/UserScript==
t=selection();
t[1]=t[1]
 .replace("s","š")
 .replace("z","ž")
 .replace("c","c")
 .replace("S","Š")
 .replace("Z","Ž")
 .replace("C","C");
  scriviBox(t.join(""));


// ==UserScript==
// @ShortcutManager
// @name Quotes replacing
// @namespace 7qDw2j91JGcP
// @key Ctrl+Alt+v
// @include *wikisource*
// ==/UserScript==
t=selection();
if (t[1]=="") /*no selection*/ {
    testo=leggiBox();
	if (testo.indexOf('"')>-1) {
        testo=testo.replace(/[“”]/g,'"');
        n=1;
        while (testo.indexOf('"')>-1) {
              if (n%2==1) {testo=testo.replace('"','”');}
              else {testo=testo.replace('"','“');}
              n+=1;
        }      
   }
   testo=testo.replace(/“/g,"#opv#").replace(/”/g,"“").replace(/#opv#/g,"”");
   scriviBox(testo);
}
else {
   t[1]=t[1].replace(/\"/g,'');
   t[1]="“"+$.trim(t[1])+"”";
   scriviBox(t.join(""));
}

// ==UserScript==
// @ShortcutManager
// @name test
// @namespace lRVtKVeCdYJq
// @key 
// @include *en.wikisource.org*
// ==/UserScript==
//</source>