Greasy Fork

Greasy Fork is available in English.

YTS - Toggle Foreign Titles

Adds A Button To Toggle Between Displaying English & Foreign Titles Per Page For Easier Viewing (Best For The "Browse All" Section)

当前为 2023-11-21 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        YTS - Toggle Foreign Titles
// @namespace   NooScripts
// @match       https://yts.mx/*
// @grant       none
// @version     1.0
// @author      NooScripts
// @description Adds A Button To Toggle Between Displaying English & Foreign Titles Per Page For Easier Viewing (Best For The "Browse All" Section)
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Delay configuration
    const delayBeforeStart = 1; // Delay in milliseconds (adjust as needed)

    // Function to seperate movie based on content language content
    function hideMovieWraps() {
        // Find all titles
        let movieWraps = document.querySelectorAll('.browse-movie-wrap');

        // Loop through each 'title' element
        movieWraps.forEach(function(movieWrap) {
            // Load sub div'
            let movieBottom = movieWrap.querySelector('.browse-movie-bottom');

            // Check for existing 'title sections'
            if (movieBottom) {
                let movieTitle = movieBottom.querySelector('.browse-movie-title');

                // Check if the 'title' contains []
                if (movieTitle) {
                    let titleSpans = movieTitle.querySelectorAll('span');
                    titleSpans.forEach(function(titleSpan) {
                        let spanContent = titleSpan.innerText.trim();
                        if (spanContent.includes('[') && spanContent.includes(']')) {
                            // Hide the parent 'title' element
                            movieWrap.style.display = 'none';
                        }
                    });
                }
            }
        });
    }

    // Toggle function
    function toggleMovieVisibility() {
        let movieWraps = document.querySelectorAll('.browse-movie-wrap');
        movieWraps.forEach(function(movieWrap) {
            movieWrap.style.display = movieWrap.style.display === 'none' ? 'block' : 'none';
        });
    }

    // Delay before executing the script
    setTimeout(function() {
        hideMovieWraps();

        // Create and append the toggle button
        const toggleButton = document.createElement('button');
        toggleButton.textContent = 'Toggle English/Foreign Titles';
        toggleButton.addEventListener('click', toggleMovieVisibility);
        document.body.appendChild(toggleButton);

        // Button style
        const style = document.createElement('style');
        style.textContent = `
            button {
                position: fixed;
                bottom: 20px;
                right: 20px;
                z-index: 9999;
                padding: 10px;
                background-color: #000000;
                color: #fff;
                border: 1px solid #fff;
                border-radius: 5px;
                cursor: pointer;
                font-size: 12px;
            }
            button:hover {
                background-color: #ffffff;
                color: #000000;
            }
        `;
        document.head.appendChild(style);
    }, delayBeforeStart);
})();