Prime Video Ad Blocker [ESP]

Skip Ads and self Promotionals in Prime Video.

ही स्क्रिप्ट इंस्टॉल करा?
लेखकाने सुचवलेली स्क्रिप्ट

तुम्हाला कदाचित ही स्क्रिप्टदेखील आवडेल: Prime Video Sólo Contenido Prime [ESP].

ही स्क्रिप्ट इंस्टॉल करा
  1. // ==UserScript==
  2. // @name Prime Video Ad Blocker [ESP]
  3. // @name:es Prime Video Ad Blocker [ESP]
  4. // @namespace https://greatest.deepsurf.us/en/users/5102-jeau
  5. // @version 0.3.1
  6. // @description Skip Ads and self Promotionals in Prime Video.
  7. // @description:es Bloquea los anuncios y promociones en Prime Video.
  8. // @author Jeau
  9. // @license MIT
  10. // @match https://*.amazon.co.jp/Amazon-Video/*
  11. // @match https://*.amazon.co.uk/Amazon-Video/*
  12. // @match https://*.amazon.com/Amazon-Video/*
  13. // @match https://*.amazon.de/Amazon-Video/*
  14. // @match https://*.amazon.com/*instant-video*
  15. // @match https://*.primevideo.com/*
  16. // @icon https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/favicon-32x32.png
  17. // @grant none
  18. // ==/UserScript==
  19.  
  20. /*
  21. -----------------------------------------------------------------------------------
  22. Adapted for Amazon Prime Video Spain site. It might also work on other countries.
  23. Based on RawMeatEater's script:
  24. https://greatest.deepsurf.us/es/scripts/446723-amazon-video-ad-blocker
  25. -----------------------------------------------------------------------------------
  26. */
  27.  
  28. (function() {
  29. 'use strict';
  30. // This value when true shows that the Ad has been skipped
  31. var adSkipped = false;
  32. // Time pattern
  33. var adTimeRegExp = /(\d?\d:){0,2}\d?\d/;
  34.  
  35. setInterval(function() {
  36. var video;
  37. var adTime;
  38. // In case of multiple video elements look for the one which is currently playing
  39. var renderers = document.getElementsByClassName("rendererContainer");
  40. if (renderers.length) {
  41. for (let i = renderers.length - 1; i >= 0; i--) {
  42. video = renderers[i].querySelector('video');
  43. if (video && video.currentTime) break;
  44. }
  45. }
  46. var promoTimeElement = document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0];
  47. var adTimeElement = document.getElementsByClassName("atvwebplayersdk-ad-timer-remaining-time")[0];
  48. // When detected stores the ad time in adTime
  49. if (adTimeElement && adTimeRegExp.test(adTimeElement.innerHTML)) adTime = adTimeElement;
  50. if (promoTimeElement && adTimeRegExp.test(promoTimeElement.innerHTML)) adTime = promoTimeElement;
  51. // If video started playing and a 'Time to Skip' element is detected
  52. if (video && video.currentTime && adTime) {
  53. // Has it been skipped aready? (To be sure that you don't skip forward twice)
  54. if (adSkipped == false) {
  55. // Grab the Ad timer in HH:MM:SS format and split it into an array as soon as it is detected
  56. var currentAdTime = adTime.innerHTML.match(adTimeRegExp)[0].split(':');
  57. // Calculate the Ad time in seconds
  58. var adTimeInSecs = 0;
  59. for (let i = 0; i < currentAdTime.length; i++) {
  60. adTimeInSecs += parseInt(currentAdTime[i]) * Math.pow(60, currentAdTime.length - 1 - i);
  61. }
  62. // Forward the video by how much Ad time the timer shows
  63. video.currentTime += adTimeInSecs;
  64. // Mark the Ad as skipped
  65. adSkipped = true;
  66. // DEBUG
  67. console.log('=====================');
  68. console.log('.');
  69. console.log('PRIME VIDEO AD SKIPPED !!!');
  70. console.log('.');
  71. console.log('=====================');
  72. }
  73. } else {
  74. // When Ad timer disappers, reset the Ad skip value
  75. adSkipped = false;
  76. }
  77. }, 200);
  78. })();