Pet Pic Replacer A

Basic pet pic replacer proof of concept. Was done quickly at 4 am.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Pet Pic Replacer A
// @namespace    http://tampermonkey.net/
// @version      0.21
// @description  Basic pet pic replacer proof of concept. Was done quickly at 4 am.
// @author       Twiggies
// @match        *://www.grundos.cafe/*
// @exclude     *://www.grundos.cafe/rainbowpool/neopetcolours/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @grant        none
// @license      MIT
// ==/UserScript==

//Species colour image code. Extract from the end of an image url of theirs, after the last slash.
//For example, 'https://grundoscafe.b-cdn.net/pets/circle/kau_rainbow_alt1.gif' you would get 'kau_rainbow_alt1'
const ogCode = 'kau_rainbow_alt1.gif';

//Image URLs of the one that it will be replacing with. Note the names to figure out which expression they're replacing
const circle = 'https://grundoscafe.b-cdn.net/pets/circle/kau_royalgirl.gif';
const happy = 'https://grundoscafe.b-cdn.net/pets/happy/kau_royalgirl.gif';
const sad = 'https://grundoscafe.b-cdn.net/pets/sad/kau_royalgirl.gif';
const angry = 'https://grundoscafe.b-cdn.net/pets/angry/kau_royalgirl.gif';
const beaten = 'https://grundoscafe.b-cdn.net/pets/beaten/kau_royalgirl.gif';
const closeAttack = 'https://grundoscafe.b-cdn.net/pets/closeattack/kau_royalgirl.gif';
const defended = 'https://grundoscafe.b-cdn.net/pets/defended/kau_royalgirl.gif';
const hit = 'https://grundoscafe.b-cdn.net/pets/hit/kau_royalgirl.gif';
const rangedAttack = 'https://grundoscafe.b-cdn.net/pets/rangedattack/kau_royalgirl.gif';

//OG image url building base
const urlBase = 'https://grundoscafe.b-cdn.net/pets/'
const urlBuild = ['circle/', 'happy/', 'sad/','angry/','beaten/','closeattack/','defended/','hit/','rangedattack/']

function replaceImage(og, newImg) {
    const imgList = document.querySelectorAll(`img[src="${og}"]`);
    if (imgList) {
        for (let i = 0; i < imgList.length; i++) {
            imgList[i].src = newImg
        }
    }
}

(function() {
    'use strict';

    replaceImage(urlBase + 'circle/' + ogCode, circle);
    replaceImage(urlBase + 'happy/' + ogCode, happy);
    replaceImage(urlBase + 'sad/' + ogCode, sad);
    replaceImage(urlBase + 'angry/' + ogCode, angry);
    replaceImage(urlBase + 'beaten/' + ogCode, beaten);
    replaceImage(urlBase + 'closeattack/' + ogCode, closeAttack);
    replaceImage(urlBase + 'defended/' + ogCode, defended);
    replaceImage(urlBase + 'hit/' + ogCode, hit);
    replaceImage(urlBase + 'rangedattack/' + ogCode, rangedAttack);

})();