Skip to content

Instantly share code, notes, and snippets.

@dotcomboom
Last active March 10, 2020 03:44
Show Gist options
  • Save dotcomboom/ba118a4b6adceda9b7dd3537f9b6d1f6 to your computer and use it in GitHub Desktop.
Save dotcomboom/ba118a4b6adceda9b7dd3537f9b6d1f6 to your computer and use it in GitHub Desktop.
Neopets userscript, very early version probably. Tested with https://github.com/janekptacijarabaci/greasemonkey/releases/tag/3.31.4Fork on Pale Moon.
// ==UserScript==
// @name Old Pets (Sidebar/lookups, config needed)
// @namespace neopets.com
// @include http://www.neopets.com/*
// @version 1
// @grant none
// ==/UserScript==
// Here's the manual bit, in case you want the right color to show up instead of just yellow. Add an entry for each pet name.
// Keep it lowercase for the sake of convenience.
var pets = {
'beocitiesthesecond': 'yellow',
'belmari': 'red',
'bzward': 'green'
} // (Basic, easier to configure-ish but doesn't show on lookups and stuff. If you do the one below you don't need this.)
// Advanced, but goes further across the site; replace certain image URLs with the old ones.
// Key is the current pose URL, value is species_color.
var images = {
'http://pets.neopets.com/cp/o5ml3qwc/1/2.png': 'kougra_red',
'http://pets.neopets.com/cp/sc2hhvhn/1/2.png': 'bori_yellow',
'http://pets.neopets.com/cp/schfx5c4/1/2.png': 'buzz_green'
}
// (config ends)
var all = document.getElementsByTagName('img')
for (var i = 0, max = all.length; i < max; i++) {
if (all[i].src in images) {
console.log(all[i].src)
var img = 'http://images.neopets.com/pets/happy/' + images[all[i].src] + '_baby.gif'
console.log(img)
all[i].src = img
}
}
// Do sidebar stuff
var colour = 'yellow'; // I'm only using the spelling because the site's Welsh I swear.
var name = document.querySelector('td.sidebarHeader > a > b').innerHTML.toLowerCase()
try {
colour = pets[name];
}
catch(error) {
document.title = document.title + ' [Unknown pet]' // this doesn't work atm
console.error(error);
}
var species = document.querySelector('td.activePetInfo > table > tbody > tr > td[align="left"] > b').innerHTML.toLowerCase()
var image = document.querySelector('td.activePet > a > img')
image.src = 'http://images.neopets.com/pets/happy/' + species + '_' + colour + '_baby.gif'
image.width = 150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment