日度归档:13 12 月, 2021

批量取消Youtube视频订阅方法

发现我的Youtube账号里莫名其妙多出来大量订阅,遂想取消之。批量取消JavaScript代码如下:
页面地址:https://www.youtube.com/feed/channels

buttons = document.querySelectorAll('#grid-container tp-yt-paper-button');
len = buttons.length;
index = 0;
while (index < len) {
    t = 100 * index;
    setTimeout((function(index, t) {
        return function() {
            buttons[index].dispatchEvent(new MouseEvent('click'));
            setTimeout(function() {
                cancel = document.querySelector('tp-yt-paper-dialog #confirm-button');
                cancel.dispatchEvent(new MouseEvent('click'));
                console.log(`共{len}个订阅,正在取消第{index + 1}个订阅`);
            },
            50);
        }
    })(index, t), t);
    index++;
}