I got sick of seeing 40 minute long videos on the dumbest things. Even if it is a topic I'm interested in the pacing of such a video makes it so not even 5 minutes of it are worth watching. All good youtube videos are under 20 minutes. Some of the code is mislabeled because I decided having the script tell youtube I'm not interested is a stretch goal and for the sake of the end user, simply hiding those videos is good enough.
```
//
UserScript// @name Youtube long video remove
// @namespace Violentmonkey Scripts
// @match
https://www.youtube.com/// @grant none
// @version 1.0
// @author -
// @description 11/29/2023, 6:23:59 PM
//
/UserScript//
UserScript// @name YouTube Auto 'Not Interested' for Long Videos
// @namespace
http://tampermonkey.net/// @version 0.1
// @description Automatically mark long videos as 'Not Interested' on YouTube
// @author YourName
// @match
://youtube.com/
// @grant none
// /UserScript
(function() {
'use strict';
function convertDurationToSeconds(text) {
return text.split(':').reverse().map((i, idx) => parseFloat(i) Math.pow(60, idx)).reduce((a, b) => a + b, 0);
}
function findAndHideLongVideos() {
var selectors = ['ytd-compact-video-renderer.style-scope.ytd-item-section-renderer','div#content.style-scope.ytd-rich-item-renderer'];
for(let selector of selectors) {
console.log("hello from long youtube")
const suggestions = document.querySelectorAll(selector);
console.log({selector,suggestions});
for (let suggestion of suggestions) {
let durationElement = suggestion.querySelector('div#time-status span#text');
if (durationElement) {
let durationSeconds = convertDurationToSeconds(durationElement.textContent.trim());
if (durationSeconds > 1200) { // 20 minutes
//Hide it
suggestion.style.display='none';
//Find and click the menu button
//let menuButton = suggestion.querySelector(/
selector for the menu button /);
//if (menuButton) menuButton.click();
//Wait for the menu to open and then click 'Not Interested'
//setTimeout(() => {
// let notInterestedButton = document.querySelector(/
selector for 'Not Interested' /);
// if (notInterestedButton) notInterestedButton.click();
//}, 500); // Adjust timeout as needed
}
}
}
}
}
// Run the function periodically
setInterval(findAndHideLongVideos, 1000); // Adjust interval as needed
})();
```
[ + ] soupnazi
[ - ] soupnazi [op] 2 points 5 monthsNov 29, 2023 18:54:30 ago (+2/-0)*
It's better formatted here: https://matrix.gvid.tv/c/userscripts/54MdRDve8X
[ + ] OftenWrong
[ - ] OftenWrong 1 point 5 monthsNov 29, 2023 19:38:11 ago (+1/-0)
[ + ] Niggly_Puff
[ - ] Niggly_Puff 0 points 5 monthsNov 29, 2023 21:15:58 ago (+0/-0)
[ + ] soupnazi
[ - ] soupnazi [op] 0 points 5 monthsNov 29, 2023 22:18:24 ago (+0/-0)
https://raw.githubusercontent.com/Schegge/Userscripts/master/Block%20Youtube%20Users.js
But I also think that's a youtube feature already and I have no idea how old that script is. I think there is a "Don't recommend this channel" option on thumbnails.