Greasy Fork is available in English.
修改cookie回到旧版B站主页
当前为
// ==UserScript==
// @name 回到旧版B站主页
// @namespace http://salt.is.lovely/
// @version 0.1.2
// @description 修改cookie回到旧版B站主页
// @author salt
// @license MulanPSL2
// @match https://*.bilibili.com/*
// @icon https://www.bilibili.com/favicon.ico
// @grant none
// ==/UserScript==
/*
Copyright (c) 2023 Salt_lovaly
回到旧版B站主页 is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
(function() {
'use strict';
// 基本配置
const defaultExpires = 'Mon, 13 Sep 2077 05:11:40 GMT'
const defaultDomain = '.bilibili.com'
const delMap = [
'buvid3', 'buvid4'
]
const setMap = {
'i-wanna-go-back': '1', // 如果想使用新版主页,就在浏览器控制台把这个改成 0,然后关闭这个脚本,最后刷新页面
'i-wanna-go-feeds': '1',
'nostalgia_conf': '2',
'go_old_video': '1',
'go-back-dyn': '1',
}
// 主要逻辑
const resetCookie = () => {
delMap.forEach((c) => deleteCookie(c))
Object.keys(setMap).forEach((c) => setCookie(c, setMap[c]))
}
setTimeout(resetCookie, 0)
setInterval(resetCookie, 1000)
// 其他东西
console.log(
`
欢迎使用盐酱牌回到旧版B站主页脚本!
本脚本将会:
强制清除这些cookie: ${delMap.join(', ')}
强制接管这些cookie: ${Object.keys(setMap).join(', ')}
如果想要使用新版B站主页,请:
1、关停此脚本
2、刷新所有B站页面(确保你已经彻底关停脚本)
3、在浏览器控制台输入这个指令并回车:document.cookie = "i-wanna-go-back=0;expires=${defaultExpires};path=/;domain=${defaultDomain}"
4、刷新页面
`)
// 工具函数
/** 删除指定 cookie */
function deleteCookie(name, domain = defaultDomain) {
// document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${domain}`;
setCookie(name, '', defaultExpires, domain)
}
/** 设定 cookie */
function setCookie(name, value = '', expires = defaultExpires, domain = defaultDomain) {
document.cookie = `${name}=${value};expires=${expires};path=/;domain=${domain}`
}
})();