Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Prime Video Next
  3. // @version 0.1.2
  4. // @description Instantly plays the next episode. This script skips the wait time on auto-play and circumvents the "auto pause" that checks if you're still watching.
  5. // @author Luxocracy
  6. // @grant none
  7. // @match https://www.primevideo.com/*
  8. // ==/UserScript==
  9. (function() {
  10. /*jshint multistr: true */
  11. 'use strict';
  12. var primeTimeout;
  13. var primeSetTimeout = function(waitTime) {
  14. var playnext = document.querySelector('.nextUpCard');
  15. primeTimeout = setTimeout(function() {
  16. if(!document.querySelector('.pausedOverlay .playIcon')) playnext.click(); // If not paused, play next episode
  17. }, waitTime);
  18. };
  19. var getTimeStamp = function(timestamp) {
  20. return 0;
  21. var split = timestamp.split(':');
  22. var minutes = parseInt(split[0]) * 60;
  23. var seconds = parseInt(split[1]);
  24. return (minutes + seconds) * 1000; // Returns timestamp in milliseconds
  25. };
  26.  
  27. var observer = new MutationObserver(function(mutations) {
  28. mutations.forEach(function(mutation) {
  29. if(mutation.addedNodes.length > 0 && mutation.addedNodes[0].className && mutation.addedNodes[0].className.toString().match(/nextUp/)) {
  30. var waitTime = getTimeStamp(document.querySelector('.infoBar .timeRemaining').lastChild.data) - 1500;
  31. primeSetTimeout(waitTime);
  32. }
  33. });
  34. });
  35.  
  36. observer.observe(document.querySelector('body'), { childList: true, subtree: true });
  37. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement