Greasy Fork is available in English.

哔哩哔哩-分享当前进度

分享当前的观看进度

Pasang skrip ini?
Sugesti pemilik skrip

Kamu mungkin juga suka 哔哩哔哩-设置迷你播放器大小.

Pasang skrip ini
// ==UserScript==
// @name         哔哩哔哩-分享当前进度
// @namespace    ckylin-bilibili-share-progress
// @version      0.2
// @description  分享当前的观看进度
// @author       CKylinMC
// @match        https://www.bilibili.com/video/*
// @grant        none
// ==/UserScript==

(function() {
    function CK_addBtn(){
        var c = document.querySelector(".float-nav .nav-menu");
        if(!c) return false;
        var alreadySet = document.querySelector("#ck_shareprogress");
        if(alreadySet){
            alreadySet.remove();
        }
        var ckbtn = document.createElement("div");
        ckbtn.title="点击分享当前进度";
        ckbtn.className = "item mini";
        ckbtn.innerHTML = "<span>分享</span><span>进度</span>"
        ckbtn.id="ck_shareprogress"
        ckbtn.onclick = CK_shareprogress;
        c.appendChild(ckbtn);
        return true;
    }
    function CK_shareprogress(){
        if (location.href.indexOf("https://www.bilibili.com/video/av") === 0) {
            var page="0";
            if(location.href.indexOf("?")!=-1){
                var locbase = location.href.split("?")[1];
                if(locbase.indexOf("#")>=0){
                    locbase = locbase.split("#")[0];
                }
                var args = [];
                if(locbase.indexOf("&")>=0){
                    args = locbase.split("&");
                }else args.push(locbase);
                args.forEach(function(e){
                    if(e.indexOf("p=")==0){
                        page = e.split("=")[1];
                    }
                });
            }
            var pagestr = page=="0"?"":"p="+page+"&";
            var a = document.querySelector(".bilibili-player-video-time-now").innerText.split(":");
            prompt("Share this bilibili video with your watch progress:\nTIME: " + (Math.floor((a[0] * 60 + parseInt(a[1])) / 60)) + "m" + ((a[0] * 60 + parseInt(a[1])) % 60) + "s" + "\nURL:", location.origin + location.pathname + "?"+pagestr+"t=" + (a[0] * 60 + parseInt(a[1])));
        } else alert("只支持普通Bilibili视频页面");
    }
    //var CK_LOOP_SP;
    function CK_load(){
        if(CK_addBtn()) clearInterval(window.CK_LOOP_SP);
    }
    setTimeout(function(){
        window.CK_LOOP_SP = setInterval(function(){CK_load()},1000);
    },5000);

})();