V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
ooh
V2EX  ›  分享创造

分享一段自动删除 Youtube 活动记录的脚本

  •  
  •   ooh · 38 天前 · 769 次点击
    这是一个创建于 38 天前的主题,其中的信息可能已经有所发展或是发生改变。

    功能

    这段脚本解决 Youtube 活动记录不能批量清空,需要用户一个个点击删除按钮。

    利用浏览器控制台功能运行脚本实现在活动记录页面查找删除按钮自动点击。

    注意

    如果你不是需要清空自己的活动记录或者你想保留特定的评论、点赞、直播聊天消息你不应该在控制台运行该脚本

    使用

    在以下页面:

    YouTube 上的评论

    YouTube 直播中的聊天消息

    对 YouTube 上评论的“赞”和“不喜欢”操作

    打开浏览器控制台运行脚本:

    const label = "删除活动记录"
    const container = document.querySelector('div.jkOv3d');
    let lastClicked = null;
    setInterval(() => {
        if (!container) return;
        const button = Array.from(container.querySelectorAll('button, [role="button"]'))
            .find(el =>
                el.getAttribute('aria-label')?.includes(label) &&
                getComputedStyle(el).display !== 'none' &&
                getComputedStyle(el).visibility !== 'hidden' &&
                el.offsetParent !== null
            );
    
        if (button && button !== lastClicked) {
            button.style.backgroundColor = '#ff0000';
            lastClicked = button;
            setTimeout(() => button.click(), 50);
        }
    }, 100);
    setInterval(() => {
        if (!container) return;
        const button = Array.from(container.querySelectorAll('button, [role="button"]'))
            .find(el =>
                el.getAttribute('aria-label')?.includes(label) &&
                getComputedStyle(el).display !== 'none' &&
                getComputedStyle(el).visibility !== 'hidden' &&
                el.offsetParent !== null
            );
        if (button === undefined) {
            window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth" });
        }
    }, 3000);
    

    刷新页面或者关闭页面即可终止运行。

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2582 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 15:09 · PVG 23:09 · LAX 08:09 · JFK 11:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.