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

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

Version vom 15.08.2016. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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.2
// @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(()=>{
    $('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');
  }, 200);
  var related = $('#tabMorefromthisuser > ul > li > article > a');
  var more = $('#mainSection > div > div > div > ul > li > article > a');
  var inlineVids = function(opt) {
    if (opt.length > 0) {
      opt.each(function(i, el) {
        $(el).click(function(e) {
          e.preventDefault();
          var vid = $('#mainSection > div > div > section.cntPanel > div.playerWrapper.videoWrapper');
          var pageLeftClone = $('#mainSection > div > div > div').clone();
          vid.empty();
          $('<iframe />').attr({
            'src': $(el).attr('href'),
            'frameborder': '0',
            'width': window.innerWidth / 1.2,
            'height': window.innerHeight
          }).appendTo(vid);
          var iframe = vid.find('iframe');
          iframe.hide();
          iframe.on('load', function() {
            iframe.contents().find('#mainSection > div > div > section.cntPanel > div.playerWrapper.videoWrapper').appendTo(vid);
            pageLeftClone.children().appendTo('#mainSection > div > div > div');
            iframe.contents().find('#mainSection > div > aside > div > div').children().appendTo('#mainSection > div > aside > div > div');
            iframe.remove();
            inlineVids($('#tabMorefromthisuser > ul > li > article > a'));
            inlineVids($('#mainSection > div > div > div > ul > li > article > a'));
            animateThumbnails('#tabMorefromthisuser > ul > li > article > a > div > div > img');
            animateThumbnails('#mainSection > div > div > div > ul > li > article > a > div > div > img');
            cleanVidPage();
          });
        });
      });
    }
    
  };
  //inlineVids(related);
  //inlineVids(more);
});