import { addStyle, DOMUtils, log } from "@/env"; import { addBlockCSS } from "@components/env.base"; import { Panel } from "@components/setting/panel"; export const DouYinLiveBlock_ChatRoom = { init() { Panel.execMenuOnce("live-shieldChatRoom", () => { return this.shieldChatRoom(); }); Panel.execMenuOnce("live-shielChatRoomVipSeats", () => { return this.shielChatRoomVipSeats(); }); Panel.execMenuOnce("live-shieldDoubleScreen", () => { return this.shieldDoubleScreen(); }); Panel.execMenuOnce("dy-live-shieldUserLevelIcon", () => { return this.shieldUserLevelIcon(); }); Panel.execMenuOnce("dy-live-shieldUserVIPIcon", () => { return this.shieldUserVIPIcon(); }); Panel.execMenuOnce("dy-live-shieldUserFansIcon", () => { return this.shieldUserFansIcon(); }); Panel.execMenuOnce("dy-live-shieldMessage", () => { return this.shieldMessage(); }); Panel.execMenuOnce("dy-live-blockBottomArea", () => { return this.blockBottomArea(); }); }, /** * 【屏蔽】评论区(聊天室) */ shieldChatRoom() { log.info("【屏蔽】评论区(聊天室)"); return [ addBlockCSS( "#chatroom", // 2025.6.29 新版 "#RightBackgroundLayout" ), addStyle(/*css*/ ` div[data-e2e="living-container"], div[data-e2e="living-container"] > div{ margin-bottom: 0px !important; }`), ]; }, /** * 【屏蔽】副屏 */ shieldDoubleScreen() { log.info("【屏蔽】副屏"); return [addBlockCSS("#double_screen")]; }, /** * 【屏蔽】评论区的贵宾席 */ shielChatRoomVipSeats() { log.info("【屏蔽】评论区的贵宾席"); return [ addBlockCSS( "#chatroom > div > div:has(#audiencePanelScrollId)", '#chatroom > div > div:has([data-e2e="live-room-audience"])', // Firefox上的CSS,多了个pace-island '#chatroom > pace-island > div > div:has([data-e2e="live-room-audience"])' ), ]; }, /** * 【屏蔽】用户等级图标 */ shieldUserLevelIcon() { log.info("【屏蔽】用户等级图标"); return [ addBlockCSS('#chatroom .webcast-chatroom___item *:has(>img[src*="level"])'), addBlockCSS('#chatroom .webcast-chatroom___item *:has(>img[src*="aweme_grade_buff"])'), addBlockCSS('#chatroom .webcast-chatroom___item *:has(>img[src*="league"])'), ]; }, /** * 【屏蔽】VIP图标 */ shieldUserVIPIcon() { log.info("【屏蔽】VIP图标"); return [addBlockCSS('#chatroom .webcast-chatroom___item *:has(>img[src*="subscribe"])')]; }, /** * 【屏蔽】粉丝牌 */ shieldUserFansIcon() { log.info("【屏蔽】粉丝牌"); return [ addBlockCSS( '#chatroom .webcast-chatroom___item span:has(>div[style*="fansclub"])', '#chatroom .webcast-chatroom___item *:has(>img[src*="fansclub"])' ), ]; }, /** * 【屏蔽】信息播报 */ shieldMessage() { log.info("【屏蔽】信息播报"); // 暂时失效 return [ addBlockCSS( "#chatroom .webcast-chatroom___bottom-message", // 上面的滚动播报,xxx进入/加入了直播间 `#chatroom > div > div> pace-island:has(div[style*="new_grade_enter"])`, '#chatroom > div > div> div:has(div[style*="new_grade_enter"])' ), ]; }, /** * 【屏蔽】底部遮挡区域 */ blockBottomArea() { log.info("【屏蔽】底部遮挡区域"); return addStyle(/*css*/ ` .webcast-chatroom___list{ clip-path: none !important; } `); }, }; export const DouYinLiveBlock_VideoAreaRightMenu = { init() { Panel.execMenuOnce("dy-live-blockVideoRightMenu-downloadClient", () => { return this.blockDownloadClient(); }); }, /** * 【屏蔽】右键菜单-下载客户端 */ blockDownloadClient() { log.info(`【屏蔽】右键菜单-下载客户端`); return [addBlockCSS('.__menu_container_className:has(>a[href*="douyin-pc-web"])')]; }, }; /** * 需验证以下状态下的屏蔽情况,防止误杀 * * + Chrome、Firefox浏览器下 * + 普通播放情况下 * + 网页宽屏模式下 * + F11全屏情况下 */ export const DouYinLiveBlock = { init() { Panel.execMenuOnce("live-shieldGiftColumn", () => { return this.shieldGiftColumn(); }); Panel.execMenuOnce("live-shieldTopToolBarInfo", () => { return this.shieldTopToolBarInfo(); }); Panel.execMenuOnce("live-shieldGiftEffects", () => { return this.shieldGiftEffects(); }); Panel.execMenuOnce("live-shieldLucky", () => { return this.shieldLucky(); }); Panel.execMenuOnce("live-shielYellowCar", () => { return this.shieldYellowCar(); }); Panel.execMenuOnce("live-shieldDanmuku", () => { return this.shieldDanmu(); }); Panel.execMenuOnce("live-block-exhibition-banner-dylive-tooltip", () => { return this.block_exhibition_banner_dylive_tooltip(); }); DouYinLiveBlock_ChatRoom.init(); DouYinLiveBlock_VideoAreaRightMenu.init(); }, /** * 【屏蔽】底部的礼物栏 */ shieldGiftColumn() { log.info("【屏蔽】底部的礼物栏"); const result = [ addBlockCSS( // 2025.5.9 'div[data-e2e="living-container"] [id^="living_room_player_container"] > :last-child:has(.gitBarOptimizeEnabled )', // Firefox上的CSS,多了个pace-island 'div[data-e2e="living-container"] >div> div:has(>pace-island >.gitBarOptimizeEnabled)', // 全屏状态下的 'div[data-e2e="living-container"] xg-controls > div:has(div[data-e2e="gifts-container"]):not(:has(video))', // 2025.6.29 新版 "#BottomLayout:not([data-multi-camera])", // 2025.7.23 新版 全屏下的礼物栏 ".douyin-player .douyin-player-controls >div:nth-child(2):has(> .gitBarOptimizeEnabled )", // 2025.9.6 新版 `[data-e2e="living-container"] >div div:has(>pace-island>.gitBarOptimizeEnabled)` ), addStyle(/*css*/ ` /* 去除全屏状态下的礼物栏后,上面的工具栏bottom也去除 */ div[data-e2e="living-container"] xg-controls xg-inner-controls:has(+div div[data-e2e="gifts-container"]){ bottom: 0 !important; }`), ]; // 兼容 多机位 DOMUtils.waitNode("#BottomLayout:contains('多机位')", 10000).then(($el) => { if (!$el) return; DOMUtils.attr($el, "data-multi-camera", "true"); result.push(addBlockCSS("#BottomLayout[data-multi-camera] .gitBarOptimizeEnabled")); }); return result; }, /** * 【屏蔽】顶栏信息 * 包括直播作者、右侧的礼物展馆 */ shieldTopToolBarInfo() { log.info("【屏蔽】顶栏信息"); return [ addBlockCSS( 'div[data-e2e="living-container"] div[id*="living_room_player_container"] > pace-island[id^="island_"]', // 2024.12.26 'div[data-e2e="living-container"] div[id*="living_room_player_container"] >div>div>pace-island[id^="island_"]:has(.__isFullPlayer)', // 全屏状态下的 'div[data-e2e="living-container"] xg-bar.xg-top-bar', // 2025.6.29 新版 "#HeaderLayout", // 2025.7.23 新版 全屏下的礼物栏 ".douyin-player .douyin-player-top-bar" ), addStyle(/*css*/ ` /* 去除屏蔽顶部后直播的video偏移 */ #PlayerLayout [id^="living_player_containerdouyin-player"]{ padding-top: 0 !important; } `), ]; }, /** * 【屏蔽】礼物特效 */ shieldGiftEffects() { log.info("【屏蔽】礼物特效"); const result: (HTMLStyleElement | undefined)[] = [ addBlockCSS("#GiftTrayLayout", "#GiftEffectLayout", "#GiftMenuLayout", 'div[id^="gift_effect_bg_"]'), ]; return result; }, /** * 【屏蔽】福袋 */ shieldLucky() { log.info("【屏蔽】福袋"); return [ addBlockCSS( '.basicPlayer[data-e2e="basicPlayer"] > pace-island[id^="island_"]:has(.ShortTouchContainer):has(>div > div:not([class*="video_layout_container"]) > div)', // 2026.6.29 新版 "#ShortTouchLayout x-view", // 2025.7.23 新版 "#ShortTouchLayout .ShortTouchContainer" ), ]; }, /** * 【屏蔽】小黄车 */ shieldYellowCar() { log.info("【屏蔽】小黄车"); return [ addBlockCSS( 'div[id^="living_room_player_container"] .basicPlayer > div:has(div[data-e2e="yellowCart-container"])', // 2026.6.29 新版 "#EcmoCardLayout" ), ]; }, /** * 屏蔽弹幕 */ shieldDanmu() { log.info("屏蔽弹幕"); return [ addBlockCSS( "xg-danmu.xgplayer-danmu", // 2025.6.29 新版 "#DanmakuLayout" ), ]; }, /** * 【屏蔽】点亮展馆帮主播集星 */ block_exhibition_banner_dylive_tooltip() { log.info(`【屏蔽】点亮展馆帮主播集星`); return [addBlockCSS('[data-e2e="exhibition-banner"] .dylive-tooltip')]; }, };