枝江反诈骗

Show titles according to BVs.

目前為 2021-08-06 提交的版本,檢視 最新版本

// ==UserScript==
// @name         枝江反诈骗
// @namespace    https://space.bilibili.com/2649561
// @version      0.1
// @description  Show titles according to BVs.
// @author       Sela
// @match        *.bilibili.com/*
// @icon         https://tse1-mm.cn.bing.net/th/id/OIP-C.D0J8yk3gtsBUFSYLpv90YwHaHa?pid=ImgDet&rs=1
// @grant        none
// @require      http://code.jquery.com/jquery-3.x-git.min.js
/* globals jQuery, $, waitForKeyElements */
// ==/UserScript==

(function() {
    var reg = /b23.tv\/[0-9a-zA-Z]{6}/;
    var title = '';
    var u = '';
    //点击页面任意部分运行
    $('html').click(function(){
        $('a').each(function(){
            var temp = $(this).text();
            if(reg.test(temp)){
                var href = $(this).text();
                trueUrl(href);
                $.ajax({url:u,
                        success:function(result){
                            title = getTitle(result);
                        }});
                if(title.length > 1){
                    $(this).text(title);
                }
            }
        });
    });
    function getTitle(t){
        var reg = /data-vue-meta="true">(.+)_哔哩哔哩_bilibili<\/title>/;
        if (reg.test(t)){
            var title = reg.exec(t);
            return title[1];
        }
    }
    function trueUrl(href){
        //使用https://res.abeim.cn/api/dwz_longurl/doc.php接口
        var tool = 'https://res.abeim.cn/api-dwz_longurl?url=http://';
        var reg = /long_url":"(.+)"\}/;
        $.ajax({url:tool+href,
                success:function(result){
                    var text = JSON.stringify(result);
                    var temp = reg.exec(text)[1];
                    u = temp.replace('//m.','//www.');
                }})
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址