Add hide button

Add hide button to video blocks in subscriptions feed

2022-02-11 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @author       Rolandas Valantinas
// @description  Add hide button to video blocks in subscriptions feed
// @include      *youtube.com/feed/subscriptions*
// @name         Add hide button
// @namespace    https://greasyfork.org/users/157178
// @supportURL   https://github.com/rolandas-valantinas/gists/issues
// @version      1.0
// ==/UserScript==

// Helper functions
function getTarget(e) {
	e = e || window.event;
	return e.target || e.srcElement;
}

// Hide videos when clicked
function autoHideClicked (e) {
	var target = getTarget(e).parentNode.parentNode;

    var hideMenuButton = target.getElementsByTagName('button')[0];
    hideMenuButton.click();

    setTimeout(function() {
        // Hide the video via the youtube menus, because 1) lazy, 2) easier to update in future
        var hideMenu = document.getElementsByTagName('ytd-popup-container')[0];
        var hideButton = hideMenu.getElementsByTagName('yt-formatted-string');
        hideButton[hideButton.length-1].click();
    }, 4);
}

(function () {
    var i;
    var videos = document.getElementsByTagName("ytd-grid-video-renderer");

    for (i = 0; i < videos.length; i++) {
        var link = document.createElement('div');
        link.innerHTML = '<a class="hide-button" href="javascript:;">hide</a>';

        videos[i].appendChild(link);
    }

    var hideButtons = document.getElementsByClassName('hide-button');

    for (i = 0; i < hideButtons.length; i++) {
        hideButtons[i].addEventListener('click', autoHideClicked, false);
    }
})();