Add link protector automatically to server links

1

Hello, I would like to know how I can use JavaScript or PHP to put this url http://anunciad.com.br?AuID=16958&Aurl= before the addresses of download servers automatically I use these servers SkyDrive, Clouddrive, Pcloud, Bitcasa, Meocloud, LolaBits, Google, Clouddriver I used Adfly it has a script in JavaScript that automatically adds the address at the beginning of these URLs to the address of the protector. With all this new protector they do not have this kind of scripts.

    
asked by anonymous 15.07.2015 / 02:44

2 answers

3

JavaScript native as follows:

var links = document.getElementsByTagName("a");

for (i = 0; i < links.length; i++) {
    var link = links[i];
    var urlProtegida = "http://anunciad.com.br?AuID=16958&Aurl=" + link.href;

    link.href = urlProtegida;
}

Or with jQuery :

$("a").each(function() {
    var urlProtegida = "http://anunciad.com.br?AuID=16958&Aurl=" + $(this).attr("href");

    $(this).attr("href", urlProtegida);
});

With jQuery you can make a filter to only change links whose URL contains the domain of any of the servers mentioned in your question.

// Lista de bases de URLs dos servidores.
var urlsBases = ["meocloud.pt", "mega.co.nz", "outro.servidor.com"];

for (var i = 0; i < urlsBases.length; i++) {
    var serverUrlBase = urlsBases[i];

    // OBS: é necessário colocar entre aspas simples a url no filtro do jQuery por atributo.
    $("a[href*='" + serverUrlBase + "']").each(function() {
        var urlProtegida = "http://anunciad.com.br?AuID=16958&Aurl=" + $(this).attr("href");

        $(this).attr("href", urlProtegida);
    });
}
    
15.07.2015 / 14:30
-1

Try this:

$urlBase = 'http://anunciad.com.br?AuID=16958&Aurl=';

$urlTotal = $urlBase . 'www.skydrive.com/arquivo1.mp3';
    
15.07.2015 / 13:30