返回首頁 

Greasy Fork is available in English.

抖音直播自动原画以及网页全屏

抖音直播间开启自动原画以及网页全屏


安装此脚本?
  1. // ==UserScript==// @name 抖音直播自动原画以及网页全屏// @namespace http://tampermonkey.net/// @version 0.1// @description 抖音直播间开启自动原画以及网页全屏// @author You// @match https://live.douyin.com/*// @icon https://live.douyin.com/favicon.ico// @grant none// @run-at document-end// @license MIT// ==/UserScript==(function () {"use strict";// Your code here...// 定义第一个函数function waitForElement(node, interval = 10, maxAttempts = 1000) {let attempts = 0;let timerId;function checkElement() {node=document.querySelector('[data-e2e="quality-selector"]');if (attempts >= maxAttempts) {console.error("Reached maximum number of attempts. Element not found.");clearTimeout(timerId); // 清除计时器return;}if (node === undefined || node === null) {console.error('Element not found');attempts++;timerId = setTimeout(checkElement, interval); // 设置下一次检查} else {console.log('Element found');clearTimeout(timerId); // 清除计时器// 在这里可以执行您想要的操作,因为节点已经找到}}checkElement();}function function1() {// 切换原画// 找到具有 data-e2e=quality-selector 属性的 div 元素const qualitySelectorDiv = document.querySelector('[data-e2e="quality-selector"]');waitForElement(qualitySelectorDiv);if (qualitySelectorDiv) {// 找到第一个孩子元素并模拟点击const firstChildElement = qualitySelectorDiv.firstElementChild;if (firstChildElement) {// 创建一个点击事件const clickEvent = new MouseEvent("click", {bubbles: true,cancelable: true,view: window,});// 触发点击事件firstChildElement.dispatchEvent(clickEvent);}}}// 定义第二个函数function function2() {// 网页全屏// 找到所有包含"网页全屏"文本的 div 元素const divElements = document.querySelectorAll("div");// 遍历所有 div 元素,查找匹配的文本的兄弟节点并点击divElements.forEach((divElement) => {if (divElement.innerText === "网页全屏") {// 找到兄弟节点const siblingElement = divElement.nextElementSibling;if (siblingElement) {// 创建一个点击事件const clickEvent = new MouseEvent("click", {bubbles: true,cancelable: true,view: window,});// 触发点击事件siblingElement.dispatchEvent(clickEvent);}}});}function1();function2();})();