Bilibili Watchlater Redirect

Bilibili watchlater page redirect to normal single video page

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bilibili Watchlater Redirect
// @namespace    https://greasyfork.org/en/scripts/398925-bilibili-watchlater-redirect
// @version      1.0
// @description  Bilibili watchlater page redirect to normal single video page
// @description  B站 稍后再看 页面跳转至普通视频页面
// @icon         https://www.bilibili.com/favicon.ico
// @encoding     utf-8
// @date         03/29/2020
// @modified     03/29/2020
// @author       Franklin Chen
// @supportURL   http://msftbot.com/
// @copyright	 2020, Franklin Chen
// @include      https://www.bilibili.com/watchlater/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function redirect(){
        var url = window.location.href;
        if (url != "https://www.bilibili.com/watchlater/#/list") {
            url = url.replace(/watchlater\/#\//,"");

            var regExp = /\/p(\d*)/;
            var matchArr = regExp.exec(url);
            if(matchArr){
                var pNo= matchArr[1];
                switch(pNo) {
                    case "1":
                        url = url.replace(/\/p\d*/,"");
                        break;
                    default:
                        url = url.replace(/\/p\d*/,"?p="+pNo);
                }
            }
        }

        window.location.href = url;
    }

    function render() {
        var reBtn = $('<img src="https://www.bilibili.com/favicon.ico" alt="Redirect to normal page" title="Redirect to normal page" style="position:fixed;right:10px;bottom: 10px;height:24px;cursor: pointer;z-index:999">');
        reBtn.click(redirect);
        reBtn.appendTo($('body'))
    }

    render();

})();