开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 1922|回复: 13
收起左侧

[2025开源大赛(第八届)] 油猴脚本-屏蔽网页版抖音-直播&广告

[复制链接]
发表于 2025-10-4 00:45:01 | 显示全部楼层 |阅读模式   西藏自治区拉萨市
分享源码
界面截图:
是否带模块: -
备注说明: -
本帖最后由 witcaspar 于 2025-10-4 00:49 编辑

上班摸鱼的时候喜欢用电脑刷网页抖音-广告直播太多-无聊写了个油猴脚本
{:4_255:} {:4_255:}

下面头部描述有点问题 建议下载文件 或者按照上面图片修改
// ==UserScript==
// home.php?mod=space&uid=47252         KillDouYin
// home.php?mod=space&uid=158809    http://tampermonkey.net/
// home.php?mod=space&uid=59980      1
// @description  屏蔽广告、直播、
// @author       You
// @match        https://www.douyin.com/*
// home.php?mod=space&uid=639598         https://www.google.com/s2/favicons?sz=64&domain=douyin.com
// home.php?mod=space&uid=585119        none
// @require      https://unpkg.com/ajax-hook@2.1.3/dist/ajaxhook.min.js
// ==/UserScript==

(function () {
    'use strict';
    let killConfig = {
        isDebug: true,
        thisClarity: '',
        isScreen: false,
        skip: {
            live: true,
            ad: true,
            enterprise: true
        }
    }
    /**
     * 打印Debug日志
     * @param {打印的消息} msg
     */
    let killLog = function (msg) {
        if (killConfig?.isDebug) {
            console.log(msg)
        }
    }
    /**
     * 主页视频清晰度切换
     */
    let vcTaskId = setInterval(function () {
        let pathName = location.pathname;
        /*判断当前页面是否可执行视频清晰度切换*/
        if (pathName === "/" || pathName === "/follow" || pathName === "/friend") {
            let thisVcItem = document.querySelector('div[data-e2e=feed-active-video] .xgplayer-playclarity-setting .virtual .item');
            if (thisVcItem !== null) {
                if (killConfig.thisClarity !== thisVcItem.textContent) {
                    if (killConfig.thisClarity !== '超清 4K') {
                        if (thisVcItem.textContent === '超清 4K' || thisVcItem.textContent === '超清 2K' || thisVcItem.textContent === '高清 1080P') {
                            killConfig.thisClarity = thisVcItem.textContent;
                            thisVcItem.click();
                        }
                    }
                }
                if (!killConfig.isScreen) {
                    //满屏播放
                    document.querySelector("div[data-e2e=feed-active-video]").querySelector(".xgplayer-page-full-screen > .xgplayer-icon").click();
                    killConfig.isScreen = true;
                }
                if (killConfig.thisClarity === '超清 4K') {
                    clearInterval(vcTaskId);
                }
            }
        }
    }, 3000);
    ah.proxy({
        //请求成功后进入
        onResponse: (response, handler) => {
            if (response.config.url?.includes("/aweme/v2/web/feed/") || response.config.url?.includes("/aweme/v1/web/tab/feed/")) {
                let stringRes = JSON.parse(response.response)
                let list = stringRes.aweme_list
                if (list) {
                    try {
                        console.info('↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓')
                        console.info(JSON.stringify(list))
                        //KillAd
                        if (killConfig?.skip?.ad) {
                            list = list.filter(i => !i?.is_ads)
                            list = list.filter(i => !i?.enterprise_verify_reason)
                            list = list.filter(i => !i?.images)
                            list = list.filter(i => i?.anchor_info?.title_tag != "购物")
                            list = list.filter(i => !i?.web_raw_data?.includes("brand_ad"))
                        }
                        //KillEnterprise
                        if (killConfig?.skip?.enterprise) {
                            list = list.filter(i => i?.author?.enterprise_verify_reason == "")
                        }
                        //KillLive
                        if (killConfig?.skip?.live) {
                            list = list.filter(i => !i.cell_room)
                            list = list.filter(i => Object.keys(i.video).length > 0)
                        }
                        console.info(JSON.stringify(list))
                        console.info('↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑')
                    } catch (e) {
                        killLog(e);
                    }
                }
                stringRes.aweme_list = list
                response.response = JSON.stringify(stringRes)
            }
            handler.next(response)
        }
    });
})();



KillDouYin.txt

4.36 KB, 下载次数: 20, 下载积分: 精币 -2 枚


签到天数: 6 天

发表于 2025-10-4 07:40:08 | 显示全部楼层   广东省广州市
头部错误,换这个头试试
// ==UserScript==
// @name         KillDouYin
// @Namespace    http://tampermonkey.net/
// @Version      1.0
// @description  屏蔽广告、直播、企业号等内容
// @author       You
// @match        https://www.douyin.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=douyin.com
// @grant        none
// @require      https://unpkg.com/ajax-hook@2.1.3/dist/ajaxhook.min.js
// ==/UserScript==
回复 支持 反对

使用道具 举报

结帖率:50% (2/4)

签到天数: 2 天

发表于 2025-10-10 16:55:20 | 显示全部楼层   重庆市重庆市
这个直接做成cxr的话是不是更爽
回复 支持 反对

使用道具 举报

结帖率:0% (0/2)

签到天数: 3 天

发表于 2025-10-5 19:35:25 | 显示全部楼层   广东省东莞市
支持开源~!感谢分享
回复 支持 反对

使用道具 举报

发表于 2025-10-5 13:29:45 | 显示全部楼层   美国
感谢分享,很给力!~
回复 支持 反对

使用道具 举报

结帖率:80% (4/5)
发表于 2025-10-5 09:43:06 | 显示全部楼层   山东省潍坊市
已经顶贴,感谢您对论坛的支持!
回复 支持 反对

使用道具 举报

签到天数: 2 天

发表于 2025-10-5 08:41:10 | 显示全部楼层   广东省东莞市
界面看着挺不错的,一眼看懂模式,期待写法参考
回复 支持 反对

使用道具 举报

发表于 2025-10-4 19:36:37 | 显示全部楼层   江苏省连云港市
感谢分享
回复 支持 反对

使用道具 举报

签到天数: 4 天

 楼主| 发表于 2025-10-4 12:26:47 | 显示全部楼层   西藏自治区拉萨市

我这屎山代码 AI估计看不上
回复 支持 反对

使用道具 举报

签到天数: 4 天

 楼主| 发表于 2025-10-4 12:25:50 | 显示全部楼层   西藏自治区拉萨市

油猴添加脚本- 全部复制进去覆盖保存就行了
回复 支持 反对

使用道具 举报

结帖率:87% (122/141)

签到天数: 3 天

发表于 2025-10-4 10:46:13 | 显示全部楼层   广东省惠州市
怎么用啊
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备2025452707号) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表