Greasy Fork is available in English.

抖音插件

自动跳过广告

// ==UserScript==
// @name         抖音插件
// @namespace    https://github.com/QYG2297248353/tampermonkey_douyin
// @version      v1.0.0
// @description  自动跳过广告
// @author       新疆萌森软件开发工作室
// @match        *://*.douyin.com/*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAHrJJREFUeF7tnQl4E9Xax/8zadMWSmlStgooyI4oiKgom6BsKiIo7iCLKPiB93rl+/ReLy64gLsirrjvioKCCoIIAoKKiCBIaWlpgdJS2ibd0qZJ5nzPCQ2Wtkkmk5nMmeSc58kTlnPO+77/c345M3OWERCBlJaW1p4Q0keSpO6iKJ4pSVJHQRDSCSGtALQUBCEZQAKAuAi4w02wr4AbgJMQUgmgTBCEYkJIgSiKhyVJyhFFMVMQhD0lJSX5WociaGEgLS2tpyRJlxFChgqCcBGADlrY4XXGvAJHCCHbBEHYJIri9yUlJRlqK6IaICkpKV1FUbxREIRrAPRV21FeH1dAhgK7CCFfSJL0cXl5+QEZ+YNmCRsQq9U6EsBsQsiEoNZ4Bq5AhBQQBGEFgFdKS0vXhWNSMSAWi2UwgPsBjAnHAV6WK6CxAmsAPGaz2bYosaMEkASLxfI0gDlKDPIyXAGdFFhis9nm0Zv/UOyHBEhqaupwQRBeAdAjFCM8L1eAEQX2E0Jm2+32DXL9kQ2IxWKZDeBluRXzfFwBhhW402az0R/6oEkWIKmpqfMFQVgQtDaegStgEAUIIQ/Y7fZHgrkbFBAORzAJ+f8bVQE5kAQEhF9WGbXpud8hKBDwcssvIHU35D+EYIhn5QoYUgFCyAh/N+7+AKGPcnfxp1WGbG/udOgK7LfZbHT1R6NHwE0CYrFYXuTzHKGrzEsYWgE6TzK3YQSNAKmbId9s6FC581wBZQoMaTjj3hQgq/nyEWXq8lKGV2CNzWYbWz+KUwChCw8JIWsNHyYPgCugUAFBEEbVX+DYEJDlfFWuQmV5sahQgK4CLi0tnegL5iQgdD+H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trs9mWeAFJS0vrKUnSPlY8Y9GPXomJGJqcjHOSktAjMRF0lr6ZGNpe31KPB8ddLhx3u7G5stL74ZdOLLY2IIpir5KSkoyT02EWi+UPAH3ZdJdNr043m9HZbEayyeQdcXzfLkK8EDT8ePjlEpsN2dirXTabrR/955OApKamzhcEYYFRIuB+cgW0UoAQ8oDdbn/kFEBSUlK6mkymLK2M8nq5AkZRwOPxdCsvLz9wCiD0L1ardTkhZIJRAuF+cgXUVkAQhBWlpaUTffWesiTParWOJISsVdsor48rYBQFBEEYVVpauq5JQOg/WiyW1QDGGCUg7idXQEUF1thstrH162u0qNtisQwGsFlFo7wqroBRFBhis9m2BASkbhShk4Z08pAnrkCsKLDEZrPNbRisv21BCRaLZReAHrGiDo8zphXYb7PZ6BygUy4gdH3WcEEQfohp2XjwMaEAIWSE3W5v8sjKgBtLLRbLbAAvx4RKPMhYVeBOm832ir/gg+685jPssdpvoj/u+jPmigGhBTkk0d9ZYi1COXBQTYKOID7h+OVWrHWhqI434GVV0Me8/qSpu3Gn12v86VZU95+oDW4/IWS2vxvypqKWPYLUK0wfAT/N50mithNFa2B0nmNeU49yAwWsBBBvfXUz7vfzZSnR2p+iJi56Ys9jDWfI5UanGBCfAbrAEcBsvgpYruQ8XyQUoKtyAbxSf+GhErthA+IzSveTiKJ4Y90xpnxnopLW4GXCVWAXPS5UkqSPffs5wq1QNUDqO1K3x/0yQshQQRAuivUjhcJtJF7erwJHCCHbBEHYJIri93QPudpaaQJIQyfp4XSEkD6SJHUXRfFMSZI6CoKQTghpBaClIAjJAOixIVHzpiu1GyrG6nPTm2lCCH25U5kgCMWEkAJRFA9LkpQjimKmIAh7SkpK8rXW5f8BL6Vz+SaPT58AAAAASUVORK5CYII=
// @run-at       document-end
// @license MIT
// @grant        GM_log
// ==/UserScript==

(function () {
    'use strict';

    const nodeClass = "u0N5WOYm"

    // 存储之前的所有 MutationObserver
    var previousObservers = [];

    // 异步函数,用于延迟指定的毫秒数
    function delay(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    // 获取节点DOM
    async function findConsecutiveChildElements(containerClass) {
        var container = document.querySelector("." + containerClass);
        var childElements = container.children;
        var consecutiveCount = 0;
        var result = [];

        for (var i = 0; i < childElements.length; i++) {
            if (childElements[i].children.length > 0) {
                consecutiveCount++;
                result.push(childElements[i]);

                if (consecutiveCount === 3) {
                    // 如果之前有观察器,则先停止它们
                    previousObservers.forEach(observer => {
                        observer.disconnect();
                    });

                    // 针对每个找到的节点设置观察器
                    result.forEach(node => {
                        setupMutationObserver(node);
                    });

                    // 中间节点
                    var middleNode = result[1];

                    // 节点文本
                    var nodeText = middleNode.innerText;

                    // 判断是否存在 “广告” 字样
                    if (nodeText.indexOf("广告") !== -1) {
                        GM_log("跳过广告")
                        // 按下键盘下键
                        var e = new KeyboardEvent("keydown", { keyCode: 40 });
                        document.dispatchEvent(e);
                    }

                    // 退出循环
                    break;
                }
            } else {
                // Reset consecutive count and result if no sub-elements found
                consecutiveCount = 0;
                result = [];
            }
        }
        return consecutiveCount === 3;
    }

    // 设置 MutationObserver 的函数
    function setupMutationObserver(targetNode) {
        // 观察者的选项(要观察哪些突变)
        var config = { childList: true, subtree: true };

        // 创建一个链接到回调函数的观察者实例
        var observer = new MutationObserver(handleMutation);

        // 开始观察目标节点的配置突变
        observer.observe(targetNode, config);

        // 存储当前观察器,以便在下次设置新的观察器时可以停止它
        previousObservers.push(observer);
    }

    // 观察到突变时要调用的函数
    function handleMutation(mutationsList) {
        for (var mutation of mutationsList) {
            // 处理变化
            if (mutation.type === 'childList') {
                findConsecutiveChildElements(nodeClass);
            }
        }
    }

    // 异步循环执行函数
    async function asyncLoop() {
        while (true) {
            try {
                var find = await findConsecutiveChildElements(nodeClass);
                if (find) {
                    break
                } else {
                    GM_log("查找节点失败,正在重试");
                    await delay(1000);
                }
            } catch (error) {
                GM_log("查找节点失败,正在重试");
                await delay(1000);
            }
        }
    }

    // 异步循环执行函数
    asyncLoop();

    GM_log("抖音插件已启动");
})();