Greasy Fork

Greasy Fork is available in English.

B站“稍后再看”重定向

B站“稍后再看”播放页重定向至常规播放页面

当前为 2020-07-15 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @id             BilibiliWatchlaterRedirect@Laster2800
// @name           B站“稍后再看”重定向
// @version        1.4.20200715
// @namespace      laster2800
// @author         Laster2800
// @description    B站“稍后再看”播放页重定向至常规播放页面
// @include        *://www.bilibili.com/medialist/play/watchlater/*
// @include        *://www.bilibili.com/watchlater/*
// @grant          GM_xmlhttpRequest
// @grant          GM_setValue
// @grant          GM_getValue
// @connect        api.bilibili.com
// @run-at         document-start
// ==/UserScript==

(function() {
    var v = GM_getValue('gm383441-20200714')
    if (!v) {
        var c = confirm(`来自【B站“稍后再看”重定向】:\n
    该脚本已合并至【http://greasyfork.icu/zh-CN/scripts/395456-b站-稍后再看-功能增强】,强烈建议进行迁移。\n
    该提示点击【确认】后不再显示,一段时间后会自动升级并移除掉与该提示相关的无用代码,所以不必担心影响运行效率的问题。\n
    如果只是希望最高效地使用重定向功能,大可忽略这个提示。`)
        if (c) {
            GM_setValue('gm383441-20200714', true)
            window.open('http://greasyfork.icu/zh-CN/scripts/395456')
        }
    }

    if (/bilibili.com\/medialist\/play\/watchlater\//.test(location.href)) {
        window.stop()
        GM_xmlhttpRequest({
            method: 'GET',
            url: `https://api.bilibili.com/x/v2/history/toview/web?jsonp=jsonp`,
            onload: function(response) {
                if (response && response.responseText) {
                    try {
                        var part = parseInt(location.href.match(/(?<=\/watchlater\/p)\d+(?=\/?)/)[0])
                        var json = JSON.parse(response.responseText)
                        var watchList = json.data.list
                        location.replace('https://www.bilibili.com/video/' + watchList[part - 1].bvid)
                    } catch(e) {
                        console.error('重定向错误,请联系脚本作者( http://greasyfork.icu/zh-CN/scripts/383441/feedback ):\n' + e)
                    }
                }
            }
        })
    }
})()