Nicovideo:GINZA-HTML5 autoset 1080p

If 1080p video exists, set video quality to 1080p automatically.

当前为 2018-01-12 提交的版本,查看 最新版本

// ==UserScript==
// @name         Nicovideo:GINZA-HTML5 autoset 1080p
// @namespace    https://twitter.com/tigerauge0
// @version      1.01
// @description  If 1080p video exists, set video quality to 1080p automatically.
// @author       HAC
// @match        http://www.nicovideo.jp/watch/*
// @grant        none
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    let observer = new MutationObserver(function (MutationRecords, MutationObserver) {
        //console.log('Obserbing');
        for(let MutationRecord of MutationRecords) {
            if(MutationRecord.target === $('.PlayerOptionDropdown-menu')[0]) {
                if(MutationRecord.previousSibling === null) {
                    let resolutionListTopDomObj = $(MutationRecord.target).find('.PlayerOptionDropdownItem:first-child > .PlayerOptionDropdownItem-inner')[0];
                    if(/1080p/.test(resolutionListTopDomObj.textContent)) {
                        console.log('1080p is available.');
                        resolutionListTopDomObj.click();
                        if($('#AutoPlayMenuItem-on').val() === 'true'){
                            $('.PlayerPlayButton > .ControllerButton-inner')[0].click();
                        }
                    } else {
                        console.log('1080p is not available.');
                    }
                    // 問題点: .PlayerOptionDropdownItem[0]が検出できなかった場合、Observeし続ける
                    MutationObserver.disconnect();
                    break;
                }
            }
        }
    });
    observer.observe(document, { childList: true, subtree: true});
})();

QingJ © 2025

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