Greasy Fork

Greasy Fork is available in English.

B站大会员影视+弹幕

解除B站大会员观影限制

当前为 2021-07-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         B站大会员影视+弹幕
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  解除B站大会员观影限制
// @author       Polygon
// @match        https://www.cuan.la/m3u8.php*
// @require      http://greasyfork.icu/scripts/407985-ajax-hook/code/Ajax-hook.js?version=940269
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// @include      https://www.bilibili.com/bangumi/play/*
// @include      https://www.bilibili.com/video/BV*
// @connect      *
// ==/UserScript==
;(function () {
    'use strict'
    const origin = [{ regex: 'dmku', api: 'https://vip.parwix.com:4433/player/?url='},
        { regex: 'barrage', api: 'https://www.cuan.la/m3u8.php?url='}]
    const which = 1
    let danmu_api = 'https://service-otptqvj5-1256272652.bj.apigw.tencentcs.com/'
    // 替换弹幕
    ah.proxy({
        onRequest: (config, handler) => {
            if (config.url.search(origin[which].regex) !== -1) {
                console.log(config.url)
                let bili_url = /https:\/\/www.bilibili.com.+/g.exec(document.URL)[0]
                let danmu_url = danmu_api + bili_url
                GM_xmlhttpRequest({
                    method: "GET",
                    url: danmu_url,
                    headers: {
                        "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
                    },
                    data: "content=erwer",
                    onload: function (res) {
                        handler.resolve({
                            config: config,
                            status: 200,
                            headers: { 'content-type': 'text/text' },
                            response: JSON.stringify(JSON.parse(res.responseText))
                        })
                    },
                    onerror: function (res) {
                        alert("弹幕接口出错啊辣,快去瞧瞧吧~");
                    }
                })
            } else handler.next(config);
        }
    })
    // 解析视频替换iframe
    let bangumi = /bilibili.com\/bangumi\/play\//g.test(window.location.href)
    let parentId = bangumi ? 'toolbar_module' : 'arc_toolbar_report'
    //添加样式
    let style = document.createElement("style")
    style.innerHTML = (".coldrainf-get-dm{float:right;}.coldrainf-get-dm>div{display:inline-block;}.coldrainf-get-dm a{font-size:15px;color:#00a1d6;margin:0 12px;line-height:28px;}.coldrainf-get-dm a:hover{cursor:pointer;color:#f25d8e;}")
    document.head.appendChild(style)
    let addElement = cid => {
        let parent = document.getElementById(parentId)
        let old = document.querySelector('.coldrainf-get-dm')
        if (old) parent.removeChild(old)
        let ele = document.querySelector('#toolbar_module')
        let iframeTmp = document.querySelector('#coldrainf-iframe')
        if (iframeTmp) document.querySelector('.plp-l').removeChild(iframeTmp)
        let bfq = document.getElementById('player_module')
        if (bfq) bfq.style.display = 'block'
        // 创建新源
        let iframe = document.createElement("iframe")
        iframe.id = 'coldrainf-iframe'
        let read_url = $('meta[property="og:url"]')[0].content
        iframe.src = origin[which].api + read_url
        console.log(iframe.src)
        if (document.body.className.includes('player-mode-widescreen')) {
            iframe.style.position = 'absolute'
            iframe.style.top = '0'
        }
        iframe.height = '0%'
        iframe.width = '100%'
        iframe.setAttribute('frameborder', 'no')
        iframe.setAttribute('border', '0')
        iframe.setAttribute('allowfullscreen', 'allowfullscreen')
        iframe.setAttribute('webkitallowfullscreen', 'webkitallowfullscreen')
        document.querySelector('.plp-l').insertBefore(iframe, bfq)
        let jump = document.createElement("div")
        jump.innerHTML = '<div class="share-info"><i class="iconfont"></i><span style="background-color: #FB7299; border: 1px solid #FB7299; color: #fff; border-radius: 16px; text-align: center;">切换</span> <!----></div>'
        ele.appendChild(jump)
        jump.onclick = e => {
            if (unsafeWindow.player) unsafeWindow.player.pause()
            if (bfq.style.display == 'none') return
            iframe.height = bfq.style.height
            window.onresize = () => {
                iframe.style.height = bfq.style.height
            }
            bfq.style.display = 'none'
        }
    }
    //添加换p事件
    let href = window.location.href
    let changeEp = () => {
        let eles = bangumi ? document.querySelectorAll('.plp-r') : document.querySelectorAll('.list-box li')
        if (!eles) return
        eles.forEach(ele => {
            ele.addEventListener('click', e => {
                setTimeout(() => {
                    if (window.location.href == href) return
                    href = window.location.href
                    document.getElementById(parentId).removeChild(document.querySelector('.coldrainf-get-dm'))
                    addElement(getCid())
                }, 200)
            })
        })
    }
    //获取cid
    let getCid = () => {
        if (bangumi) return unsafeWindow.__INITIAL_STATE__.epInfo.cid
        else return cid
    }
    let init = () => {
        addElement(getCid())
        changeEp()
    }
    let obs = bangumi ? document.querySelector('#toolbar_module') : document.querySelector('.ops')
    if (!obs) setTimeout(init, 600)
    else {
        new MutationObserver(function (mutations, observer) {
            observer.disconnect();
            setTimeout(init, 600)
        }).observe(obs, { childList: true, subtree: true });
    }
})()