Zyn Warning Removals & Topbar Adjustments

Adjusts styles on Zyn site to remove warnings that take up 20% of the view.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Zyn Warning Removals & Topbar Adjustments
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  Adjusts styles on Zyn site to remove warnings that take up 20% of the view.
// @author       sharmanhall
// @match        https://us.zyn.com/*
// @match        https://*.us.zyn.com/*
// @match        https://*.zyn.com/*
// @match        https://us.zyn.com/*
// @grant        none
// @icon         https://www.google.com/s2/favicons?sz=48&domain=zyn.com
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Inject CSS to force the warning to be hidden and the header to be at the top
    const style = document.createElement('style');
    style.textContent = `
        .has-warning .header {
            top: 0 !important;
        }
        .site-warning,
        .zynheader-warning,
        .zyn-header .zynheader-warning {
            display: none !important;
            visibility: hidden !important;
            z-index:-99999999 !important;
        }

        .site-warning {
        font-size: 0px !important;
        line-height: 0px !important;
        }
}
    `;
    document.head.appendChild(style);

    // MutationObserver to watch for dynamically added elements
    const observer = new MutationObserver(() => {
        document.querySelectorAll('.has-warning .header').forEach(element => {
            element.style.top = '0';
        });

        document.querySelectorAll('.site-warning, .zynheader-warning, .zyn-header .zynheader-warning').forEach(element => {
            element.style.display = 'none';
            element.style.setProperty('display', 'none', 'important');
            element.style.visibility = 'hidden';
            element.style.setProperty('visibility', 'hidden', 'important');
        });
    });

    // Observe the whole document for changes in the subtree and child elements
    observer.observe(document.body, { childList: true, subtree: true });
})();