Amazon Prime Video Expiry Viewer

Makes it obvious which and when videos are going to expire.

  1. // ==UserScript==
  2. // @name Amazon Prime Video Expiry Viewer
  3. // @namespace https://github.com/Kadauchi
  4. // @version 1.0.4
  5. // @description Makes it obvious which and when videos are going to expire.
  6. // @author Kadauchi
  7. // @icon http://i.imgur.com/oGRQwPN.png
  8. // @include https://www.amazon.com/gp/video*
  9. // @include https://www.amazon.com/Prime-Video/*
  10. // ==/UserScript==
  11.  
  12. const checked = {}
  13.  
  14. function checkShelf () {
  15. for (const el of document.getElementsByClassName('dv-shelf-item')) checkIfLeaving(el);
  16. for (const el of document.getElementsByClassName('dv-packshot')) checkIfLeaving(el);
  17. for (const el of document.getElementsByClassName('UaW15H')) checkIfLeaving(el);
  18. for (const el of document.getElementsByClassName('UI789i')) checkIfLeaving(el);
  19. }
  20.  
  21. async function checkIfLeaving (item) {
  22. const asin = item.querySelector('[data-asin]').dataset.asin;
  23. const leaving = await fetchHover(asin);
  24.  
  25. if (leaving.isLeaving) {
  26. const date = document.createElement('div');
  27. date.textContent = 'Leaving ' + leaving.isLeaving;
  28. date.style = 'text-align: center; color: black;';
  29. date.style.backgroundColor = 'yellow';
  30. item.appendChild(date);
  31. }
  32.  
  33. if (leaving.isImdb) {
  34. const date = document.createElement('div');
  35. date.textContent = 'Available on your IMDb TV channel';
  36. date.style = 'text-align: center; color: black;';
  37. date.style.backgroundColor = 'gold';
  38. item.appendChild(date);
  39. }
  40. }
  41.  
  42. function fetchHover (asin) {
  43. return new Promise(async (resolve) => {
  44. if (asin && !checked[asin]) {
  45. const response = await window.fetch(`https://www.amazon.com/gp/video/hover/${asin}?format=json`);
  46. const text = await response.text();
  47. // console.log(text);
  48. const imdb = text.match(/ncluded with your IMDb TV channel/);
  49. const leaving = text.match(/Leaving Prime on ([\w\s,]+)/);
  50. const isImdb = !!imdb;
  51. const isLeaving = leaving ? leaving[1] : false;
  52. checked[asin] = { isImdb, isLeaving };
  53. resolve(checked[asin]);
  54. } else if (checked[asin]) {
  55. resolve(checked[asin]);
  56. }
  57. })
  58. }
  59.  
  60. checkShelf();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址