Hentai Heroes SFW

Removing explicit images in Hentai Heroes game and setting all girls / champions poses to the default one.

// ==UserScript==
// @name         Hentai Heroes SFW
// @namespace    https://sleazyfork.org/fr/scripts/539097-hentai-heroes-sfw
// @description  Removing explicit images in Hentai Heroes game and setting all girls / champions poses to the default one.
// @version      1.1.0
// @match        https://*.comixharem.com/*
// @match        https://*.hentaiheroes.com/*
// @match        https://*.pornstarharem.com/*
// @run-at       document-idle
// @grant        none
// @author       Geto_hh
// @license      MIT
// ==/UserScript==

// ==CHANGELOG==
// 1.1.0: Page per page query selectors and optimized girl icons processing on edit team pages 
// 1.0.1: Small fixes
// 1.0.0: Optimize script for release
// 0.6.0: Use only document query selectors and run continously
// 0.5.0: Optimized script for faster processing
// 0.4.0: Stop processing mutations when a 'diamond' or 'speech_bubble_info_icn' class element is clicked
// 0.3.0: Run script only once per page load
// 0.2.0: Added namespace
// 0.1.0: First available version on SleazyFork
// ==/CHANGELOG==

// Pre-compile regular expressions
let DEBUG_ACTIVATED = false;
const DEBUG_LIMIT_ACTIVATED = false;
let debugLimitCount = 0;

const HIDE_BACKGROUND = false;

const NB_OF_GIRL_ICONS_TO_PROCESS_AT_ONCE = 20;
let currentIconIndex = 0;

const girlsWithSFWIndexEqualsOne = ['225777755', '298984036'];

const girlsRegex =
  /(.*\/)([0-9]+)\/([a-zA-Z]+)(\d+)([a-zA-Z0-9-_]*)\.(png|jpg|jpeg|webp|gif|bmp|tiff|svg|ico)$/;

// Activities screen https://www.hentaiheroes.com/activities.html
const activitiesSelectorsOfBackgroundImagesSrcToRemove = ['.contest > .contest_header'];
const activitiesSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
  '.mission_image > img',
  '.pop_thumb > img',
  '.timer-girl-container > img',
];

// Champions screen https://www.hentaiheroes.com/champions/3
const championsSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
  '.champions-animation > .avatar',
  '.champions-animation > .champions-over__champion-image',
  '.defender-preview > img',
  '.attacker-preview > .character',
  '.rounds-info__figures > .figure',
];
const championSelectorsOfGirlsSrcToModify = [
  '.girl-box__draggable > .girl-box__ico',
  '.girl > .avatar',
  '.girl-card > img',
];
const championSelectorsOfGirlsIconsSrcToModify = [];

// Characters screen https://www.hentaiheroes.com/characters/461620826
const charactersSelectorsOfGirlsSrcToModify = [
  '.avatar-box > .avatar',
  '.left > img',
  '.variation_girl > .girl_ava',
  '.team-slot-container > img',
];
const charactersSelectorsOfGirlsIconsSrcToModify = [];

// Club champion screen https://www.hentaiheroes.com/club-champion.html
const clubChampionSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
  '.figure',
  '.girl-fav-position > .favorite-position',
  '.girl-card > .fav-position',
];
const clubChampionSelectorsOfGirlsSrcToModify = [
  '.girl-box__draggable > .girl-box__ico',
  '.girl > .avatar',
  '.girl-card > img',
];
const clubChampionSelectorsOfGirlsIconsSrcToModify = [];

// Edit Labyrinth team screen https://www.hentaiheroes.com/edit-labyrinth-team.html
const editLabyrinthTeamSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.girl-display > .avatar',
];
const editLabyrinthTeamSelectorsOfGirlsIconsSrcToModify = [
  '.harem-girl-container > .girl_img', // all girls => 282 for me
];

// Edit team screen https://www.hentaiheroes.com/edit-team.html
const editTeamSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.girl-display > .avatar',
];
const editTeamSelectorsOfGirlsIconsSrcToModify = ['.harem-girl-container > .girl_img'];

// Edit world boss team screen https://www.hentaiheroes.com/edit-world-boss-team.html
const editWorldBossTeamSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.girl-display > .avatar',
];
const editWorldBossTeamSelectorsOfGirlsIconsSrcToModify = ['.harem-girl-container > .girl_img'];

// Girl screen https://www.hentaiheroes.com/girl/143960742
const girlSelectorsOfGirlsSrcToModify = [
  '#next_girl > img',
  '#previous_girl > img',
  '.girl-skills-avatar > .avatar',
  '.girl-avatar-wrapper > .avatar',
  '.team-slot-container > img',
  '.base-hexagon > .girl_img',
];
const girlSelectorsOfGirlsIconsSrcToModify = [];

// Home screen https://www.hentaiheroes.com/home.html
const homeSelectorsOfGirlsSrcToModify = ['.waifu-container > .avatar'];
const homeSelectorsOfGirlsIconsSrcToModify = [];
const homeSelectorsOfBackgroundImagesSrcToRemove = [
  '#crosspromo_show_ad > .crosspromo_banner',
  '#special-offer',
  '.news_page_content > .news_page_pic',
  '.news_thumb > .news_thumb_pic',
];
const homeSelectorsOfImagesSrcToRemove = [...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : [])];

// Labyrinth screen https://www.hentaiheroes.com/labyrinth.html
const labyrinthSelectorsOfGirlsSrcToModify = ['.relic-infos > .girl-image'];
const labyrinthSelectorsOfGirlsIconsSrcToModify = [];

// Labyrinth battle screen https://www.hentaiheroes.com/labyrinth-battle.html
const labyrinthBattleSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.pvp-girls > .avatar',
];
const labyrinthBattleSelectorsOfGirlsIconsSrcToModify = [];

// Labyrinth pool select screen https://www.hentaiheroes.com/labyrinth-pool-select.html
const labyrinthPoolSelectSelectorsOfGirlsSrcToModify = [];
const labyrinthPoolSelectSelectorsOfGirlsIconsSrcToModify = ['.girl-container > .girl-image'];
const labyrinthPoolSelectSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Labyrinth pre-battle screen https://www.hentaiheroes.com/labyrinth-pre-battle.html
const labyrinthPreBattleSelectorsOfGirlsSrcToModify = ['.base-hexagon > .girl_img'];
const labyrinthPreBattleSelectorsOfGirlsIconsSrcToModify = [];

// League pre-battle screen https://www.hentaiheroes.com/leagues-pre-battle.html
const leaguePreBattleSelectorsOfGirlsSrcToModify = [
  '.girl-block > .avatar',
  '.base-hexagon > .girl_img',
];
const leaguePreBattleSelectorsOfGirlsIconsSrcToModify = [];
const leaguePreBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// League battle screen https://www.hentaiheroes.com/league-battle.html
const leagueBattleSelectorsOfGirlsSrcToModify = [
  '.new-battle-girl-container > .avatar',
  '.base-hexagon > .girl_img',
];
const leagueBattleSelectorsOfGirlsIconsSrcToModify = [];
const leagueBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Login pop-up (no precise url as it can appear on any page)
const loginSelectorsOfImagesSrcToRemove = ['.canvas > .picture'];

// Member progression screen https://www.hentaiheroes.com/member-progression.html
const memberProgressionSelectorsOfImagesSrcToRemove = ['.page-girl > img'];

// Pachinko screen https://www.hentaiheroes.com/pachinko.html
const pachinkoSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
  '.pachinko_img > img',
];

// Pantheon screen https://www.hentaiheroes.com/pantheon.html
const pantheonSelectorsOfGirlsSrcToModify = ['.girl-container > .avatar'];
const pantheonSelectorsOfGirlsIconsSrcToModify = [];
const pantheonSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img', '.pantheon_bgr > .stage-bgr'] : []),
];

// Pantheon battle screen https://www.hentaiheroes.com/pantheon-battle.html
const pantheonBattleSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.new-battle-girl-container > .avatar',
];
const pantheonBattleSelectorsOfGirlsIconsSrcToModify = [];
const pantheonBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Pantheon pre-battle screen https://www.hentaiheroes.com/pantheon-pre-battle.html
const pantheonPreBattleSelectorsOfGirlsSrcToModify = ['.base-hexagon > .girl_img'];
const pantheonPreBattleSelectorsOfGirlsIconsSrcToModify = [];
const pantheonPreBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Season arena screen https://www.hentaiheroes.com/season-arena.html
const seasonArenaSelectorsOfGirlsSrcToModify = ['.base-hexagon > .girl_img'];
const seasonArenaSelectorsOfGirlsIconsSrcToModify = [];
const seasonArenaSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Season battle screen https://www.hentaiheroes.com/season-battle.html
const seasonBattleSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.new-battle-girl-container > .avatar',
];
const seasonBattleSelectorsOfGirlsIconsSrcToModify = [];
const seasonBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Shop pop-up (no precise url as it can be opened with the chest icon on the homepage or the plus icon on any page)
const shopSelectorsOfImagesSrcToRemove = ['.prestige > .avatar'];
const shopSelectorsOfBackgroundImagesSrcToRemove = [
  '.mc-card-container > .rewards-container',
  '.product-offer-container > .product-offer-background-container',
];

// Side quests screen https://www.hentaiheroes.com/side-quests.html
const sideQuestsSelectorsOfImagesSrcToRemove = ['.side-quest-image > img'];

// Teams screen https://www.hentaiheroes.com/teams.html
const teamsSelectorsOfGirlsSrcToModify = [
  '.team-slot-container > img',
  '.base-hexagon > .girl_img',
];
const teamsSelectorsOfGirlsIconsSrcToModify = [];
const teamsSelectorsOfImagesSrcToRemove = ['.girl-image-container > img'];

// Troll battle screen https://www.hentaiheroes.com/troll-battle.html
const trollBattleSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.new-battle-girl-container > .avatar',
];
const trollBattleSelectorsOfGirlsIconsSrcToModify = [];
const trollBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Troll pre-battle screen https://www.hentaiheroes.com/troll-pre-battle.html
const trollPreBattleSelectorsOfGirlsSrcToModify = ['.base-hexagon > .girl_img'];
const trollPreBattleSelectorsOfGirlsIconsSrcToModify = [];
const trollPreBattleSelectorsOfImagesSrcToRemove = [
  ...(HIDE_BACKGROUND ? ['.fixed_scaled > img'] : []),
];

// Main quest troll screens https://www.hentaiheroes.com/world/12
const worldSelectorsOfImagesSrcToRemove = ['.troll_world > .troll-tier-img'];

// World boss battle screen https://www.hentaiheroes.com/world-boss-battle.html
const worldBossBattleSelectorsOfGirlsSrcToModify = [
  '.base-hexagon > .girl_img',
  '.pvp-girls > .avatar',
];
const worldBossBattleSelectorsOfGirlsIconsSrcToModify = [];

// World boss event screen https://www.hentaiheroes.com/world-boss-event
const worldBossEventSelectorsOfImagesSrcToRemove = ['.right-container > .avatar'];

// World boss pre-battle screen https://www.hentaiheroes.com/world-boss-pre-battle
const worldBossEventPreBattleSelectorsOfGirlsSrcToModify = ['.base-hexagon > .girl_img'];
const worldBossEventPreBattleSelectorsOfGirlsIconsSrcToModify = [];

let observer;

function initObserver() {
  if (!observer) {
    // Use MutationObserver to watch for dynamically loaded images
    observer = new MutationObserver(function (mutations) {
      mutations.forEach(function () {
        processMediaUrls();
      });
    });
  }

  // Start observing the main document
  if (observer) {
    observer.observe(document.body, { childList: true, subtree: true });
  }
}

function killObserver() {
  if (observer) {
    observer.disconnect();
    observer = null;
  }
}

function processBackgroundImagesSrcToRemove(selectorsOfBackgroundImagesSrcToRemove) {
  if (DEBUG_ACTIVATED) {
    console.log('> PROCESSING BACKGROUND IMAGES SRC TO REMOVE');
  }
  const elements =
    selectorsOfBackgroundImagesSrcToRemove.length > 0
      ? document.querySelectorAll(selectorsOfBackgroundImagesSrcToRemove.join(', '))
      : [];
  let nbOfElementsProcessed = 0;
  if (DEBUG_ACTIVATED && elements.length > 0) {
    console.log('> nb of elements:', elements.length);
  }
  elements.forEach((element) => {
    if (element && element.style) {
      element.style.backgroundImage = 'none';
      element.style['background-image'] = 'none';
      nbOfElementsProcessed++;
    }
  });
  if (DEBUG_ACTIVATED) {
    console.log('> nb of elements processed:', nbOfElementsProcessed);
  }
}

function processGirlImagesSrcToModify(
  selectorsOfGirlsSrcToModify,
  selectorsOfGirlsIconsSrcToModify,
) {
  if (DEBUG_ACTIVATED) {
    console.log('> PROCESSING GIRLS SRC TO MODIFY');
  }

  const baseElements =
    selectorsOfGirlsSrcToModify.length > 0
      ? document.querySelectorAll(selectorsOfGirlsSrcToModify.join(', '))
      : [];

  const iconElements =
    selectorsOfGirlsIconsSrcToModify.length > 0
      ? document.querySelectorAll(selectorsOfGirlsIconsSrcToModify.join(', '))
      : [];

  const totalIconElements = iconElements.length;
  const processIconElements = totalIconElements > 0;
  const elements = baseElements.length > 0 ? Array.from(baseElements) : [];

  const startIndex = currentIconIndex;
  const endIndex = Math.min(startIndex + NB_OF_GIRL_ICONS_TO_PROCESS_AT_ONCE, totalIconElements);
  const batchedIconElements = Array.from(iconElements).slice(startIndex, endIndex);

  currentIconIndex = endIndex >= totalIconElements ? 0 : endIndex;

  if (DEBUG_ACTIVATED) {
    console.log('> nb of baseElements:', elements.length);
    console.log('> nb of iconElements:', totalIconElements);
    console.log('> nb of batchedIconElements:', batchedIconElements.length);
    console.log('> current batch (start, end):', startIndex, endIndex);
  }

  let nbOfElementsProcessed = 0;
  elements.forEach((element) => {
    if (element && element.src && !element.src.includes('grade_skins')) {
      const baseSrc = element.src.split('?')[0];
      const newSrc = baseSrc.replace(girlsRegex, function (match, p1, p2, p3, p4, p5, p6) {
        const sfwIndex = girlsWithSFWIndexEqualsOne.includes(p2) ? '1' : '0';
        return p4 === sfwIndex ? match : p1 + p2 + '/' + p3 + sfwIndex + p5 + '.' + p6;
      });

      if (newSrc !== baseSrc) {
        if (DEBUG_ACTIVATED) {
          console.log('> altering girl src from:', element.outerHTML);
        }
        element.src = newSrc;
        nbOfElementsProcessed++;
      }
    }
  });
  if (DEBUG_ACTIVATED) {
    console.log('> nb of elements processed:', nbOfElementsProcessed);
  }

  if (processIconElements) {
    setTimeout(() => {
      let nbOfIconElementsProcessed = 0;
      batchedIconElements.forEach((element) => {
        if (element && element.src && !element.src.includes('grade_skins')) {
          const baseSrc = element.src.split('?')[0];
          const newSrc = baseSrc.replace(girlsRegex, function (match, p1, p2, p3, p4, p5, p6) {
            const sfwIndex = girlsWithSFWIndexEqualsOne.includes(p2) ? '1' : '0';
            return p4 === sfwIndex ? match : p1 + p2 + '/' + p3 + sfwIndex + p5 + '.' + p6;
          });

          if (newSrc !== baseSrc) {
            if (DEBUG_ACTIVATED) {
              console.log('> altering girl icon src from:', element.outerHTML);
            }
            element.src = newSrc;
            nbOfIconElementsProcessed++;
          }
        }
      });
      if (DEBUG_ACTIVATED) {
        console.log('> nb of icon elements processed:', nbOfIconElementsProcessed);
      }
      if (batchedIconElements.length > 0 && nbOfIconElementsProcessed === 0) {
        killObserver();
      }
    }, 0);
  }
}

function processImagesSrcToRemove(selectorsOfImagesSrcToRemove) {
  if (DEBUG_ACTIVATED) {
    console.log('> PROCESSING IMAGES SRC TO REMOVE');
  }
  const elements =
    selectorsOfImagesSrcToRemove.length > 0
      ? document.querySelectorAll(selectorsOfImagesSrcToRemove.join(', '))
      : [];
  let nbOfElementsProcessed = 0;
  if (DEBUG_ACTIVATED && elements.length > 0) {
    console.log('> nb of elements:', elements.length);
  }
  elements.forEach((element) => {
    if (element && element.src) {
      element.src = '';
      nbOfElementsProcessed++;
    }
  });
  if (DEBUG_ACTIVATED) {
    console.log('> nb of elements processed:', nbOfElementsProcessed);
  }
}

// Function to process image URLs
function processMediaUrls() {
  if (DEBUG_LIMIT_ACTIVATED) {
    debugLimitCount++;
    if (debugLimitCount > 3) {
      DEBUG_ACTIVATED = false;
    }
  }

  // Shop pop-up image processing
  if (DEBUG_ACTIVATED) {
    console.log(' ');
    console.log('> ALL PAGES');
  }
  processBackgroundImagesSrcToRemove(shopSelectorsOfBackgroundImagesSrcToRemove);
  processImagesSrcToRemove([
    ...loginSelectorsOfImagesSrcToRemove,
    ...shopSelectorsOfImagesSrcToRemove,
  ]);

  if (window.location.href.includes('/activities.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> ACTIVITIES PAGE');
    }

    processBackgroundImagesSrcToRemove(activitiesSelectorsOfBackgroundImagesSrcToRemove);
    processImagesSrcToRemove(activitiesSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/champions/')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> CHAMPIONS PAGE');
    }

    processImagesSrcToRemove(championsSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      championSelectorsOfGirlsSrcToModify,
      championSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/characters/')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> CHARACTERS PAGE');
    }

    processGirlImagesSrcToModify(
      charactersSelectorsOfGirlsSrcToModify,
      charactersSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/club-champion.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> CLUB CHAMPION PAGE');
    }

    processImagesSrcToRemove(clubChampionSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      clubChampionSelectorsOfGirlsSrcToModify,
      clubChampionSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/edit-labyrinth-team.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> EDIT LABYRINTH TEAM PAGE');
    }

    processGirlImagesSrcToModify(
      editLabyrinthTeamSelectorsOfGirlsSrcToModify,
      editLabyrinthTeamSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/edit-team.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> EDIT TEAM PAGE');
    }

    processGirlImagesSrcToModify(
      editTeamSelectorsOfGirlsSrcToModify,
      editTeamSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/edit-world-boss-team.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> EDIT WORLD BOSS TEAM PAGE');
    }

    processGirlImagesSrcToModify(
      editWorldBossTeamSelectorsOfGirlsSrcToModify,
      editWorldBossTeamSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/girl/')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> GIRL PAGE');
    }

    processGirlImagesSrcToModify(
      girlSelectorsOfGirlsSrcToModify,
      girlSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/home.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> HOME PAGE');
    }

    processImagesSrcToRemove(homeSelectorsOfImagesSrcToRemove);
    processBackgroundImagesSrcToRemove(homeSelectorsOfBackgroundImagesSrcToRemove);
    processGirlImagesSrcToModify(
      homeSelectorsOfGirlsSrcToModify,
      homeSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/labyrinth.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> LABYRINTH PAGE');
    }

    processGirlImagesSrcToModify(
      labyrinthSelectorsOfGirlsSrcToModify,
      labyrinthSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/labyrinth-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> LABYRINTH BATTLE PAGE');
    }

    processGirlImagesSrcToModify(
      labyrinthBattleSelectorsOfGirlsSrcToModify,
      labyrinthBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/labyrinth-pool-select.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> LABYRINTH POOL SELECT PAGE');
    }

    processImagesSrcToRemove(labyrinthPoolSelectSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      labyrinthPoolSelectSelectorsOfGirlsSrcToModify,
      labyrinthPoolSelectSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/labyrinth-pre-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> LABYRINTH PRE-BATTLE PAGE');
    }

    processGirlImagesSrcToModify(
      labyrinthPreBattleSelectorsOfGirlsSrcToModify,
      labyrinthPreBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/league-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> LEAGUE BATTLE PAGE');
    }

    processImagesSrcToRemove(leagueBattleSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      leagueBattleSelectorsOfGirlsSrcToModify,
      leagueBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/leagues-pre-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> LEAGUE PRE-BATTLE PAGE');
    }

    processImagesSrcToRemove(leaguePreBattleSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      leaguePreBattleSelectorsOfGirlsSrcToModify,
      leaguePreBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/member-progression.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> MEMBER PROGRESSION PAGE');
    }

    processImagesSrcToRemove(memberProgressionSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/pachinko.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> PACHINKO PAGE');
    }

    processImagesSrcToRemove(pachinkoSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/pantheon.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> PANTHEON PAGE');
    }

    processGirlImagesSrcToModify(
      pantheonSelectorsOfGirlsSrcToModify,
      pantheonSelectorsOfGirlsIconsSrcToModify,
    );
    processImagesSrcToRemove(pantheonSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/pantheon-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> PANTHEON BATTLE PAGE');
    }

    processGirlImagesSrcToModify(
      pantheonBattleSelectorsOfGirlsSrcToModify,
      pantheonBattleSelectorsOfGirlsIconsSrcToModify,
    );
    processImagesSrcToRemove(pantheonBattleSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/pantheon-pre-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> PANTHEON PRE-BATTLE PAGE');
    }

    processGirlImagesSrcToModify(
      pantheonPreBattleSelectorsOfGirlsSrcToModify,
      pantheonPreBattleSelectorsOfGirlsIconsSrcToModify,
    );
    processImagesSrcToRemove(pantheonPreBattleSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/season-arena.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> SEASON ARENA PAGE');
    }

    processImagesSrcToRemove(seasonArenaSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      seasonArenaSelectorsOfGirlsSrcToModify,
      seasonArenaSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/season-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> SEASON BATTLE PAGE');
    }

    processImagesSrcToRemove(seasonBattleSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      seasonBattleSelectorsOfGirlsSrcToModify,
      seasonBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/side-quests.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> SIDE QUESTS PAGE');
    }

    processImagesSrcToRemove(sideQuestsSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/teams.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> TEAMS PAGE');
    }

    processImagesSrcToRemove(teamsSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      teamsSelectorsOfGirlsSrcToModify,
      teamsSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/troll-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> TROLL BATTLE PAGE');
    }

    processImagesSrcToRemove(trollBattleSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      trollBattleSelectorsOfGirlsSrcToModify,
      trollBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/troll-pre-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> TROLL PRE-BATTLE PAGE');
    }

    processImagesSrcToRemove(trollPreBattleSelectorsOfImagesSrcToRemove);
    processGirlImagesSrcToModify(
      trollPreBattleSelectorsOfGirlsSrcToModify,
      trollPreBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/world/')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> WORLD PAGE');
    }

    processImagesSrcToRemove(worldSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/world-boss-battle.html')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> WORLD BOSS BATTLE PAGE');
    }

    processGirlImagesSrcToModify(
      worldBossBattleSelectorsOfGirlsSrcToModify,
      worldBossBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }

  if (window.location.href.includes('/world-boss-event')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> WORLD BOSS EVENT PAGE');
    }

    processImagesSrcToRemove(worldBossEventSelectorsOfImagesSrcToRemove);
  }

  if (window.location.href.includes('/world-boss-pre-battle')) {
    if (DEBUG_ACTIVATED) {
      console.log(' ');
      console.log('> WORLD BOSS PRE-BATTLE PAGE');
    }

    processGirlImagesSrcToModify(
      worldBossEventPreBattleSelectorsOfGirlsSrcToModify,
      worldBossEventPreBattleSelectorsOfGirlsIconsSrcToModify,
    );
  }
}

processMediaUrls();
initObserver();

// Add event listener to stop observing when specific class elements are clicked
document.addEventListener('click', function (event) {
  if (
    event.target.classList.contains('diamond') ||
    event.target.classList.contains('speech_bubble_info_icn')
  ) {
    if (DEBUG_ACTIVATED) {
      console.log('');
      console.log('> OBSERVER STOPPED');
    }
    killObserver();
    if (DEBUG_ACTIVATED) {
      console.log(
        'MutationObserver disconnected due to click on diamond or speech_bubble_info_icn class.',
      );
    }
  } else {
    processMediaUrls();
  }
});