Avatar Linker

Looks up the solution to avatars.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Avatar Linker
// @namespace   Marascripts
// @description Looks up the solution to avatars.
// @author      marascript
// @version     2.0.1
// @grant       none
// @match       https://www.marapets.com/stalker.php*
// @match       https://www.marapets.com/avatars.php?missing=1*
// @homepageURL https://github.com/marascript/userscripts
// @supportURL	https://github.com/marascript/userscripts/issues
// @license     MIT
// ==/UserScript==

/**
 * TODO: Add links to obtained avatars
 * TODO: Refactor functions
 */

;(async () => {
  'use strict'

  if (document.URL.includes('/avatars.php')) {
    const missingAvatars = document.querySelectorAll('#eachitemdiv')

    for (const avatar in missingAvatars) {
      missingAvatars[avatar].style.paddingBottom = '15px'

      if (!missingAvatars[avatar].querySelector('.offline')) {
        const name = missingAvatars[avatar]
          .querySelector('.itempadding .bigger')
          .innerText.replace(/ /g, '+')
        const link = document.createElement('a')
        const linkText = document.createTextNode('Check Solution')

        link.appendChild(linkText)
        link.href = `https://www.maraforce.com/avatars.php?search=${name}`
        link.target = '_blank'
        link.style.color = 'gray'
        link.style.fontWeight = 700

        missingAvatars[avatar].appendChild(link)
      }
    }
  }

  if (document.URL.includes('/stalker.php')) {
    const avatar = document
      .querySelector('.sbigger')
      ?.innerText.split(' Hidden Avatar')[0]

    if (avatar) {
      const urlEncodedAvatar = avatar.replace(/ /g, '+')
      const checkSolution = document.querySelector('.pricecheck').parentElement
      checkSolution.href = `https://www.maraforce.com/avatars.php?search=${urlEncodedAvatar}`
    }
  }
})()