返回首頁 

网页抖音去广告,跳过直播,去除鼠标移动到收藏、分享后的界面

抖音将广告视频的【广告】两个字屏蔽了,但是我换了个定位又可以跳过广告了


Install this script?
// ==UserScript==// @name        网页抖音去广告,跳过直播,去除鼠标移动到收藏、分享后的界面// @namespace   Violentmonkey Scripts// @match       https://www.douyin.com/?*// @grant       none// @version     3.7// @description  抖音将广告视频的【广告】两个字屏蔽了,但是我换了个定位又可以跳过广告了// @author      -// @description 2022/12/15 下午4:03:18// ==/UserScript==(function checkForAd() {// 隐藏指定的 div 元素hideLastElement('.fZtBRuGd'); // 鼠标移动到收藏后的界面hideLastElement('[data-e2e="video-share-container"]'); // 鼠标移动到分享后的界面hideLastElement('.seEhooOF[data-e2e="video-play-more"]'); // 鼠标移动到...后的界面var videoContainer = document.querySelector('div[data-e2e="feed-active-video"]');if (videoContainer) {var hiddenDiv = videoContainer.querySelector('div.ZXLf6yJK') || videoContainer.querySelector('div.AXQAavwp'); // 广告地址//console.log(hiddenDiv);if (hiddenDiv && window.getComputedStyle(hiddenDiv).display === 'none') { // 添加对 hiddenDiv 是否存在的检查console.log('找到广告位置');simulateKeyDown(document, 40); // 模拟按下方向键↓// 在广告出现后,等待 5 秒后执行其他操作setTimeout(function () {// 在这里添加你想要执行的其他操作console.log('5 秒后执行其他操作');}, 5000);} else {console.log('没有广告');}// 自动选择“高清”清晰度const gearContainer = document.querySelector('.gear .virtual');console.log('999');// 确保容器存在if (gearContainer) {// 找到所有清晰度选项const items = gearContainer.querySelectorAll('.item');// 检查当前选中的选项const selectedItem = gearContainer.querySelector('.item.selected');// 如果当前选项不是“高清”,则选择“高清”if (!selectedItem || !selectedItem.textContent.includes('高清')) {// 遍历所有选项,找到包含“高清”的选项items.forEach(item => {if (item.textContent.includes('高清')) {// 触发点击事件,选择“高清”item.click();}});}}} else {console.log('没有找到 feed-active-video 元素,跳过直播');simulateKeyDown(document, 40); // 模拟按下方向键↓}// 在没有广告的情况下,每0.5秒检测一次setTimeout(checkForAd, 500);})();// 隐藏指定元素function hideLastElement(selector) {var elements = document.querySelectorAll(selector);var lastElement = elements[elements.length - 1];if (lastElement) {lastElement.style.display = 'none';}}// 模拟按下键盘事件function simulateKeyDown(target, keyCode) {var event = new KeyboardEvent('keydown', {keyCode: keyCode,bubbles: true,cancelable: true,});target.dispatchEvent(event);console.log('按下↓键');}