您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动在地址栏中将 bv 还原为 av,非重定向,不会导致页面刷新,顺便清除 search string 中所有无用参数
当前为
// ==UserScript== // @name Bilibili AntiBV // @icon https://www.bilibili.com/favicon.ico // @namespace https://moe.best/ // @version 1.3 // @description 自动在地址栏中将 bv 还原为 av,非重定向,不会导致页面刷新,顺便清除 search string 中所有无用参数 // @author 神代绮凛 // @include /^https:\/\/www\.bilibili\.com\/video\/[BbAa][Vv]/ // @require https://cdn.jsdelivr.net/npm/[email protected]/src/simplequerystring.min.js // @license MIT // @grant none // ==/UserScript== (function() { 'use strict'; // Get from __INITIAL_STATE__ const get = key => { const is = window.__INITIAL_STATE__ || {}; return is[key] || (is.videoData && is.videoData[key]) || window[key]; }; // https://www.zhihu.com/question/381784377/answer/1098804685 const bv2av = bv => { if (!bv) return; const pos = [11, 10, 3, 8, 4, 6]; const base = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'; const table = {}; for (let i = 0; i < base.length; i++) table[base[i]] = i; let r = 0; for (let i = 0; i < pos.length; i++) r += table[bv[pos[i]]] * 58 ** i; return (r - 8728348608) ^ 177451812; }; const purgeSearchString = () => { const { p, t } = simpleQueryString.parse(location.search); const result = simpleQueryString.stringify({ p, t }); return result ? `?${result}` : ''; }; const av = get('aid') || bv2av(get('bvid')); if (av) history.replaceState(null, '', `https://www.bilibili.com/video/av${av}${purgeSearchString()}${window.location.hash}`); })();