Skip to content

Instantly share code, notes, and snippets.

@iosifnicolae2
Last active March 12, 2024 19:42
Show Gist options
  • Star 91 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save iosifnicolae2/1a78b5ab1d166fd5d17e6ae0a0fe0901 to your computer and use it in GitHub Desktop.
Save iosifnicolae2/1a78b5ab1d166fd5d17e6ae0a0fe0901 to your computer and use it in GitHub Desktop.
Youtube is Boring

How To Make Youtube Less Boring

Tutorial: https://www.youtube.com/watch?v=hIqMrPTeGTc
Paste the below code in your browser console (F12 > Console):

(()=>{
    markAllVideosAsNotBeingInteresting({
        iterations: 1
    });
})();

async function markAllVideosAsNotBeingInteresting({iterations}) {
    for(let i=0; i<iterations; i++) {
        await markCurrentVideosAsNotBeingInteresting();
        console.log(`Iteration ${i} completed. Waiting 300ms`);
        await sleep(300);
    }
   if(confirm("I'm done! Do you want to reload the page", "Yes")) {
    location.reload();
   }
}

async function markCurrentVideosAsNotBeingInteresting() {
    const videoMenuButtons = document.querySelectorAll("yt-icon.ytd-menu-renderer");

    for(let i=0; i<videoMenuButtons.length; i++) {
        if(!videoMenuButtons[i]) {
            continue
        }
        videoMenuButtons[i].scrollIntoView();
        await sleep(10);

        // Open the video menu
        videoMenuButtons[i].click();


        await sleep(50);

        // Click on "Not interested" button
        var notInterestedButton = document.querySelector("#items > ytd-menu-service-item-renderer:nth-child(5) > tp-yt-paper-item");
        if(!notInterestedButton) {
            continue
        }
        notInterestedButton.click();

        console.log("One video has been marked. Waiting 100ms");
        window.scrollBy(0, 95);
        await sleep(100);
    }
}

// Utils
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

PS. I'm not responsible if your accound get banned (Up until now, I wasn't banned) . Thanks!

UPDATE!

You can check the "New to you" tab (make sure to scale the page to 80%) image

@rachmadaniHaryono
Copy link

rachmadaniHaryono commented Jan 14, 2022

@iosifnicolae2 can confirm the fix, thank you

markdown

javascript:(function()%7B(()%3D%3E%7B%0A%20%20%20%20markAllVideosAsNotBeingInteresting(%7B%0A%20%20%20%20%20%20%20%20iterations%3A%201%0A%20%20%20%20%7D)%3B%0A%7D)()%3B%0A%0Aasync%20function%20markAllVideosAsNotBeingInteresting(%7Biterations%7D)%20%7B%0A%20%20%20%20for(let%20i%3D0%3B%20i%3Citerations%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20await%20markCurrentVideosAsNotBeingInteresting()%3B%0A%20%20%20%20%20%20%20%20console.log(%60Iteration%20%24%7Bi%7D%20completed.%20Waiting%20300ms%60)%3B%0A%20%20%20%20%20%20%20%20await%20sleep(300)%3B%0A%20%20%20%20%7D%0A%20%20%20if(confirm(%22I'm%20done!%20Do%20you%20want%20to%20reload%20the%20page%22%2C%20%22Yes%22))%20%7B%0A%20%20%20%20location.reload()%3B%0A%20%20%20%7D%0A%7D%0A%0Aasync%20function%20markCurrentVideosAsNotBeingInteresting()%20%7B%0A%20%20%20%20const%20videoMenuButtons%20%3D%20document.querySelectorAll(%22yt-icon.ytd-menu-renderer%22)%3B%0A%0A%20%20%20%20for(let%20i%3D0%3B%20i%3CvideoMenuButtons.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20%20%20%20%20if(!videoMenuButtons%5Bi%5D)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20videoMenuButtons%5Bi%5D.scrollIntoView()%3B%0A%20%20%20%20%20%20%20%20await%20sleep(10)%3B%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Open%20the%20video%20menu%0A%20%20%20%20%20%20%20%20videoMenuButtons%5Bi%5D.click()%3B%0A%0A%0A%20%20%20%20%20%20%20%20await%20sleep(50)%3B%0A%0A%20%20%20%20%20%20%20%20%2F%2F%20Click%20on%20%22Not%20interested%22%20button%0A%20%20%20%20%20%20%20%20var%20notInterestedButton%20%3D%20document.querySelector(%22%23items%20%3E%20ytd-menu-service-item-renderer%3Anth-child(5)%20%3E%20tp-yt-paper-item%22)%3B%0A%20%20%20%20%20%20%20%20if(!notInterestedButton)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20continue%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20notInterestedButton.click()%3B%0A%0A%20%20%20%20%20%20%20%20console.log(%22One%20video%20has%20been%20marked.%20Waiting%20100ms%22)%3B%0A%20%20%20%20%20%20%20%20window.scrollBy(0%2C%2095)%3B%0A%20%20%20%20%20%20%20%20await%20sleep(100)%3B%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20Utils%0Afunction%20sleep(ms)%20%7B%0A%20%20%20%20return%20new%20Promise(resolve%20%3D%3E%20setTimeout(resolve%2C%20ms))%3B%0A%7D%7D)()%3B

@rachmadaniHaryono
Copy link

@iosifnicolae2 unfortunately if blocktube is installed it will add not interested video channel to block list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment