Greasy Fork

Host-Selector

在aniworld.to和s.to网站上增强了GUI,让您可以轻松选择并自动打开首选的视频主机。页面右下角会出现一个方便的绿色按钮,提示您点击并从用户友好的下拉菜单中选择所需的主机。选择您喜欢的主机,享受无缝的视频流媒体!

目前为 2023-07-16 提交的版本。查看 最新版本

// ==UserScript==
// @name Host-Selector
// @version 1.1
// @description Enhanced GUI for aniworld.to and s.to websites, allowing you to effortlessly choose your preferred video host and have it automatically opened. A convenient green button positioned at the bottom right corner of the page will appear, prompting you to click and select your desired host from a user-friendly drop-down menu. Enjoy seamless video streaming with the host of your choice!
// @description:de Verbesserte Benutzeroberfläche für die Websites aniworld.to und s.to, die es Ihnen ermöglicht, ganz einfach Ihren bevorzugten Video-Host auszuwählen und automatisch zu öffnen. Ein praktischer grüner Button unten rechts auf der Seite wird angezeigt und fordert Sie dazu auf, darauf zu klicken und Ihren gewünschten Host aus einem benutzerfreundlichen Dropdown-Menü auszuwählen. Genießen Sie ein nahtloses Video-Streaming mit dem Host Ihrer Wahl!
// @description:es Interfaz de usuario mejorada para los sitios web aniworld.to y s.to, que le permite elegir fácilmente su host de video preferido y abrirlo automáticamente. Aparecerá un práctico botón verde en la esquina inferior derecha de la página, que le pedirá que haga clic y seleccione su host preferido en un menú desplegable fácil de usar. ¡Disfrute del streaming de video sin interrupciones con el host de su elección!
// @description:fr Interface graphique améliorée pour les sites aniworld.to et s.to, vous permettant de choisir facilement votre hébergeur vidéo préféré et de l'ouvrir automatiquement. Un bouton pratique vert sera positionné en bas à droite de la page, vous invitant à cliquer dessus et à sélectionner votre hébergeur préféré dans un menu déroulant convivial. Profitez du streaming vidéo fluide avec l'hébergeur de votre choix !
// @description:it GUI migliorata per i siti web aniworld.to e s.to, che ti consente di selezionare facilmente il tuo host video preferito e aprirlo automaticamente. Comparirà un comodo pulsante verde posizionato in basso a destra della pagina, che ti inviterà a fare clic e selezionare il tuo host desiderato da un menu a discesa facile da usare. Goditi lo streaming video senza problemi con l'host che preferisci!
// @description:ru Улучшенный интерфейс для веб-сайтов aniworld.to и s.to, позволяющий легко выбирать предпочитаемый видеохост и автоматически его открывать. Удобная зеленая кнопка, расположенная в правом нижнем углу страницы, появится, приглашая вас нажать и выбрать желаемый хост из удобного раскрывающегося меню. Наслаждайтесь плавным видеопросмотром с выбранным хостом!
// @description:zh-CN 在aniworld.to和s.to网站上增强了GUI,让您可以轻松选择并自动打开首选的视频主机。页面右下角会出现一个方便的绿色按钮,提示您点击并从用户友好的下拉菜单中选择所需的主机。选择您喜欢的主机,享受无缝的视频流媒体!
// @author       𝕭𝖚𝖉𝖚𝖒𝖟
// @icon https://w0.peakpx.com/wallpaper/40/813/HD-wallpaper-walpaper-zedge.jpg
// @match https://aniworld.to/*
// @match https://s.to/serie/stream/*
// @grant GM_addStyle
// @namespace http://tampermonkey.net/
// ==/UserScript==

(function () {
    'use strict';

    // Function to create and show the GUI pop-up
    function createGUI() {
        const popupDiv = document.createElement('div');
        popupDiv.innerHTML = `
      <div style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; padding: 20px; border: 1px solid #ccc;">
        <h2>Hoster Selection</h2>
        <label for="hosterSelect">Select a Hoster:</label>
        <select id="hosterSelect">
          <option value="VOE">VOE</option>
          <option value="Doodstream">Doodstream</option>
          <option value="Vidoza">Vidoza</option>
          <option value="Streamtape">Streamtape</option>
        </select>
        <br />
        <h2>Preferred Hoster</h2>
        <label for="preferredHoster">Set your preferred Hoster:</label>
        <select id="preferredHoster">
          <option value="">None</option>
          <option value="VOE">VOE</option>
          <option value="Doodstream">Doodstream</option>
          <option value="Vidoza">Vidoza</option>
          <option value="Streamtape">Streamtape</option>
        </select>
        <br />
        <button id="submitButton">Submit</button>
        <button id="closeButton">Close</button>
      </div>
    `;
      document.body.appendChild(popupDiv);

      // Check if there's a previously selected hoster in localStorage and pre-select it
      const storedHoster = localStorage.getItem('selectedHoster');
      const hosterSelect = document.getElementById('hosterSelect');
      if (storedHoster && Array.from(hosterSelect.options).some(option => option.value === storedHoster)) {
          hosterSelect.value = storedHoster;
      }

      // Check if there's a previously selected preferred hoster in localStorage and pre-select it
      const storedPreferredHoster = localStorage.getItem('preferredHoster');
      const preferredHosterSelect = document.getElementById('preferredHoster');
      if (storedPreferredHoster && Array.from(preferredHosterSelect.options).some(option => option.value === storedPreferredHoster)) {
          preferredHosterSelect.value = storedPreferredHoster;
      }

      // Set up event listener for the submit button
      const submitButton = document.getElementById('submitButton');
      submitButton.addEventListener('click', () => {
          const selectedHoster = hosterSelect.value;
          const preferredHoster = preferredHosterSelect.value;

          // Save the selected hoster and preferred hoster in localStorage
          localStorage.setItem('selectedHoster', selectedHoster);
          localStorage.setItem('preferredHoster', preferredHoster);

          // Find the corresponding hoster link and emulate a click for the preferred hoster
          const hosterLinks = document.querySelectorAll('a.watchEpisode');
          for (const link of hosterLinks) {
              const hosterName = link.querySelector('h4').innerText;
              if (hosterName === preferredHoster) {
                  link.querySelector('.hosterSiteVideoButton').click();
                  break;
              }
          }

          // Close the GUI pop-up after selecting and clicking the hoster
          document.body.removeChild(popupDiv);
      });

      // Set up event listener for the close button
      const closeButton = document.getElementById('closeButton');
      closeButton.addEventListener('click', () => {
          // Close the GUI pop-up without taking any action
          document.body.removeChild(popupDiv);
      });
  }

    // Add a button to the page
    function addGUIButton() {
        const button = document.createElement('button');
        button.innerText = 'Open GUI';
        button.style.position = 'fixed';
        button.style.bottom = '20px';
        button.style.right = '20px';
        button.addEventListener('click', createGUI);
        document.body.appendChild(button);
    }

    // Add the CSS styles
    GM_addStyle(`
    button {
      padding: 10px 20px;
      background-color: #4CAF50;
      color: white;
      border: none;
      cursor: pointer;
      border-radius: 4px;
    }
  `);

    // Add the GUI button to the page
    addGUIButton();

    // Auto-select preferred hoster if available
    const storedPreferredHoster = localStorage.getItem('preferredHoster');
    if (storedPreferredHoster) {
        const hosterLinks = document.querySelectorAll('a.watchEpisode');
        for (const link of hosterLinks) {
            const hosterName = link.querySelector('h4').innerText;
            if (hosterName === storedPreferredHoster) {
                link.querySelector('.hosterSiteVideoButton').click();
                break;
            }
        }
    }
})();