Greasy Fork

Greasy Fork is available in English.

bilibili网页视频简介中的链接可以点击(按行区分)

try to take over the world!

当前为 2020-08-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         bilibili网页视频简介中的链接可以点击(按行区分)
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       beibeibeibei
// @match        *.bilibili.com/video/*
// @grant        none
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...
    var $=jQuery.noConflict();
    function splitLines(str) {return str.split(/\r?\n/);}
    var info_text = $("#v_desc").find(".info");
    var text = info_text.text();
    var textarray = splitLines(text);

    var time1 = 250;
    var time2 = 1500;
    var count = 0;
    var countarray = [];
    var reg = /([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/|[wW]{3}.|[wW][aA][pP].|[fF][tT][pP].|[fF][iI][lL][eE].)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;

    function self_increasing(num1,num2,num3){
        //num1会在大于等于num2和小于等于num3中自增
        num1++;
        if (num1 > num3){
            num1 = num2;
        }
        return num1;
    }
    function del_text(){
        if(info_text.text() != ""){
            info_text.text("");
            count=self_increasing(count,0,9);
        }
        countarray.unshift(count);
        if(countarray.length > time2/time1){
            countarray.length = countarray.length - 1;
            if(new Set(countarray).size == 1){
                //console.log(textarray);
                for(var i=0;i<textarray.length;i++){
                    if(reg.test(textarray[i])){
                        info_text.before('<p><a href="' + textarray[i] + '" target="_blank" style="color:blue;">' + textarray[i] + '</a></p>');
                    }else if(textarray[i] == ""){
                        info_text.before('<br>');
                    }else{
                        info_text.before('<p>' + textarray[i] + '</p>');
                    }
                }
                clearInterval(timer);
            }
        }
        //console.log("转啊转啊");
    }

    var timer = setInterval(del_text, time1);

    // Your code here...
})();