您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
解除B站大会员观影限制
当前为
// ==UserScript== // @name B站大会员影视+弹幕 // @namespace http://tampermonkey.net/ // @version 1.4 // @description 解除B站大会员观影限制 // @author Polygon // @match https://www.cuan.la/m3u8.php* // @match https://vip.parwix.com/* // @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* // @require http://code.jquery.com/jquery-1.11.0.min.js // @connect * // @run-at document-idle // @grant GM_getValue // @grant GM_setValue // ==/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 var danmu, cid function parseDanmu() { cid = GM_getValue('cid') danmu = { code: 23, msg: "success", dannum: 0, danmuku: [], name: "" } danmu.name = cid let api = `https://api.bilibili.com/x/v1/dm/list.so?oid=${cid}` GM_xmlhttpRequest({ method: "GET", url: api, onload: function (res) { let obj = res.responseText.match(/<d p=".+?">.+?<\/d>/g) danmu.danmuku = [] obj.forEach(ele => { let r = /<d p="(.+?)">(.+?)<\/d>/g.exec(ele) let params = r[1].split(',') let content = r[2] let time = params[0] let direction = parseInt(params[1]) let fontsize = params[2] let color = '#' + parseInt(params[3]).toString(16) let direction_info if (direction <= 3) { direction_info = 'right' } else if (direction == 4) { direction_info = 'bottom' } else if (direction == 5) { direction_info = 'top' } else { direction_info = 'right' } danmu.danmuku.push([time, direction_info, color, "", content, "", "", `${fontsize}px`]) }) danmu.dannum = danmu.danmuku.length danmu.danmuku.push(["0", 'bottom', '#FF616D', "", `替换弹幕源成功,前方共有${danmu.danmuku.length}条弹幕,请做好准备哟`, "", "", `30px`]) } }) } let get_danmu = (config, handler) => { parseDanmu() setTimeout(() => { handler.resolve({ config: config, status: 200, headers: { 'content-type': 'text/text' }, response: JSON.stringify(danmu) }) }, 500) } // 替换弹幕 ah.proxy({ onRequest: (config, handler) => { if (config.url.search(origin[which].regex) !== -1) { get_danmu(config, handler) } else handler.next(config) } }) // 解析视频替换iframe let parentId = '#toolbar_module' //添加样式 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 clear = () => { let parent // 删除已存在d的按钮 parent = document.querySelector(parentId) let old = document.querySelector('#switch') if (old) parent.removeChild(old) // 删除div parent = document.querySelector('.plp-l') let diyDiv = document.querySelector('#diy_module') if (diyDiv) { parent.removeChild(diyDiv) } } let addElement = () => { // 防止匹配到解析网址,控制台会输出错误 if (!document.URL.startsWith('https://www.bilibili.com/')) return clear() // 按钮添加到ele let ele = document.querySelector(parentId) let biliDiv = document.querySelector('#player_module') // 创建新player_module let diyDiv = biliDiv.cloneNode(true) diyDiv.style['padding-left'] = '0px' diyDiv.style.display = 'none' diyDiv.innerHTML = "" diyDiv.setAttribute('id', 'diy_module') let iframe = document.createElement("iframe") iframe.id = 'coldrainf-iframe' iframe.style.height = biliDiv.style.height diyDiv.append(iframe) let read_url = location.href 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 = '0px' } 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(diyDiv, document.querySelector('.media-wrapper')) // 切换按钮 let switchButton = document.createElement("div") switchButton.setAttribute('class', 'share-info') switchButton.setAttribute('id', 'switch') switchButton.innerHTML = '<i class="iconfont"></i><span style="background-color: #FB7299; border: 1px solid #FB7299; color: #fff; border-radius: 16px; text-align: center;">切换</span> <!---->' ele.appendChild(switchButton) let biliEle = document.querySelector('#player_module') let switchEle = document.querySelector('#diy_module') switchButton.addEventListener('click', function () { if (biliEle.style.display !== 'none') { // 切换前状态,点击切换 switchButton.querySelector('span').style['background-color'] = '#a62aee' switchButton.querySelector('span').style['border-color'] = '#a62aee' if (window.player) { window.player.pause() } biliEle.style.display = 'none' switchEle.style.display = 'block' if (document.querySelector('#bofang')) { document.querySelector('#bofang').click() } } else { // 切换后状态,点击恢复原始 switchButton.querySelector('span').style['background-color'] = '#fb7299' switchButton.querySelector('span').style['border-color'] = '#fb7299' biliEle.style.display = 'block' if (window.player) { window.player.play() } if (document.querySelector('#bofang')) { document.querySelector('#bofang').click() } switchEle.style.display = 'none' } }) $(switchButton).hover(function () { switchButton.querySelector('span').style['background-color'] = '#505050' switchButton.querySelector('span').style['border-color'] = '#505050' }, function () { if (biliEle.style.display !== 'none') { switchButton.querySelector('span').style['background-color'] = '#fb7299' switchButton.querySelector('span').style['border-color'] = '#fb7299' } else { switchButton.querySelector('span').style['background-color'] = '#a62aee' switchButton.querySelector('span').style['border-color'] = '#a62aee' } }) } function getCid() { if (!document.URL.startsWith('https://www.bilibili.com/')) return if (typeof cid == "undefined") { cid = unsafeWindow.__INITIAL_STATE__.epInfo.cid } GM_setValue('cid', cid) } let init = () => { getCid() addElement() setTimeout(() => { if (!document.URL.startsWith('https://www.bilibili.com/')) return let biliEle = document.querySelector('#player_module') let switchEle = document.querySelector('#diy_module') if (biliEle) biliEle.style.display = 'block' if (switchEle) switchEle.style.display = 'none' }, 500) } setTimeout(init, 800) let obs = document.querySelector('head title') new MutationObserver(function (mutations, observer) { setTimeout(() => {location.reload()}, 500) }).observe(obs, { attributes: true, childList: true, subtree: true }) })()