Xtube Enhancer - Animated Thumbnails and Removed Sponsored Videos

Animates thumbnails and cleans up sponsored content

Versione datata 10/01/2016. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Xtube Enhancer - Animated Thumbnails and Removed Sponsored Videos
// @description  Animates thumbnails and cleans up sponsored content
// @namespace    xtube
// @version      0.5
// @include      http*://www.xtube.com/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @require      https://cdnjs.cloudflare.com/ajax/libs/lodash-compat/3.10.1/lodash.min.js
// @run-at document-end
// ==/UserScript==
$(document).ready(function(){
    $('div.advertisement').remove();
    $('a.clearfix').remove();
    $('li.pull-right').remove();
    $('h2.h1').remove();
    $('section.overviewPage>div:nth-child(5)').remove();
    // Remove premium content in index.
    $('div.col-xs-24>ul>li').each(function(){
        if ($(this).find('article>a>span>span').text() === 'Premium') {
            $(this).remove();
        }
    });
    // Remove sponsored content in index.
    $('section.overviewPage>div>ul>li').each(function(){
        if ($(this).find('article>dl>dd>a').text() === 'xtube_sponsor') {
            $(this).remove();
        }
    });
    // Remove sponsored content in search results.
    $('section.row>div>div>ul>li').each(function(){
        if ($(this).find('article>dl>dd>a').text() === 'xtube_sponsor') {
            $(this).remove();
        }
    });
    // Remove premium content below query index.
    $('div.mainContent>ul>li').each(function(){
        if ($(this).find('article>a>span>span').text() === 'Premium' || $(this).find('article>a>div>span>span').text() === 'Premium') {
            $(this).remove();
        }
    });
    // Remove sponsored content beside video player.
    var relatedVideos = null;
    $('div#related_videos>div').each(function(){
        relatedVideos = $(this).text().split(' ');
        for (var i = relatedVideos.length - 1; i >= 0; i--) {
          if (relatedVideos[i] === '0:15') {
              $(this).prev().remove();
              $(this).remove();
          }
        }
    });
    // Remove sponsored content below video player.
    $('div#watchPageLeft>div>div').each(function(){
        if ($(this).find('a>span:nth-child(3)').text() === '0:15') {
            $(this).remove();
        }
    });
    // Remove sponsored content in full related videos view.
    $('div.Card-list>article').each(function(){
        if ($(this).find('div>div>div:nth-child(3)').text() === '0:15') {
            $(this).remove();
        }
    });
    // Animate thumbnails
    _.delay(function(){
        var mainContent = $('div.mainContent>ul>li>article>a>div>div>img');
        if (mainContent.length > 0) {
            mainContent.each(function(i, el){
                var clone = $(el).clone();
                clone.insertBefore($(el));
                $(el).hide();
                var animation = [];
                var images = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg'];
                var src = $(this).attr('src').split('/');
                if (_.last(src).length <= 6) {
                    var src3 = _.without(src, _.last(src));
                    var imgSrc = src3.join('/')+'/';
                    for (var z = 0; z < images.length; z++) {
                        animation.push(imgSrc+images[z]);
                    }
                    var n = -1;
                    var animate = function(){
                        clone.attr({src: animation[++n]});
                        if (n === 14) {
                            n = -1;
                        }
                        setTimeout(animate, 500);
                    }.bind(this);
                    animate();
                }
            });
        }
        var relatedVideos = $('#related_videos > div > a > img');
        if (relatedVideos.length > 0) {
            relatedVideos.each(function(i, el){
                var clone = $(el).clone();
                clone.insertBefore($(el));
                $(el).hide();
                var animation = [];
                var images = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg'];
                var src = $(this).attr('src').split('/');
                if (_.last(src).length <= 6) {
                    var src3 = _.without(src, _.last(src));
                    var imgSrc = src3.join('/')+'/';
                    for (var z = 0; z < images.length; z++) {
                        animation.push(imgSrc+images[z]);
                    }
                    var n = -1;
                    var animate = function(){
                        clone.attr({src: animation[++n]});
                        if (n === 14) {
                            n = -1;
                        }
                        setTimeout(animate, 500);
                    }.bind(this);
                    animate();
                }
            });
        }
        var watchPageLeft = $('#watchPageLeft > div > div > a > img');
        if (watchPageLeft.length > 0) {
            watchPageLeft.each(function(i, el){
                var clone = $(el).clone();
                clone.insertBefore($(el));
                $(el).hide();
                var animation = [];
                var images = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg'];
                var src = $(this).attr('src').split('/');
                if (_.last(src).length <= 6) {
                    var src3 = _.without(src, _.last(src));
                    var imgSrc = src3.join('/')+'/';
                    for (var z = 0; z < images.length; z++) {
                        animation.push(imgSrc+images[z]);
                    }
                    var n = -1;
                    var animate = function(){
                        clone.attr({src: animation[++n]});
                        if (n === 14) {
                            n = -1;
                        }
                        setTimeout(animate, 500);
                    }.bind(this);
                    animate();
                }
            });
        }
        var userPage = $('[id*="vid_id_"]');
        if (userPage.length > 0) {
            userPage.each(function(i, el){
                var clone = $(el).clone();
                clone.insertBefore($(el));
                $(el).hide();
                var animation = [];
                var images = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg'];
                var src = $(this).attr('src').split('/');
                if (_.last(src).length <= 6) {
                    var src3 = _.without(src, _.last(src));
                    var imgSrc = src3.join('/')+'/';
                    for (var z = 0; z < images.length; z++) {
                        animation.push(imgSrc+images[z]);
                    }
                    var n = -1;
                    var animate = function(){
                        clone.attr({src: animation[++n]});
                        if (n === 14) {
                            n = -1;
                        }
                        setTimeout(animate, 500);
                    }.bind(this);
                    animate();
                }
            });
        }
        var userFavorites = $('[id*="2_frame"]> a > img');
        if (userFavorites.length > 0) {
            userFavorites.each(function(i, el){
                var clone = $(el).clone();
                clone.insertBefore($(el));
                $(el).hide();
                var animation = [];
                var images = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg'];
                var src = $(this).attr('src').split('/');
                if (_.last(src).length <= 6) {
                    var src3 = _.without(src, _.last(src));
                    var imgSrc = src3.join('/')+'/';
                    for (var z = 0; z < images.length; z++) {
                        animation.push(imgSrc+images[z]);
                    }
                    var n = -1;
                    var animate = function(){
                        clone.attr({src: animation[++n]});
                        if (n === 14) {
                            n = -1;
                        }
                        setTimeout(animate, 500);
                    }.bind(this);
                    animate();
                }
            });
        }
    },4000);
});