Skip to content

Instantly share code, notes, and snippets.

@dotcomboom
Created August 8, 2021 05:24
Show Gist options
  • Save dotcomboom/723d84386e9cb85aca006a6d5f0b13b6 to your computer and use it in GitHub Desktop.
Save dotcomboom/723d84386e9cb85aca006a6d5f0b13b6 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Neopets: Custom art/aliases
// @namespace http://lince.somnolescent.net
// @version 0.1
// @description Replace the art and name shown for pets on the beta home page
// @author metalynx
// @match http://www.neopets.com
// @match http://www.neopets.com/
// @match http://www.neopets.com//
// @match http://www.neopets.com/index.phtml
// @icon https://www.google.com/s2/favicons?domain=neopets.com
// ==/UserScript==
(function() {
'use strict';
const pets = {
'Apachel': {
'image': 'http://lince.somnolescent.net/creative/art/apache2.png',
'alias': 'Apache'
},
'BeocitiestheSecond': {
'alias': 'Beocities the Second'
},
'belmari': {
'alias': 'Belmari'
}
}
const useAliasInCareDialog = true
// -----
let carousel = document.getElementsByClassName('hp-carousel-pet')
for (let i = 0; i < carousel.length; i++) {
let petName = carousel[i].getAttribute('data-name')
if (petName in pets) {
if ('image' in pets[petName]) {
carousel[i].setAttribute('style', 'background-image: url(\'' + pets[petName].image + '\')')
carousel[i].setAttribute('data-petimage', pets[petName].image)
}
if ('alias' in pets[petName]) {
carousel[i].parentNode.getElementsByClassName('hp-carousel-nameplate')[0].innerText = pets[petName].alias
}
}
}
if (useAliasInCareDialog) {
const dialogTitle = document.getElementById('petCareInfoName')
dialogTitle.addEventListener('DOMSubtreeModified', (event) => {
if (dialogTitle.innerText in pets) {
if ('alias' in pets[dialogTitle.innerText]) {
dialogTitle.innerText = pets[dialogTitle.innerText].alias;
}
}
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment