bilibili wayback

将b站首页推荐替换成随机老视频(2019之前)

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         bilibili wayback
// @namespace    http://tampermonkey.net/
// @version      2024-09-08
// @description  将b站首页推荐替换成随机老视频(2019之前)
// @author       You
// @match        https://www.bilibili.com/
// @icon         https://p.sda1.dev/19/cfe475595af1b40e42368711ac2acd75
// @grant        none
// @run-at document-start
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const { fetch: originalFetch } = window;

    window.fetch = async (...args) => {
        let [resource, config] = args;
        let origin_url;
        if (resource instanceof window.Request) {
            origin_url = resource.url;
        } else {
            origin_url = resource.toString();
        }
        let target_prefix = 'https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd';
        if (!origin_url.startsWith(target_prefix)) {
            return originalFetch(resource, config);
        } else {
            let ps = new URL(origin_url).searchParams.get('ps') || 12;
            return originalFetch(`https://imfeelinglucky.linkpc.net/random_id?ps=${ps}`);
        }
    };

    window.addEventListener('load', function() {
        document.querySelector('.primary-btn.roll-btn').click();
    });
})();