本帖最后由 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)
}
});
})();
|