YTS - Toggle Foreign Titles

Adds A Button To Toggle Between Displaying English & Foreign Movies Per Page While Browsing.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        YTS - Toggle Foreign Titles
// @namespace   NooScripts
// @match       https://yts.mx/browse-movies*
// @grant       none
// @version     1.5
// @author      NooScripts
// @description Adds A Button To Toggle Between Displaying English & Foreign Movies Per Page While Browsing.
// @license MIT
// ==/UserScript==

(function() {
  'use strict';

  const delayBeforeStart = 1;

  function hideMovieWraps() {
    let movieWraps = document.querySelectorAll('.browse-movie-wrap');
    movieWraps.forEach(function(movieWrap) {
      let movieBottom = movieWrap.querySelector('.browse-movie-bottom');
      if (movieBottom) {
        let movieTitle = movieBottom.querySelector('.browse-movie-title');
        if (movieTitle) {
          let titleSpans = movieTitle.querySelectorAll('span');
          titleSpans.forEach(function(titleSpan) {
            let spanContent = titleSpan.innerText.trim();
            if (spanContent.includes('[') && spanContent.includes(']')) {
              movieWrap.style.display = 'none';
            }
          });
        }
      }
    });
  }

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

  setTimeout(function() {
    hideMovieWraps();

    const toggleButton = document.createElement('button');
    toggleButton.textContent = '🌎🎥';
    toggleButton.id = 'movieToggleButton'; // Unique ID for the button
    toggleButton.classList.add('movieToggleButton');
    toggleButton.addEventListener('click', toggleMovieVisibility);
    document.body.appendChild(toggleButton);

    const style = document.createElement('style');
    style.textContent = `
      #movieToggleButton {
        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: 18px;
      }
      #movieToggleButton:hover {
        background-color: #ffffff;
        color: #000000;
      }
    `;
    document.head.appendChild(style);
  }, delayBeforeStart);
})();