bilibili wayback

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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