Bilibili 视频默认选择1080P

哔哩哔哩清晰度默认1080P (在 Xianliang GE 版本上进行修改)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bilibili 视频默认选择1080P
// @namespace    https://github.com/henryxrl
// @version      0.2
// @description  哔哩哔哩清晰度默认1080P (在 Xianliang GE 版本上进行修改)
// @author       henryxrl
// @match        *://www.bilibili.com/video/*
// @match        *://www.bilibili.com/bangumi/play/*
// @icon         https://www.bilibili.com//favicon.ico
// @run-at       document-idle
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const video = document.getElementsByTagName("video")[0];
    video.onplay = (event) => {
        const observer = new MutationObserver(() => {
            const items = Array.from(document.getElementsByClassName("bpx-player-ctrl-quality-menu-item"))
                .filter(item => parseInt(item.getAttribute('data-value')) <= 80);
            if (items.length > 0) {
                items[0].click();
                observer.disconnect();
            }
        });
        observer.observe(document.body, { childList: true, subtree: true });
    };
})();