Greasy Fork

Greasy Fork is available in English.

隱藏 Mojim 更多更詳盡歌詞

把 Mojim 的更多更詳盡歌詞隱藏起來

目前为 2023-12-22 提交的版本,查看 最新版本

// ==UserScript==
// @name         隱藏 Mojim 更多更詳盡歌詞
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  把 Mojim 的更多更詳盡歌詞隱藏起來
// @author       abc0922001
// @match        https://mojim.com/*
// @grant        none
// @license    MIT
// ==/UserScript==

(function() {
    'use strict';

    // 使用更靈活的選擇器來定位 <a> 標籤
    let linkSelector = "a[href*='mojim.com']"; // 假設所有 Mojim 的連結都包含 'mojim.com'
    let linkElements = document.querySelectorAll(linkSelector);

    linkElements.forEach(linkElement => {
        // 隱藏 <a> 標籤
        linkElement.style.display = 'none';

        // 隱藏特定的 <br> 標籤和文本
        let ddElement = linkElement.closest('dd');
        if (ddElement) {
            let textFound = false;
            ddElement.childNodes.forEach(node => {
                if (node.nodeType === Node.TEXT_NODE && node.textContent.includes('更多更詳盡歌詞 在')) {
                    node.textContent = node.textContent.replace('更多更詳盡歌詞 在', '');
                    textFound = true;
                } else if (textFound && node.nodeName === 'BR') {
                    node.style.display = 'none';
                    textFound = false;
                }
            });
        }
    });
})();