bilibili wayback

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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();
    });
})();