Amazon Prime - Hide Store Videos

Amazon Prime - Hide Store Videos.

  1. // ==UserScript==
  2. // @name Amazon Prime - Hide Store Videos
  3. // @description Amazon Prime - Hide Store Videos.
  4. // @version 0.3
  5. // @author to
  6. // @namespace https://github.com/to
  7. // @license MIT
  8. //
  9. // @include https://www.amazon.*/gp/video/*
  10. // @include https://www.amazon.*/Amazon-Video/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=amazon.co.jp
  12. // ==/UserScript==
  13.  
  14. const PRIME_TEXT = 'プライム';
  15. const OKS = [/セール/, /(続けて|ウォッチリスト|近日公開|カテゴリー)/];
  16. const NGS = [];
  17.  
  18. const observer = new IntersectionObserver(([e]) => {
  19. if (!e.intersectionRect.height)
  20. return;
  21.  
  22. e.target.click();
  23. });
  24.  
  25. function patch() {
  26. Array.from(document.querySelectorAll('div.tst-collection')).forEach(row => {
  27. const title = row.querySelector('h2')?.textContent;
  28. if (title && !OKS.some(re => re.test(title)) && (
  29. NGS.some(re => re.test(title)) ||
  30. !row.querySelector(`img[alt="${PRIME_TEXT}"]`)
  31. ))
  32. row.remove();
  33. });
  34.  
  35. const next = document.querySelector('a.tst-pagination');
  36. if (next) {
  37. observer.disconnect();
  38. observer.observe(next);
  39. }
  40. }
  41.  
  42. new MutationObserver(patch).observe(document.body, {
  43. childList: true,
  44. subtree: true,
  45. });
  46.  
  47. patch();