Greasy Fork

Greasy Fork is available in English.

只显示中文翻译

一个移除subtitlecat字幕网站的其他语言翻译只显示中文翻译的的脚本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         只显示中文翻译
// @namespace    http://greasyfork.icu/zh-CN/users/1361855-fourth-master
// @version      1.0
// @description  一个移除subtitlecat字幕网站的其他语言翻译只显示中文翻译的的脚本
// @author       Fourth_Master
// @match        https://www.subtitlecat.com/subs/*
// @grant        none
// @license         GNU General Public License v3.0 or later
// @namespace       http://greasyfork.icu/scripts/531977
// @supportURL      http://greasyfork.icu/scripts/531977
// @homepageURL     http://greasyfork.icu/scripts/531977
// ==/UserScript==

(function() {
    'use strict';

    // 等待页面加载完成
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initScript);
    } else {
        initScript();
    }

    function initScript() {

        try {
            // 创建一个MutationObserver来监视DOM变化
            const observer = new MutationObserver((mutations) => {
                removeTranslationDivs();
            });

            // 配置observer
            const config = {
                childList: true,
                subtree: true
            };

            // 开始观察
            observer.observe(document.body, config);

            // 初始执行一次
            removeTranslationDivs();
        } catch (error) {
            console.error('初始化脚本时发生错误:', error);
        }
    }

    // 移除翻译div的主函数
    function removeTranslationDivs() {
        const divs = document.querySelectorAll('div.col-md-6.col-lg-4');
        divs.forEach(div => {
            // 检查div内部是否包含特定结构
            if (div.querySelector('.sub-single') &&
                div.querySelector('img.flag') &&
                (div.querySelector('.green-link') || div.querySelector('#voting_') || div.querySelector('.yellow-link'))) {
                // 检查是否包含"Chinese (Simplified)"文本
                const hasChineseText = Array.from(div.querySelectorAll('span')).some(span =>
                    span.textContent.includes('Chinese (Simplified)'));
                if (!hasChineseText) {
                    div.remove();
                    console.log('已移除非中文翻译div:', div.textContent);
                }
            }
        });
    }

    // 初始执行一次
    removeTranslationDivs();
})();