🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Bilibili旧版首页

阻止b站修改buvid3以退回旧版2023/09/14

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 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旧版首页
// @namespace    http://tampermonkey.net/
// @version      0.1.8
// @description  阻止b站修改buvid3以退回旧版2023/09/14
// @author       飘过的风
// @license      MIT
// @match        *://*.bilibili.com/*
// @icon         https://www.bilibili.com/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    document.cookie = `go_back_dyn=1; domain=.bilibili.com; expires=Wed, 31 Dec 2025 00:00:00 GMT; path=/`;
    document.cookie = `go-back-dyn=1; domain=.bilibili.com; expires=Wed, 31 Dec 2025 00:00:00 GMT; path=/`;
    document.cookie = `go_old_video=1; domain=.bilibili.com; expires=Wed, 31 Dec 2025 00:00:00 GMT; path=/`;
    document.cookie = `nostalgia_conf=2; domain=.bilibili.com; expires=Wed, 31 Dec 2025 00:00:00 GMT; path=/`;
    document.cookie = `i-wanna-go-back=1; domain=.bilibili.com; expires=Wed, 31 Dec 2025 00:00:00 GMT; path=/`;
    document.cookie = `i-wanna-go-feeds=-1; domain=.bilibili.com; expires=Wed, 31 Dec 2025 00:00:00 GMT; path=/`;
    const blockedCookieNames = ['buvid3', 'buvid4', 'otherCookieYouWantToBlock']; // Add or remove cookie names from this lista as needed

    // Delete the cookies if they're already set
    blockedCookieNames.forEach((cookieName) => {
        if (document.cookie.includes(cookieName + '=')) {
            document.cookie = `${cookieName}=; domain=.bilibili.com; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
        }
    });

    // Override document.cookie to prevent setting blocked cookies
    const originalDocumentCookie =
        Object.getOwnPropertyDescriptor(Document.prototype, 'cookie') ||
        Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie');

    Object.defineProperty(document, 'cookie', {
        get: function () {
            return originalDocumentCookie.get.call(document);
        },
        set: function (value) {
            const cookieNameBeingSet = value.split('=')[0].trim();
            if (!blockedCookieNames.includes(cookieNameBeingSet)) {
                originalDocumentCookie.set.call(document, value);
            }
        },
    });
})();