Ani Gamer Age Check Bypass

The script automically select agree when age check appear

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name              Ani Gamer Age Check Bypass
// @name:zh-Tw        動畫瘋年齡確認自動同意
// @description       The script automically select agree when age check appear
// @description:zh-Tw 年齡認證出現時自動選取同意
// @namespace         ani.gamer
// @version           2.1
// @include           https://*ani.gamer.com.tw/animeVideo*
// @include           https://*ani.gamer.com.tw/party.php*
// @license           Beerware
// @compatible firefox 瀏覽器需給予自動撥放影音內容的權限
// ==/UserScript==

/* jshint esversion: 8 */
(async function() {
  // get video node
  function get_video_node() {
    let ani_video = document.getElementById('ani_video');
    let party_video = document.getElementById('partyPlayer');
    return ani_video || party_video
  }

  // click the agree button
  function agreeAnyway() {
    let agreeButton = document.getElementById('adult');
    if (agreeButton) {
      console.log("I AM A GROWN MAN, I'M A BIG ADULT, I CAN DO THIS.");
      agreeButton.click();
    }
  }

  function delay(milliseconds){
      return new Promise(resolve => {
          setTimeout(resolve, milliseconds);
      });
  }

  // wait for ani_video node appear
  let retryCount = 0;
  let video_node = null;

  // check 4 times/second for 20 seconds
  while (retryCount++ < 80) {
    video_node = get_video_node()
    if (video_node) {
      break;
    }
    await delay(250);
  }

  if (!video_node) {
    console.error("Can not get the video node");
    return;
  }

  // add observer on video node
  const config = { childList: true, subtree: false};
  const observer = new MutationObserver(() => agreeAnyway());
  observer.observe(video_node, config);

  // this step is required to prevent the agreeAnyway not trigger if
  // ani_video is fully loaded before observer started
  agreeAnyway();
})();