您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自動跳到看影片舒服的高度
// ==UserScript== // @name B站高度 // @namespace http://tampermonkey.net/ // @version 0.3 // @description 自動跳到看影片舒服的高度 // @author You // @match https://www.bilibili.com/video/* // @grant none // @require https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js // ==/UserScript== (function() { const lastMatchingElement = $('div.player-wrap'); var changeButtonHtml3 = '<input type="button" value="高度" ' + 'style="position: fixed; top: 100px; left: 83px; z-index: 9999;line-height: 30px;font-size: 25px; ">'; jQuery('body').append(changeButtonHtml3); jQuery('body').on('click', 'input[type="button"][value="高度"]', function() { $(window).scrollTop($(lastMatchingElement).offset().top-5); }); const $video = $('video'); const $target = $('div.player-wrap'); function scrollToTarget() { if ($target.length) { $(window).scrollTop($target.offset().top - 5); } } if ($video.length) { const observer = new MutationObserver(function(mutationsList) { for (const mutation of mutationsList) { if (mutation.type === 'attributes' && mutation.attributeName === 'src') { scrollToTarget(); } } }); observer.observe($video[0], { attributes: true, attributeFilter: ['src'] }); $video.on('play', function() { scrollToTarget(); }); } scrollToTarget(); })();