Prime Video Ad Blocker [ESP]

Skip Ads in Prime Video.

当前为 2023-01-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Prime Video Ad Blocker [ESP]
  3. // @namespace https://greasyfork.org/en/users/5102-jeau
  4. // @version 0.2.5.1
  5. // @description Skip Ads in Prime Video.
  6. // @description:es Bloquea los anuncios en Prime Video.
  7. // @author Jeau
  8. // @license MIT
  9. // @match https://*.amazon.co.jp/Amazon-Video/*
  10. // @match https://*.amazon.co.uk/Amazon-Video/*
  11. // @match https://*.amazon.com/Amazon-Video/*
  12. // @match https://*.amazon.de/Amazon-Video/*
  13. // @match https://*.primevideo.com/*
  14. // @icon https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/favicon-32x32.png
  15. // @grant none
  16. // ==/UserScript==
  17.  
  18. /*
  19. -----------------------------------------------------------------------------------
  20. Adapted for spanish Amazon site. It might also work on other countries.
  21. Based on RawMeatEater's script:
  22. https://greasyfork.org/es/scripts/446723-amazon-video-ad-blocker
  23. -----------------------------------------------------------------------------------
  24. */
  25.  
  26. (function() {
  27. 'use strict';
  28. // This value when true shows that the Ad has been skipped
  29. var adSkipped = false;
  30. setInterval(function() {
  31. var video;
  32. var renderer = document.getElementsByClassName("rendererContainer")[0];
  33. if (renderer) {
  34. video = renderer.querySelector('video');
  35. }
  36. var adTimeElement = document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0];
  37. // If video started playing and a 'Time to Skip' element is detected
  38. if (video && video.currentTime && adTimeElement) {
  39. var adTimeRegExp = /(\d?\d:){0,2}\d?\d/;
  40. // Has it been skipped aready? (To be sure that you don't skip forward twice)
  41. if (adSkipped == false && adTimeRegExp.test(adTimeElement.innerHTML)) {
  42. // Grab the Ad timer in HH:MM:SS format and split it into an array as soon as it is detected
  43. var currentAdTime = adTimeElement.innerHTML.match(adTimeRegExp)[0].split(':');
  44. // Calculate the Ad time in seconds
  45. var adTimeInSecs = 0;
  46. for (let i = 0; i < currentAdTime.length; i++) {
  47. adTimeInSecs += parseInt(currentAdTime[i]) * Math.pow(60, currentAdTime.length - 1 - i);
  48. }
  49. // Forward the video by how much Ad time the timer shows
  50. video.currentTime += adTimeInSecs;
  51. // Mark the Ad as skipped
  52. adSkipped = true;
  53. }
  54. } else {
  55. // When Ad timer disappers, reset the Ad skip value
  56. adSkipped = false;
  57. }
  58. }, 200);
  59. })();