bilibili 自动网页全屏

自动网页全屏

目前为 2022-04-21 提交的版本。查看 最新版本

// ==UserScript==
// @name        bilibili 自动网页全屏
// @author      sangkuanji
// @license MIT
// @namespace   nana_vao_script
// @description 自动网页全屏
// @version     1.30
// @include     http://www.bilibili.com/video/BV*
// @include     https://www.bilibili.com/video/BV*
// @include     https://www.bilibili.com/video/av*
// @include     http://bangumi.bilibili.com/anime/v/*
// @include     https://bangumi.bilibili.com/anime/v/*
// @include     https://www.bilibili.com/bangumi/play/*
// @run-at      document-start
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM_deleteValue
// ==/UserScript==

(function () {
    let url = GM_getValue('url');
    GM_deleteValue('url');
    if (location.hostname == 'bangumi.bilibili.com') {
        if(url === location.href){
            return;
        }
        GM_setValue('url', location.href);
        document.addEventListener('DOMContentLoaded', function () {
            window.stop();
            location.href = document.querySelector('.v-av-link').href;
        });
    } else {
        try{
            localStorage.setItem('bilibililover', 'YESYESYES');
            localStorage.setItem('defaulth5', '1');
        }catch(e){}
        window.addEventListener('load', function () {
            console.log("load success");
            this.$ = unsafeWindow.jQuery;
            let elementNames = ["bilibili-player-iconfont-web-fullscreen-off", "squirtle-pagefullscreen-inactive"];
            for(var i = 0; i < elementNames.length; i++) {
                 waitElement(elementNames[i]);
            }
        });
    }

    function waitElement(elementName) {
        this.$ = unsafeWindow.jQuery;
        var _times = 20, //100次
            _interval = 1000, //100毫秒每次
            _self = document.getElementsByClassName(elementName),
            _iIntervalID; //定时器id
        if( _self.length != 0){ //如果已经获取到了,就直接执行函数
            document.getElementsByClassName(elementName)[0].click();
        } else {
            console.log("times" + _times);
            _iIntervalID = setInterval(function() {
                if(!_times) { //是0就退出
                    clearInterval(_iIntervalID);
                }
                _times <= 0 || _times--; //如果是正数就 --
                _self = document.getElementsByClassName(elementName); //再次选择
                if( _self.length != 0) { //判断是否取到
                    document.getElementsByClassName(elementName)[0].click();
                    clearInterval(_iIntervalID);
                }
            }, _interval);
        }
        return this;
    }
}) ();

QingJ © 2025

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