Greasy Fork

Greasy Fork is available in English.

bilibili 让推荐页点开的视频能正常返回

点击bilibili的视频推荐卡片、跳转到另一个视频后,可以在浏览器中回退到之前的视频

// ==UserScript==
// @name         bilibili 让推荐页点开的视频能正常返回
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  点击bilibili的视频推荐卡片、跳转到另一个视频后,可以在浏览器中回退到之前的视频
// @author       Ne0
// @match        *://www.bilibili.com/video/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('click', function(event) {
        const card = event.target.closest('.video-page-card-small');

        if (card) {
            event.preventDefault();
            event.stopPropagation();

            const linkElement = card.querySelector('a.video-awesome-img');

            if (linkElement && linkElement.href) {
                window.location.href = linkElement.href;
            }
        }
    }, true);

})();