您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在番剧页面时,可以用“L键”切换视频比例。(看柯南看的)
// ==UserScript== // @name 番剧页面切换视频比例 // @namespace http://tampermonkey.net/ // @version 1.1 // @description 在番剧页面时,可以用“L键”切换视频比例。(看柯南看的) // @author 40FoUR // @match https://www.bilibili.com/bangumi/play/* // @grant none // @license GPL-3.0 // ==/UserScript== (function() { 'use strict'; // 找到元素 function waitForElement(selector, callback) { const element = document.querySelector(selector); if (element) { callback(element); } else { setTimeout(() => waitForElement(selector, callback), 500); } } // 设置视频比例 function setAspectRatio(ratio) { waitForElement('.squirtle-single-setting-chooses.squirtle-aspect-ratio', (element) => { const choices = element.querySelectorAll('.squirtle-single-setting-choice.squirtle-aspect-ratio-choice'); choices.forEach((choice) => { if (choice.getAttribute('data-value') === ratio) { choice.click(); } }); }); } // 监听键盘 document.addEventListener('keydown', function(event) { if (event.key === 'l' || event.key === 'L') { waitForElement('.squirtle-single-setting-choice.squirtle-aspect-ratio-choice.active', (activeChoice) => { const currentRatio = activeChoice.getAttribute('data-value'); switch (currentRatio) { case '0:0': setAspectRatio('4:3'); break; case '4:3': setAspectRatio('16:9'); break; case '16:9': setAspectRatio('0:0'); break; default: setAspectRatio('0:0'); break; } }); } }); })();