Skip to content

Instantly share code, notes, and snippets.

@sarpavci
Created May 17, 2022 01:09
Show Gist options
  • Select an option

  • Save sarpavci/d83851228c298743f6d0ae0083ca5fc5 to your computer and use it in GitHub Desktop.

Select an option

Save sarpavci/d83851228c298743f6d0ae0083ca5fc5 to your computer and use it in GitHub Desktop.
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