略
// ==UserScript==
// @name bilibili B站地址bv号自动跳转回av号
// @description 略
// @language zh-CN
// @version 20200401
// @match *://*.bilibili.com/*
// @author mudan_cn
// @run-at document-start
// @grant unsafeWindow
// @namespace https://gf.qytechs.cn/users/70322
// ==/UserScript==
const table='fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF',
s=[11,10,3,8,4,6],
xor=177451812,
add=8728348608;
switch([/www\.bilibili\.com\/video\/BV/,
/(search|space)\.bilibili\.com/]
.findIndex(e => e.test(location.href))){
case 0:
location.pathname = `/video/${dec(location.pathname.replace('/video/', ''))}`;
break;
case 1:
unsafeWindow.onload = function() {
document.querySelectorAll('a[href*="/BV"]').forEach(e => {
var url = new URL(e.href);
url.pathname = `/video/${dec(url.pathname.replace('/video/', ''))}`;
e.href = url.href;
});
};
break;
case -1:
}
function dec(x){
var i, r = 0;
for(i of Array(6).keys())
r += table.indexOf(x[s[i]])*58**i;
return `av${(r-add)^xor}`;
}
function enc(x){
x=(parseInt(x)^xor)+add;
var i, r=[...'BV1 4 1 7 '];
for(i of Array(6).keys())
r[s[i]]=table[Math.floor(x/58**i)%58]
return r.join('')
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址