Skip to content

Instantly share code, notes, and snippets.

@NullDev
Last active May 9, 2023 00:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NullDev/485d4b51fcab5751ab0b1f5ba5fd6745 to your computer and use it in GitHub Desktop.
Save NullDev/485d4b51fcab5751ab0b1f5ba5fd6745 to your computer and use it in GitHub Desktop.
Auto-Skip Amazon Video Ads / Promos

Auto-Skip for Amazon Video Ads / Promos

You just want to binge your show but Amazon interrupts your experience with those annoying promos between the episodes?
LOOK NO FURTHER

This script saves you some clicks and automatically skips those promos for you.

How to install

License

Under MIT License like all of my public gists: https://gist.github.com/NullDev/f65b57677505e72986536652aa5dbc9c

Kudos to @RundesBalli for helping with the RegEx <3

// ==UserScript==
// @name AmazonVideo Ad Skip
// @namespace NullDev
// @version 0.1
// @description Auto-Skip Amazon Video promos
// @author NullDev
// @include /https?:\/\/(?:www\.)?amazon(?:\.[a-z]+){1,2}\/gp\/video\/detail\/.+/
// @icon https://www.amazon.com/favicon.ico
// @grant none
// ==/UserScript==
"use strict";
const tries = 3;
const delay = 1500;
/**
* Simulate click if element exists
*
* @param {Number} i
* @returns {void}
*/
let skipAd = function(i){
let btn = document.querySelector(".adSkipButton.skippable");
if (!!btn) return btn.click();
};
/**
* Try to check for element
*
* @returns {void}
*/
let tryElement = function(){
for (let i = 0; i < tries; i++) setTimeout(() => skipAd(i), i * delay);
};
(function(ns, fetch){
if (typeof fetch !== "function") return;
// Hook into fetch function and execute check after invoking fetch
ns.fetch = function(){
let out = fetch.apply(this, arguments);
out.then(({ ok }) => tryElement());
return out;
};
}(window, window.fetch));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment