BV2AV

BV转AV,并且显示到视频信息栏

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         BV2AV
// @namespace    https://www.7gugu.comm/
// @version      0.2
// @description  BV转AV,并且显示到视频信息栏
// @author       7gugu
// @include        /https?:\/\/bilibili\.com\/
// @match        https://www.bilibili.com/video/*
// @require      https://code.jquery.com/jquery-1.12.4.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    /*
    算法来源:
    https://www.zhihu.com/question/381784377/answer/1099438784
    */
    var table = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF",
    tr = new Object();
    for (var i = 0; i < 58; i++) {
        tr[table[i]] = i;
    }
    var s = [11, 10, 3, 8, 4, 6],
    xor = 177451812,
    add = 8728348608;

    function dec(x) {
        var r = 0;
        for (var i = 0; i < 6; i++) {
            r += tr[x[s[i]]] * 58 ** i;
        }
    return (r - add) ^ xor;
    }

    var bv = window.location.pathname;
	bv = bv.substring(bv.lastIndexOf('/'), bv.length);
    bv = bv.replace("\/","");
    if(bv.substr(0,2)!="BV")return;
    var av = dec(bv);

    var id = setInterval(function(){
        var html = $(".like").html();
        html = html.replace(/<!---->/g, "");
        html = html.replace("<i class=\"van-icon-videodetails_like\" style=\"color:;\"></i>", "");
        if(html.substr(0,2) != "--"){
            $(".video-data:first").append("<span style='margin-left:16px'><a href='https://www.bilibili.com/video/av"+av+"'>av"+av+"</a></span>");
            clearInterval(id);
        }
    }, 1000);



})();