Tieba Bypass Login

解除百度贴吧强制登录

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name				Tieba Bypass Login
// @name:zh-CN			Tieba Bypass Login
// @namespace			[email protected]
// @author				依然独特
// @description			解除百度贴吧强制登录
// @description:zh-CN	解除百度贴吧强制登录
// @version				0.0.4
// @run-at				document-start
// @require				https://greasyfork.org/scripts/18715-hooks/code/Hooks.js?version=661566
// @include				*://tieba.baidu.com/*
// @include				*://tiebac.baidu.com/*
// @include				*://*.tieba.baidu.com/*
// @match				*://tieba.baidu.com/*
// @match				*://tiebac.baidu.com/*
// @match				*://*.tieba.baidu.com/*
// @grant				unsafeWindow
// @license				CC-BY-4.0
// ==/UserScript==

"use strict";

(function() {
	let executed = false

	// We want to change user login state as soon as possible
	Hooks.get(unsafeWindow, "_", (...args) => {
		const [_target, _propertyName, _oldValue, _newValue] = args
		
		// Only on desktop site `PageData' will be defined
		if (!executed && unsafeWindow.PageData != null) {
			unsafeWindow.PageData.user.is_login = 1
			unsafeWindow.PageData.user.no_login_user_browse_switch = 0
			executed = true
		}

		return Hooks.Reply.get(args);
	})
})()