A站 自动播放 & 网页全屏

AcFun Autoplay & FullScreen

当前为 2019-12-08 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         A站 自动播放 & 网页全屏
// @version      0.11
// @description  AcFun Autoplay & FullScreen
// @author       Erimus
// @include      http*://*acfun.cn/v/ac*
// @grant        none
// @namespace    https://greasyfork.org/users/46393
// ==/UserScript==

(function() {
    'use strict';

    console.log('=== autoplay & fullscreen')

    // 把是否在播放的判断条件改为计数。
    // 防止网络不好长时间Loading,出现播了一点,判断为已播放,其实暂停了的情况。
    let playing = 0
    // 现在是折中的方法,只判断3次,防止Loading造成的暂停。
    // 但是1.5秒内用户点击暂停后,会继续播放。
    let play_count_limit = 3
    let fullscreen = false

    let main = setInterval(function() {

        if (!fullscreen) {
            // find full screen button
            let fullScreenBtn = document.querySelector('.fullscreen-web')
            console.log('=== Full Screen Button:', fullScreenBtn)
            if (fullScreenBtn) {
                // check fullscreen status
                let closed = fullScreenBtn.querySelector('.btn-span').getAttribute('data-bind-attr')
                console.log('=== Closed:', closed)
                // alert(1)
                if (closed=='web') {
                    console.log('=== fullscreen OK')
                    fullscreen = true
                } else {
                    fullScreenBtn.click()
                }
            }
        }

        if (playing < play_count_limit) {
            // find start button on player area bottom
            let playBtn = document.querySelector('.btn-play');
            console.log('=== Play Button:', playBtn)
            if (playBtn) {
                // check play status
                let check = playBtn.querySelector('.btn-span').getAttribute('data-bind-attr')
                console.log('=== Playing check:', check)
                if (check=='play') {
                    playing++
                    console.log('=== playing', playing)
                } else {
                    playBtn.click()
                }
            }
        }

        if (playing >= play_count_limit && fullscreen) {
            console.log('=== quit loop')
            clearInterval(main)
        }

    }, 200);

})();