Created
May 17, 2022 01:09
-
-
Save sarpavci/d83851228c298743f6d0ae0083ca5fc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function markVideoAsNotInterested() { | |
| const selectorOptionsBtn = document.querySelectorAll('button.yt-icon-button'); | |
| const filterVideoItemButton = (btn) => { | |
| return !!btn.closest('.ytd-rich-grid-media'); | |
| }; | |
| const findPopup = () => { | |
| const selectorPopupContainer = document.getElementsByTagName('ytd-popup-container'); | |
| return Array.from(selectorPopupContainer).at(0); | |
| }; | |
| const filterNotInterestedServiceItem = (elm) => { | |
| const selectorFormattedString = elm.getElementsByTagName('yt-formatted-string'); | |
| const elmText = Array.from(selectorFormattedString).at(0); | |
| return elmText && elmText.textContent === 'Not interested'; | |
| }; | |
| const targetButtonIndex = window.markedVideoAsNotInterestedCount || 0; | |
| const elmOptionsButton = Array | |
| .from(selectorOptionsBtn) | |
| .filter(filterVideoItemButton) | |
| .at(targetButtonIndex); | |
| elmOptionsButton.click(); | |
| setTimeout(() => { | |
| const popup = findPopup(); | |
| const selectorOptionsServiceItem = popup.getElementsByTagName('ytd-menu-service-item-renderer'); | |
| const elmNotInterested = Array | |
| .from(selectorOptionsServiceItem) | |
| .filter(filterNotInterestedServiceItem) | |
| .at(0); | |
| setTimeout(() => { | |
| elmNotInterested.click(); | |
| window.markedVideoAsNotInterestedCount = targetButtonIndex + 1; | |
| setTimeout(markVideoAsNotInterested, 100); | |
| }, 50); | |
| }, 50); | |
| } | |
| markVideoAsNotInterested(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment