Prime Video Ad Blocker [ESP]

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

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

  1. // ==UserScript==
  2. // @name Prime Video Ad Blocker [ESP]
  3. // @namespace https://greasyfork.org/en/users/5102-jeau
  4. // @version 0.1.5
  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.  
  17. // This value when true shows that the ad has been skipped
  18. var adSkipped = false;
  19.  
  20. // Every 0.2 seconds, this function runs
  21. setInterval(function() {
  22.  
  23. // Selects the video container's child (Which is the video element)
  24. if (document.getElementsByClassName("rendererContainer")[0]) {
  25. var video = document.getElementsByClassName("rendererContainer")[0].children[2];
  26.  
  27. // If Time To Skip element exist
  28. if ( document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0] ){
  29.  
  30. // Has it been skipped aready? (This is so that way you don't skip forward twice)
  31. if ( adSkipped == false ) {
  32.  
  33. // Grabs the ad timer in HH:MM:SS format and splits it into an array
  34. var currentAdTime = document.getElementsByClassName("atvwebplayersdk-adtimeindicator-text")[0].innerHTML.split(':');
  35.  
  36. // Calculate the Ad time in seconds
  37. var adTimeInSecs = 0;
  38. for (let i = 0; i < currentAdTime.length; i++) {
  39. adTimeInSecs += parseInt(currentAdTime[i]) * Math.pow(60, currentAdTime.length - 1 - i);
  40. }
  41.  
  42. // It then skipped forward the video by how much ad time the timer shows
  43. // 0.5 secs correction to avoid freezing of Web Player with some Ads
  44. video.currentTime = video.currentTime + adTimeInSecs - 0.5;
  45.  
  46. // Shows that the ad has been skipped
  47. adSkipped = true;
  48. }
  49.  
  50. } else {
  51. // When ad timer disappers, reset the ad skip value
  52. adSkipped = false;
  53. }
  54. }
  55.  
  56. // When 200 milliseconds pass, execute script
  57. }, 200);
  58.  
  59. })();