您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
b 站移动端网页推荐视频直接看
当前为
// ==UserScript== // @name Bilibili Mobile // @name:zh-CN bilibili 移动端 // @namespace https://github.com/jk278/bilibili-mobile // @version 1.1.2 // @description view bilibili mobile page recommended video directly // @description:zh-CN b 站移动端网页推荐视频直接看 // @author jk 278 // @match *://m.bilibili.com // @match *://m.bilibili.com/video/* // @match *://m.bilibili.com/search?* // @icon https://www.bilibili.com/favicon.ico // @require http://code.jquery.com/jquery-3.6.0.min.js // ==/UserScript== (function () { 'use strict'; function runVideo() { function addTargetElementListener(targetElement) { if (targetElement) { const anchor = targetElement.firstChild; const h2Element = anchor.lastChild; const keyword = encodeURIComponent(h2Element.innerHTML); const searchUrl = `https://m.bilibili.com/search?keyword=${keyword}&utm_source=userscript`; anchor.addEventListener( 'click', async (event) => { event.preventDefault(); event.stopImmediatePropagation(); await new Promise((resolve) => setTimeout(resolve, 0)); window.location.href = searchUrl; }, true ); } } document.querySelector('.player-icon').click(); document.querySelector('.play-icon').click(); let timer = setInterval(function () { const dialog = document.querySelector('.dialog'); if (dialog) { clearInterval(timer); dialog.lastChild.click(); } }, 200); const cardBox = document.querySelector('.card-box'); const targetElements = cardBox.children; // 为初始子元素添加监听器 Array.from(targetElements).forEach(addTargetElementListener); // 创建 MutationObserver 以监听子元素的变化 const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === 'childList') { mutation.addedNodes.forEach((addedNode) => { addTargetElementListener(addedNode); }); } }); }); // 配置观察选项 const observerConfig = { childList: true, }; // 开始观察 observer.observe(cardBox, observerConfig); } function runSearch() { const searchResultElement = document.querySelector('.v-card-single'); // 第一个 if (searchResultElement) { // clearInterval(timer); searchResultElement.click(); let dialogTimer = setInterval(function () { const vDialog = document.querySelector('.v-dialog'); if (vDialog) { clearInterval(dialogTimer); vDialog.querySelector('.cancel').click(); } }, 200); } } if (window.location.pathname.startsWith('/video')) { runVideo(); console.log('Execute Video!'); } else if (window.location.pathname.startsWith('/search') && new URLSearchParams(window.location.search).get('utm_source') === 'userscript') { runSearch(); console.log('Execute Search!'); } const href = window.location.href; let hrefTimer = setInterval(function () { if (window.location.href !== href) { clearInterval(hrefTimer); window.location.href = window.location.href; } }, 200); })();