thewatchseries.to Random Episodes Button

Generate new random episode every time you press random episode without refresh the page!

  1. // ==UserScript==
  2. // @name thewatchseries.to Random Episodes Button
  3. // @namespace RandomEpisodesButton
  4. // @version 0.2
  5. // @description Generate new random episode every time you press random episode without refresh the page!
  6. // @author jscriptjunkie
  7. // @match http://thewatchseries.to/*
  8. // @grant none
  9. // ==/UserScript==
  10. /* jshint -W097 */
  11. 'use strict';
  12.  
  13. $('body > div.centeres > div.home-page > div.home-page-left > div:nth-child(1) > div:nth-child(2)').remove();
  14. $('body > div.centeres > div.home-page > div.home-page-left > div:nth-child(6) > div:nth-child(2)').remove();
  15. $('.random_inside a').attr('href','#');
  16. $('.random_inside').click(function () {
  17. var website = 'http://thewatchseries.to';
  18. var obj = $(this).parent().next();
  19. var numberOfEpisonds = obj.children().length;
  20. var rnd = 1 + Math.floor(Math.random() * numberOfEpisonds);
  21. var episodeLink = website + obj.find('li:nth-child('+rnd+') a').attr('href');
  22. window.open(episodeLink, '_blank');
  23. });
  24.  
  25. var episodes = [];
  26. $('ul.listings li > a').each(function( index ) {
  27. episodes.push('http://thewatchseries.to' + $( this ).attr('href'));
  28. });
  29.  
  30. var r= $('<center><input type="button" id="randFromAll" value="Random Episode" style="font-size: 15px; line-height: 26px; border-bottom: 1px solid #59789E; background-color: #59789E; color: #ffffff"/></center>');
  31. $(".latest-episode").append(r);
  32.  
  33. $('#randFromAll').click(function () {
  34. var rnd = 1 + Math.floor(Math.random() * episodes.length);
  35. window.open(episodes[rnd], '_blank');
  36. });