Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Neopets: Shop Stock Pricer
// ==UserScript==
// @name Neopets: Shop Stock Pricer
// @namespace
// @version 0.2
// @description This script lets you scrape JellyNeo for prices on the shop stock page. Does not auto-submit or otherwise automate activities, though it does send a bunch of search requests to JN when run. Use at your own risk.
// @author metalynx
// @match*
// @match*
// @icon
// @require
// @require
// @grant GM.xmlHttpRequest
// @grant GM_setValue
// ==/UserScript==
(function() {
'use strict';
let offset = -5 // increase/decrease prices a fixed amount
let minprice = 1
axios.defaults.adapter = axiosGmxhrAdapter;
let forms = document.getElementsByTagName('form')
for (let i = 0; i < forms.length; i++) {
if ((forms[i].action) == '') {
var form = forms[i];
var node = document.createElement('a')
node.href = '#autoprice'
node.setAttribute('id', 'autoprice')
var textnode = document.createTextNode(" >>")
node.onclick = function(){
let rows = form.getElementsByTagName('tr')
for (let i = 1; rows.length - 1; i++) { // index is set to 1 to skip the header row "Name", goes to the index just before the bottom Update/Remove All row
let item = rows[i].getElementsByTagName('b')[0].innerHTML
let pricebox = rows[i].getElementsByTagName('input')[2]
//console.log(item + ' is currently set to ' + pricebox.value + ' NP')
axios.get('' + item.replace(' ', '+') + '&name_type=3').then(res => {
let parser = new DOMParser()
let doc = parser.parseFromString(, 'text/html')
let links = doc.getElementsByTagName('a')
let price = 0
for (let i = 1; i < links.length - 1; i++) {
if (links[i].className == 'price-history-link') {
price = parseInt(links[i].innerHTML.replace(',', '').replace(' NP', ''))
console.log('JN PRICE: ' + price + ' NP (' + item + ')')
pricebox.setAttribute('value', Math.max(minprice, price += offset))
Copy link

Zidantur commented Aug 6, 2022

It has something to do with the error on the side I think. Axios is not defined?

Has something to do with these two lines:
axios.defaults.adapter = axiosGmxhrAdapter;

Copy link

I saw that error while digging, but I believe that error appears in Tampermonkey because axios is defined when the script actually runs, not in that window where it's being inspected. There are 2 @require js libraries pointing to axios code at the top, and they seem to be operational.

Just my experience, but I still have the axios error shown, but by emptying my user excludes for the script and preventing automatic updates, it has worked just fine for me.

Copy link

Figured it out. I'm dumb.
Not only do you have to change http to https in lines 7 and 8, you also have to do it in line 27.

Copy link

I've fixed the issue with http but not sure how to use it yet, it seems to be running on tampermonkey but seems to do nothing? @Zidantur @HiroiSekai @dotcomboom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment