Xtube Enhancer - Animated Thumbnails, Inline Video Loading, and Sponsor/Premium-Free Videos

Animates thumbnails, inlines video loading, and cleans up sponsored content

Per 15-08-2016. Zie de nieuwste versie.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         Xtube Enhancer - Animated Thumbnails, Inline Video Loading, and Sponsor/Premium-Free Videos
// @description  Animates thumbnails, inlines video loading, and cleans up sponsored content
// @namespace    xtube
// @version      2.4
// @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() {
  _.delay(function(){
    $('div.advertisement').remove();
    $('a.clearfix').remove();
    $('li.pull-right').remove();
    $('h2.h1').remove();
    $('section.overviewPage>div:nth-child(5)').remove();
    $('body > div > div.container > div > div').remove();
  },500);
  var selectors = [
    '#mainSection > section > div.mainContent > ul > li', 
    '#mainSection > section > div > div > ul > li',
    'section.row>div>div>ul>li'
  ];
  // v2 - Remove videos that have similar title and author strings
  for (var i = selectors.length - 1; i >= 0; i--) {
    $(selectors[i]).each(function() {
      try {
        if ($(this).find('article > a:nth-child(1) > h3').text().trim().indexOf($(this).find('article > a.userLink.ellipsis').text().trim().split('by ')[1]) !== -1) {
          $(this).remove();
        } else {
          if ($(this).find('article > a:nth-child(1) > h3').text().trim().indexOf('*****') !== -1) {
            var titleBegin = $(this).find('article > a:nth-child(1) > h3').text().trim().split('*****')[0];
            if (titleBegin === $(this).find('article > a.userLink.ellipsis').text().trim().split('by ')[1].substring(0, titleBegin.length)) {
              $(this).remove();
            }
          }
        }
        if ($(this).find('article > a.userLink.ellipsis').text().includes('xtube_sponsor')) {
          $(this).remove();
        }
        if ($(this).find('article > a > div > span.metaInfo > span').text().includes('Premium')) {
          $(this).remove();
        }
        if ($(this).find('article>a>span>span').text() === 'Premium' || $(this).find('article>a>div>span>span').text() === 'Premium') {
          $(this).remove();
        }
        if ($(this).find('article>dl>dd>a').text() === 'xtube_sponsor') {
          $(this).remove();
        }
        if ($(this).find('article>a>span>span').text() === 'Premium') {
          $(this).remove();
        }
      } catch (e) {}
    });
  }
  $('#mainSection > div > div > section.cntPanel > article.box.contentInfo.hasButtonFooter').insertAfter('#mainSection > div > div > section.cntPanel > div.playerWrapper.videoWrapper');
  var cleanVidPage = function() {
    $('#mainSection > div > aside > div.cntPanel').remove();
    $('#mainSection > div > div > section.cntPanel > div.ujbf8hlZW8DTpdFW4aoF.onderSellamPlayer').remove();
    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();
      }
    });
  };
  cleanVidPage();
  var animateThumbnails = function(selector){
    var content = $(selector);
    if (content.length > 0) {
      try {
        content.each(function(i, el) {
          var setAnimations = function(){
            var clone = $(el).clone();
            clone.insertBefore($(el));
            $(el).hide();
            var animation = [];
            var images;
            var _src = $(this).attr('src');
            var src = _src.split('/');
            var isSearch = _src.indexOf('0011') !== -1;

            if (_.last(src).length <= 6 || isSearch) {
              var imgSrc;
              if (isSearch) {
                images = ['00.jpg', '01.jpg', '02.jpg', '03.jpg', '04.jpg', '05.jpg', '06.jpg', '07.jpg', '08.jpg', '09.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg'];
                imgSrc = _src.split('0011')[0] + '00';
              } else {
                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 src3 = _.without(src, _.last(src));
                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();
            }
          }.bind(this);
          if (selector === '#tabMorefromthisuser > ul > li > article > a > div > div > img') {
            $(el).parent().on('mouseenter', function(e){
              setAnimations();
            }.bind(this));
          } else {
            setAnimations();
          }
        });
      } catch (e) {}
    }
  };

    // Animate thumbnails
  _.delay(function() {
    animateThumbnails('div.mainContent>ul>li>article>a>div>div>img');
    animateThumbnails('[id*="vid_id_"]');
    animateThumbnails('[id*="2_frame"]> a > img');
    animateThumbnails('#tabMorefromthisuser > ul > li > article > a > div > div > img');
    animateThumbnails('#mainSection > div > div > div > ul > li > article > a > div > div > img');
    animateThumbnails('#contentVideos > div > div > ul > li > article > a > div > div.imageWrapper.video > img');
    animateThumbnails('#tabVideos > div > ul > li > article > a > div > div.imageWrapper.video > img');
  }, 2000);
  $('#mainSection > div > aside > div > menu > ul > li:nth-child(2) > a').on('click', function(){
    animateThumbnails('#tabRelatedVideos > ul > li > article > a > div > div > img');
  });
});