Greasy Fork is available in English.

巴哈姆特移除小圖示紅點

移除小圖示紅點

// ==UserScript==
// @name         巴哈姆特移除小圖示紅點
// @version      0.1.0
// @description  移除小圖示紅點
// @author       pana
// @namespace    https://greasyfork.org/zh-CN/users/193133-pana
// @license      GNU General Public License v3.0 or later
// @match        *://*.gamer.com.tw/*
// @grant        none
// @noframes
// ==/UserScript==
(function () {
    'use strict';
    const favicon = '/favicon.ico';
    function createIconLink() {
        const link = document.createElement('link');
        link.id = 'notificationNotice';
        link.type = 'image/x-icon';
        link.rel = 'icon';
        link.href = favicon;
        return link;
    }
    window.onload = () => {
        console.info('window onload.');
        let notificationNotice = document.getElementById('notificationNotice');
        if (notificationNotice) {
            console.info('reset favicon.');
            notificationNotice.href = favicon;
        }
        else {
            console.info('Cannot find notificationNotice.');
            notificationNotice = createIconLink();
            document.head.appendChild(notificationNotice);
        }
        const observer = new MutationObserver(() => {
            console.info('notificationNotice observer.');
            observer.disconnect();
            console.info('reset favicon.');
            if (notificationNotice) {
                notificationNotice.href = favicon;
                observer.observe(notificationNotice, {
                    attributes: true,
                    attributeFilter: ['href'],
                });
            }
        });
        observer.observe(notificationNotice, {
            attributes: true,
            attributeFilter: ['href'],
        });
    };
})();