Prime Video Ad Blocker [ESP]

Skip Ads in Prime Video Spain. Adapted from RawMeatEater's script for spanish Amazon site.

当前为 2022-08-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Prime Video Ad Blocker [ESP]
  3. // @namespace https://greasyfork.org/en/users/5102-jeau
  4. // @version 0.1.7
  5. // @description Skip Ads in Prime Video Spain. Adapted from RawMeatEater's script for spanish Amazon site.
  6. // @description:es Bloquea los anuncios en Prime Video España. Adaptado a partir del código de RawMeatEater para la web de Amazon España.
  7. // @author Jeau
  8. // @license MIT
  9. // @match https://www.primevideo.com/*
  10. // @icon https://m.media-amazon.com/images/G/01/digital/video/DVUI/favicons/favicon-32x32.png
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. // This value when true shows that the Ad has been skipped
  17. var adSkipped = false;
  18. // Every 0.2 seconds this function runs
  19. setInterval(function() {
  20. var video;
  21. var renderer = document.getElementsByClassName("rendererContainer")[0];
  22. // Get the video element
  23. if (renderer && renderer.querySelector('video')) {
  24. video = renderer.querySelector('video');
  25. }
  26. // If video started playing and a 'Time to Skip Ad' is detected
  27. if (video && video.currentTime && document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0]) {
  28. // Has it been skipped aready? (To be sure that you don't skip forward twice)
  29. if ( adSkipped == false ) {
  30. // Grab the Ad timer in HH:MM:SS format and split it into an array
  31. var currentAdTime = document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0].innerHTML.split(':');
  32. // Calculate the Ad time in seconds
  33. var adTimeInSecs = 0;
  34. for (let i = 0; i < currentAdTime.length; i++) {
  35. adTimeInSecs += parseInt(currentAdTime[i]) * Math.pow(60, currentAdTime.length - 1 - i);
  36. }
  37. // Forward the video by how much Ad time the timer shows
  38. video.currentTime += adTimeInSecs;
  39. // Mark the Ad as skipped
  40. adSkipped = true;
  41. }
  42. } else {
  43. // When Ad timer disappers, reset the Ad skip value
  44. adSkipped = false;
  45. }
  46. // When 200 milliseconds pass, execute script
  47. }, 200);
  48. })();