Crunchyroll Watchlist

Hide watched animes so it is easier to spot new episodes

当前为 2022-01-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Crunchyroll Watchlist
  3. // @version 1
  4. // @description Hide watched animes so it is easier to spot new episodes
  5. // @match https://beta.crunchyroll.com/*
  6. // @icon https://www.google.com/s2/favicons?domain=crunchyroll.com
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/206408
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Your code here...
  15. function l(...args){
  16. console.log('[Watchlist]', ...args)
  17. }
  18.  
  19. function filter(){
  20. let container = document.querySelector("#content > div > div.app-body-wrapper > div > div > div.erc-watchlist > div.watchlist-body > div:nth-child(1) > div > div")
  21. for(let row of container.children){
  22. row = row.children[0]
  23. for(let item of row.children){
  24. let card = item.querySelector('.c-watchlist-card')
  25. if(card){ //not a loading placeholder
  26. let subtitle = card.querySelector('.c-watchlist-card__subtitle').textContent
  27. if(subtitle.includes('Watch Again')){
  28. //Do something with animes watched
  29. card.style.filter = 'brightness(0.1)'
  30. }
  31. }
  32. }
  33. }
  34. }
  35.  
  36. //Observe changes to the DOM since there are no events that can be used
  37. const observer = new MutationObserver((mutationsList, observer) => {
  38. if(window.location.href === 'https://beta.crunchyroll.com/watchlist'){
  39. for(const mutation of mutationsList){
  40. //Items added to the watchlist grid
  41. if(['ReactVirtualized__Grid__innerScrollContainer', 'ReactVirtualized__Grid ReactVirtualized__List'].includes(mutation.target.className)){
  42. filter()
  43. }
  44. }
  45. }
  46. })
  47.  
  48. observer.observe(document, {subtree:true, childList:true, attributes:true})
  49. })();