抖音直播Extend

抖音直播加入功能拓展按钮,可以在某些方面加强抖音直播。

// ==UserScript==
// @name         抖音直播Extend
// @namespace    http://dyliveplug.ddwhm.com/
// @version      1.6
// @description  抖音直播加入功能拓展按钮,可以在某些方面加强抖音直播。
// @author       Jesen
// @match        *://live.douyin.com/*
// @icon         https://p-pc-weboff.byteimg.com/tos-cn-i-9r5gewecjs/favicon.png
// @grant             GM_addStyle
// @grant             GM_addElement
// @grant             GM_setValue
// @grant             GM_getValue
// @grant             unsafeWindow
// @run-at            document-idle
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    console.log("GM 脚本开始");
    window.switchLive = false;
    // 旋转具体函数
    function rotate(e){
        e.style.transformOrigin = "center";
        e.classList.add("rrr");
    }
    function unRotate(e){
        e.style.transformOrigin = "";
        e.classList.remove("rrr");
    }
    // 旋转按钮点击事件
    function onRotateBtnclick(){
        let a = document.getElementsByTagName("video")[0];
        if(window.switchLive){
            unRotate(a);
            window.switchLive = false;
        }else{
            rotate(a);
            window.switchLive = true;
        }
    }

    function onZhuiliuBtnclick(){
        let liveVideoNode = document.getElementsByTagName("video")[0];
        let buffered = liveVideoNode.buffered;
        if (buffered.length == 0) {
            // 暂停中
            return;
        }
        liveVideoNode.currentTime = buffered.end(0);
    }

    window.onloadFunc = function() {
        if(location.host.indexOf("douyin") > -1){
          // 在页面中展示旋转按钮。
          const xgr = document.getElementsByTagName("xg-right-grid")[0];
          let ne = document.createElement("b");
          ne.innerHTML= "<b style='color:red;'>横屏</b>";
          let zl = document.createElement("b");
          zl.innerHTML= "<b style='color:red;'>追流</b>";
          xgr.appendChild(ne);
          xgr.appendChild(zl);
          ne.firstChild.onclick = onRotateBtnclick;
          zl.firstChild.onclick = onZhuiliuBtnclick;
          // 横屏样式
          var style = document.createElement('style');
          style.innerHTML = '.rrr { transform: rotate(270deg) !important; }';
          document.head.appendChild(style);
        }

        if(location.host.indexOf("huya.com") > -1){
            // 在页面中展示旋转按钮。
            const xxx = document.getElementsByClassName("player-ctrl-btn")[0];
            let zls = document.createElement("b");
            zls.innerHTML= "<b style='color:red;'>追流</b>";
            xxx.appendChild(zls);
            zl.firstChild.onclick = onZhuiliuBtnclick;
        };
    };

    let intID = setInterval(() => {
        if (typeof (document.querySelector('.xgplayer-play')) !== "undefined") {
            window.onloadFunc();
            console.log("成功检测到播放器,开始置放按钮")
            clearInterval(intID);
        }
    }, 1000);

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址