amitbl / blocktube

YouTube™ content blocker
GNU General Public License v3.0
948 stars 67 forks source link

[Feature Request] Send "Not Interested" command to the filtered out videos #474

Open klesun opened 1 month ago

klesun commented 1 month ago

Hi. Thank you for this great extension.

After using it for a while and creating a bunch of title filters, I eventually reached such state: image

My whole page consists of just a couple of videos, sometimes there is even not a single one. I assume youtube keeps recommending same videos again and again until at a certain point all of the feed consists of those recommendations hidden by the filters and there is just nothing more to show.

To prevent such situations, what I believe would make sense would be to automatically trigger the "Not Interested" button on all the filtered videos so that youtube knew that it should not recommend those same filtered videos again anymore and showed something new - something that will not be those accumulated filtered out videos.

Hopefully this issue will resonate with other people and someone files a PR eventually...

Best regards!

klesun commented 1 month ago

A workaround I'm using so far is temporarily disabling the extension, clicking "Not Interested" on all the accumulated videos in my feed, then turning the extension back on.

dragitz commented 2 weeks ago

I'm in favour of this option, especially since it could be implemented into the https://github.com/amitbl/blocktube/wiki/Advanced-Blocking

Right now I have this little algo that automatically block videos if they are shown multiple times in the span of x hours

(video, objectType) => {
    const MAX_RECOMMENDATIONS = 3;
    const TIME_WINDOW_SECONDS = 3600;
    const HOURS_BLOCKED = 4;
    // If video gets recommended more than MAX_RECOMMENDATIONS times in TIME_WINDOW_SECONDS, it gets blocked for HOURS_BLOCKED

    const currentUrl = window.location.href;

    // Must be in the recommended videos
    if (objectType !== 'compactVideoRenderer') {
        return false; 
    }
    // ensure music videos aren't filtered out
    if (video.channelBadges == "artist") { return false; }

    // filter based on view count
    if (video.viewCount < 1000 || video.viewCount > 100000) { // || video.title.length > 50
        return true;
    }

    // If we click on a video, it means we have shown interest, score must not go higher
    // Reset current video's score if present in localStorage
    if (currentUrl.includes(video.videoId)) {
        if (localStorage.hasOwnProperty(video.videoId)) {
            const videoData = JSON.parse(localStorage[video.videoId]);
            videoData.count = 0;
            videoData.timestamps = [];
            localStorage[video.videoId] = JSON.stringify(videoData);
        }
    }

    if (localStorage.hasOwnProperty(video.videoId)) {
        const videoData = JSON.parse(localStorage[video.videoId]);
        const currentTime = Date.now();

        // filter out timestamps older than n seconds
        videoData.timestamps = videoData.timestamps.filter(timestamp => currentTime - timestamp < TIME_WINDOW_SECONDS * 1000);
        videoData.timestamps.push(currentTime);

        if (videoData.timestamps.length > MAX_RECOMMENDATIONS) {
            videoData.blacklistedUntil = currentTime + HOURS_BLOCKED * 60 * 60 * 1000; // x hours from now
        }

        if (videoData.blacklistedUntil && currentTime < videoData.blacklistedUntil) {
            return true;
        } else {
            localStorage[video.videoId] = JSON.stringify(videoData);
        }
    } else {
        const videoData = {
            count: 1,
            timestamps: [Date.now()],
            blacklistedUntil: null
        };
        localStorage[video.videoId] = JSON.stringify(videoData);
    }

    return false;
}

If this feature gets implemented, it could be used to automatically send a "non interested" instead of hiding like I'm doing

dragitz commented 2 weeks ago

just to point out, this code does not work well on the home page, as the design breaks. that's why "compactVideoRenderer" is there

FatheredPuma81 commented 2 weeks ago

Why not just enable the feature???

dragitz commented 2 weeks ago

Why not just enable the feature???

I did a little bit of research to see how the context menu works, basically the option menu is shared between all visible videos, which means you must tell the page "hey I'm opening the menu for this specific video, give me the option to block/share/save that one"

I think (in theory) we could trick the page into thinking we opened it and then we pressed the "not interested" button, but I have no idea how to do that, my javascript skills aren't that evolved to do such thing right now

FatheredPuma81 commented 2 weeks ago

Ah never mind I misread what this was about entirely lol.

My whole page consists of just a couple of videos, sometimes there is even not a single one. I assume youtube keeps recommending same videos again and again until at a certain point all of the feed consists of those recommendations hidden by the filters and there is just nothing more to show.

Yea I've had this happen a lot of times when I binge watch a channel and have to temporarily block it after YouTube becomes obsessed with it. Just keep refreshing the page until you find a video to watch. It'll eventually fix itself as the algorithm readjusts in a couple days.

To prevent such situations, what I believe would make sense would be to automatically trigger the "Not Interested" button on all the filtered videos so that youtube knew that it should not recommend those same filtered videos again anymore and showed something new - something that will not be those accumulated filtered out videos.

Trust me you really shouldn't use the "not interested" button at all and god forbid automate it onto random videos. Pressing the "not interested" button causes the algorithm to also stop recommending you videos that the viewers of the "not interested" video watch. Which is to say just about everything you probably watch as well. I've gone down the "not interested" rabbit hole a few times (clearing watch history seems to fix it btw) and it always ended up with the algorithm recommending me random and niche videos I had no interest at all in.