Goku/AniWatch Auto Sign

Automatically clicks the Sign In button for Goku.sx and for Aniwatch.to after 10 seconds, and fills in the email and password fields if provided by the user.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name       Goku/AniWatch Auto Sign
// @namespace  http://tampermonkey.net/
// @version    4.5
// @ author    longkidkoolstar
// @description  Automatically clicks the Sign In button for Goku.sx and for Aniwatch.to after 10 seconds, and fills in the email and password fields if provided by the user.
// @match       https://goku.sx/*
// @match      https://aniwatch.to/*
// @grant      GM_getValue
// @grant      GM_setValue
// @license    GPL-3.0
// @icon        https://cdn.dribbble.com/users/289074/screenshots/1614713/sans_titre_-_2.png
// @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
// ==/UserScript==

(function() {
  'use strict';

  function generateRandomKey() {
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    let key = '';
    for (let i = 0; i < 16; i++) {
      key += characters.charAt(Math.floor(Math.random() * characters.length));
    }
    return key;
  }

  function encryptData(data, key) {
    const encrypted = CryptoJS.AES.encrypt(data, key);
    return encrypted.toString();
  }

  function decryptData(encryptedData, key) {
    const decrypted = CryptoJS.AES.decrypt(encryptedData, key);
    return decrypted.toString(CryptoJS.enc.Utf8);
  }

  window.addEventListener('load', function() {
    const emailInput = document.querySelector('input[name="email"]');
    const passwordInput = document.querySelector('input[name="password"]');
    const key = GM_getValue('goku.to.key');

    if (emailInput && passwordInput) {
      const encryptedEmail = localStorage.getItem('goku.to.email');
      const encryptedPassword = localStorage.getItem('goku.to.password');

      if (encryptedEmail && encryptedPassword) {
        const email = decryptData(encryptedEmail, key);
        const password = decryptData(encryptedPassword, key);

        emailInput.value = email;
        passwordInput.value = password;
      } else {
        const newEmail = prompt('Enter your email for the website:', '');
        const newPassword = prompt('Enter your password for the website:', '');
        if (newEmail && newPassword) {
          const newKey = generateRandomKey();
          const encryptedNewEmail = encryptData(newEmail, newKey);
          const encryptedNewPassword = encryptData(newPassword, newKey);

          GM_setValue('goku.to.key', newKey);
          localStorage.setItem('goku.to.email', encryptedNewEmail);
          localStorage.setItem('goku.to.password', encryptedNewPassword);

          emailInput.value = newEmail;
          passwordInput.value = newPassword;
        }
      }
    }

    const button = document.querySelector('.account-button .btn.btn-blank');
    if (button) {
      button.click();
    }
  });

  if (window.location.href.startsWith('https://goku.sx/login')) {
    let secondsToWait = null;
    const storedSeconds = localStorage.getItem('goku.to.autosign.seconds');
    if (storedSeconds !== null) {
      secondsToWait = parseInt(storedSeconds, 10);
    }
    if (!secondsToWait) {
      const input = prompt('Enter the number of seconds to wait before clicking the "Sign In" button. Default is 10 seconds.', '10');
      if (!input) return;
      secondsToWait = parseInt(input, 10);
      if (isNaN(secondsToWait)) {
        secondsToWait = 10;
      }
      localStorage.setItem('goku.to.autosign.seconds', secondsToWait.toString());
    }
    setTimeout(function() {
      const key = GM_getValue('goku.to.key');
      const button = document.querySelector('.btn.btn-block.btn-primary.position-relative');
      if (button) {
        button.click();
      }
    }, secondsToWait * 1000);
  }

})();