Greasy Fork

Greasy Fork is available in English.

Tieba Bypass Login

解除百度贴吧强制登录

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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				http://greasyfork.icu/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);
	})
})()