HKG Toast Message Fixer

移除高登隱藏嘅toast bar,避免阻擋後面嘅內容點擊。

当前为 2024-10-19 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         HKG Toast Message Fixer
// @namespace    http://tampermonkey.net/
// @version      3.1
// @description  移除高登隱藏嘅toast bar,避免阻擋後面嘅內容點擊。
// @author       居理夫人
// @match        *://forum.hkgolden.com/*
// @icon
// @grant        none
// @license GNU GPLv3
// ==/UserScript==

(function() {
	'use strict';

	// 監聽DOM變化
	const observer = new MutationObserver(mutations => {
		mutations.forEach(mutation => {
			const toast = document.querySelector('.MuiSnackbarContent-root');
			if (toast) {
				const style = getComputedStyle(toast);
                // 先檢查 toast 係咪要顯示,若要顯示嘅話,opacity 會係 1
                if (style.opacity === '1' ) {
                    toast.style.display = 'flex';
                }
                // 檢查 toast 係咪已經隱藏,即opacity 要係 0
   				else if (style.opacity === '0') {
					// 當 toast 被隱藏時,將佢完全刪除
					toast.style.display = 'none';
                }
			}
		});
	});

	// 開始監聽 <body> 嘅子節點變化
	observer.observe(document.body, { childList: true, subtree: true });
})();