├── BigPet.user.js
├── Fixed Position SSW.user.js
├── Neopets Add Important Links.user.js
├── Neopets Beta Animation Toggler.user.js
├── Neopets Classic Inventory Header.user.js
├── Neopets Daily Quest Helper.user.js
├── README.md
├── Restock History.user.js
└── Sidebar Always Open.user.js
/BigPet.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Big Pet
3 | // @version 1.0
4 | // @description Make the boards a little nicer with big pet images!
5 | // @author Harvey
6 | // @match http://www.neopets.com/neoboards/*
7 | // @match https://www.neopets.com/neoboards/*
8 | // @grant none
9 | // ==/UserScript==
10 |
11 | GM_addStyle ( `
12 | .postPetInfo {
13 | margin-right: 50% !important;
14 | margin-left: 50% !important;
15 | width:160px;
16 | }
17 | ` );
18 | GM_addStyle ( `
19 | .postPetInfo h4, .postPetInfo p{
20 | text-align:center!important;
21 | }
22 | ` );
23 | GM_addStyle (`
24 | .postAuthorPetIcon img {
25 | margin-left:50%;
26 | }`);
27 | GM_addStyle (`
28 | .postAuthor {
29 | margin-left:25px;
30 | }`);
31 |
32 | GM_addStyle (`
33 | .authorIcon {
34 | margin-top:10px;
35 | }`);
36 |
37 | function getPostAuthorPet()
38 | {
39 | var results = document.getElementsByClassName("postAuthorPetIcon");
40 | for(var i = 0; i < results.length; i++){
41 | var newhtml = results[i].innerHTML.replace("/1.png","/2.png");
42 | newhtml = newhtml.replace("width=\"50\"","");
43 | newhtml = newhtml.replace("height=\"50\"","");
44 | results[i].innerHTML = newhtml;
45 | results[i].outerHTML = results[i].outerHTML + "
";
46 | }
47 | }
48 |
49 | function GM_addStyle(css) {
50 | const style = document.getElementById("GM_addStyleBy8626") || (function() {
51 | const style = document.createElement('style');
52 | style.type = 'text/css';
53 | style.id = "GM_addStyleBy8626";
54 | document.head.appendChild(style);
55 | return style;
56 | })();
57 | const sheet = style.sheet;
58 | sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
59 | }
60 |
61 | getPostAuthorPet();
--------------------------------------------------------------------------------
/Fixed Position SSW.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Fixed Position SSW
3 | // @namespace http://tampermonkey.net/
4 | // @version 0.1
5 | // @description Always keep the SSW and bookmark in fixed location
6 | // @author Harvey
7 | // @match http://www.neopets.com/*
8 | // @match https://www.neopets.com/*
9 | // @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
10 | // @grant GM.setValue
11 | // ==/UserScript==
12 |
13 | GM_addStyle ( `
14 | .navsub-left__2020{
15 | margin-top:10px !important;
16 | }
17 | ` );
18 |
19 | function GM_addStyle(css) {
20 | const style = document.getElementById("GM_addStyleBy8626") || (function() {
21 | const style = document.createElement('style');
22 | style.type = 'text/css';
23 | style.id = "GM_addStyleBy8626";
24 | document.head.appendChild(style);
25 | return style;
26 | })();
27 | const sheet = style.sheet;
28 | sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
29 | }
--------------------------------------------------------------------------------
/Neopets Add Important Links.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Neopets Add Important Links
3 | // @version 1.4
4 | // @description Adds some missing links to the sidebar
5 | // @author Harvey
6 | // @match http://www.neopets.com/*
7 | // @match https://www.neopets.com/*
8 | // @grant none
9 | // ==/UserScript==
10 |
11 | var $ = window.jQuery;
12 |
13 | //returns true if white
14 | //returns false if black
15 | function getLinkHtml(link,icon,text)
16 | {
17 | var linkadd ="" + text +"";
18 | return linkadd;
19 | }
20 |
21 | function addLinks()
22 | {
23 | var addedLinks = "";
24 | var quickref = getLinkHtml("quickref.phtml", "nav-petcentral-icon__2020", "Quickref");
25 | var quickstock = getLinkHtml("quickstock.phtml", "nav-userlookup-icon__2020", "Quickstock");
26 | var custom = getLinkHtml("customise.phtml", "nav-userlookup-icon__2020", "Customization");
27 | var sdb = getLinkHtml("safetydeposit.phtml", "nav-inventory-icon__2020", "Safety Deposit Box");
28 | addedLinks = addedLinks + quickref; //Quickref link
29 | addedLinks = addedLinks + quickstock; //Quickstock link
30 | addedLinks = addedLinks + custom; //Customization link
31 | addedLinks = addedLinks + sdb; //Safety deposit box link
32 |
33 | var addInvLink = ""
34 |
35 | var clock = document.getElementsByClassName("nav-profile-dropdown-clock__2020")[0];
36 |
37 | if (clock != null)
38 | {
39 | var firstSet = document.getElementById("navprofiledropdown__2020");
40 | var newEl = document.createElement('ul');
41 | newEl.innerHTML = addedLinks;
42 | clock.parentNode.insertBefore(newEl, clock.nextSibling.nextSibling);
43 |
44 | var bankLink = document.getElementsByClassName("navsub-right__2020")[0];
45 |
46 |
47 | var invEl = document.createElement('span');
48 | invEl.innerHTML = addInvLink;
49 |
50 | bankLink.insertBefore(invEl, bankLink.children[0]);
51 | }
52 | }
53 |
54 |
55 | addLinks();
56 |
--------------------------------------------------------------------------------
/Neopets Beta Animation Toggler.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Neopets Beta Animation Toggler
3 | // @version 1.1
4 | // @description Ability to turn on or off the neopets animation on the beta site
5 | // @author Harvey
6 | // @match https://www.neopets.com/*
7 | // @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
8 | // @grant GM.setValue
9 | // @grant GM.getValue
10 | // ==/UserScript==
11 |
12 | const animationOnOff = "animationOnOff";
13 | GM_addStyle ( `
14 | #animationCheckArea{
15 | font-size:13px;
16 | background:white;
17 | font-family:verdana;
18 | padding:10px;
19 | border-radius:5px;
20 | }
21 | ` );
22 | GM_addStyle(`
23 | .footer-links__2020{
24 | max-width:450px!important;
25 | }`);
26 | const setAnimationOnOff = async ()=>{
27 | var value = await getAnimationOnOffSetting();
28 |
29 | var footerDiv = document.getElementsByClassName("footer-link__2020")[0];
30 | var checkBox = document.createElement("input");
31 | var checkDiv = document.createElement("div");
32 | var checkText = document.createElement("span");
33 | checkDiv.setAttribute("id", "animationCheckArea");
34 | checkDiv.appendChild(checkBox);
35 | checkDiv.appendChild(checkText);
36 | checkBox.setAttribute("type", "checkbox");
37 | checkBox.addEventListener("click", changeToggle, false);
38 | if(value){
39 | checkBox.setAttribute("checked", "true");
40 | }else{
41 | GM_addStyle ( `
42 | .nav-top-pattern__2020 {
43 | animation: none !important;
44 | }
45 | ` );
46 | }
47 | checkText.textContent="Animation";
48 | if (footerDiv){
49 | footerDiv.parentNode.insertBefore(checkDiv, footerDiv);
50 | }
51 |
52 | }
53 |
54 | //Confirmation for clearing the data
55 | const changeToggle = async (value) =>{
56 | var currvalue = await getAnimationOnOffSetting();
57 | await toggleAnimationOnOff(!currvalue);
58 | }
59 |
60 | const getAnimationOnOffSetting = async ()=>{
61 | const value = await GM.getValue(animationOnOff);
62 | return value;
63 | }
64 |
65 | const toggleAnimationOnOff = async (value)=>{
66 | await GM.setValue(animationOnOff, value);
67 | }
68 |
69 |
70 |
71 | function GM_addStyle(css) {
72 | const style = document.getElementById("GM_addStyle") || (function() {
73 | const style = document.createElement('style');
74 | style.type = 'text/css';
75 | style.id = "GM_addStyle";
76 | document.head.appendChild(style);
77 | return style;
78 | })();
79 | const sheet = style.sheet;
80 | sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
81 | }
82 |
83 | setAnimationOnOff();
--------------------------------------------------------------------------------
/Neopets Classic Inventory Header.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Neopets Classic Inventory Header
3 | // @version 1.2
4 | // @description Creates a classic look to your inventory
5 | // @author Harvey
6 | // @match https://www.neopets.com/inventory.phtml*
7 | // @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
8 | // @grant none
9 | // ==/UserScript==
10 |
11 | addStyle (`
12 | .inv-menulinks {
13 | height:85px;
14 | width:550px!important;
15 | background:url(https://i.imgur.com/EWyJD8I.png) no-repeat center!important;
16 | margin:auto!important;
17 | }`);
18 | addStyle(`
19 | .inv-menulinks li
20 | {
21 | max-width: 50px;
22 | margin:-10px!important;
23 | padding-top:5px;
24 | }`);
25 |
26 | addStyle(`
27 | .inv-menulinks li img
28 | {
29 | width: 50px;
30 | height: 50px;
31 | }`);
32 | addStyle(`
33 | .inv-menulinks li:nth-child(8)
34 | {
35 | padding-left:70px;
36 | padding-bottom:2px;
37 | }
38 | `);
39 | addStyle(`
40 | .inv-menulinks.mobile li:nth-child(6)
41 | {
42 | padding-left:70px;
43 | padding-bottom:2px;
44 | }
45 | `);
46 | addStyle(`
47 | .inv-menulinks.mobile li:nth-child(8)
48 | {
49 | padding-left:0px;
50 | padding-bottom:0px;
51 | }
52 | `);
53 | addStyle(`
54 | .inv-menulinks li img:hover
55 | {
56 | margin-top:-10px;
57 | }
58 | `);
59 | addStyle(`
60 | .middleLink{
61 | position:absolute;
62 | top: 70px;
63 | left: 50%;
64 | transform: translate(-50%, -50%);
65 | }
66 | `);
67 | addStyle(`
68 | @media all and (max-width: 575px) {
69 |
70 | .middleLink{
71 | left: 285px;
72 | }
73 | }
74 | `);
75 | addStyle(`
76 | .middleLink img{
77 | width:40px;
78 | height:40px;}
79 | `);
80 | addStyle(`
81 | .bottomLink{
82 | margin-top:50px;
83 | }
84 | `);
85 | addStyle(`
86 | .topLink img:hover{
87 | margin-top:-10px;
88 | }`);
89 | addStyle(`
90 | .bottomLink img:hover{
91 | margin-top:10px;
92 | }`);
93 | addStyle(`
94 | .inv-log, .inv-safety
95 | {
96 | display:initial!important;
97 | }`);
98 | createImages();
99 |
100 | function createImages()
101 | {
102 | //Inventory Button
103 | let potion = document.createElement("img");
104 | potion.src = "https://i.imgur.com/IZwT8p8.png";
105 |
106 | let gift = document.createElement("img");
107 | gift.src = "https://i.imgur.com/k7OJclv.png";
108 |
109 | let shirt = document.createElement("img");
110 | shirt.src = "https://i.imgur.com/ETxA2Fg.png";
111 |
112 | let chest = document.createElement("img");
113 | chest.src = "https://i.imgur.com/gwWexwt.png";
114 |
115 | let sword = document.createElement("img");
116 | sword.src = "https://i.imgur.com/CnIOZDt.png";
117 |
118 | let shed = document.createElement("img");
119 | shed.src = "https://i.imgur.com/6nlMB6x.png";
120 |
121 | let display = document.createElement("img");
122 | display.src = "https://i.imgur.com/yhHDtVW.png";
123 |
124 | let stamp = document.createElement("img");
125 | stamp.src = "https://i.imgur.com/8PMUQfi.png";
126 |
127 | let card = document.createElement("img");
128 | card.src = "https://i.imgur.com/J4I53P5.png";
129 |
130 | let album = document.createElement("img");
131 | album.src = "https://i.imgur.com/A2EhywO.png";
132 |
133 | let topLink = document.createElement("a");
134 | let statue = document.createElement("img");
135 | topLink.setAttribute('href', 'https://www.neopets.com/objects.phtml');
136 | topLink.setAttribute('class', 'middleLink topLink');
137 | statue.src = "https://i.imgur.com/UkkJ2q2.png";
138 | topLink.append(statue);
139 |
140 | let bottomLink = document.createElement("a");
141 | let shop = document.createElement("img");
142 | bottomLink.setAttribute('href', 'https://www.neopets.com/market.phtml?type=your');
143 | bottomLink.setAttribute('class', 'middleLink bottomLink');
144 | shop.src = "https://i.imgur.com/GqTmyQU.png";
145 | bottomLink.append(shop);
146 |
147 | let lis = document.getElementsByClassName("inv-menulinks")[0].querySelectorAll('li a');
148 | for (let i=0; i < lis.length; i++)
149 | {
150 | lis[i].innerText = "";
151 | }
152 |
153 | lis[0].append(potion);
154 | document.getElementsByClassName("inv-quickstock-icon")[0].setAttribute('src', potion.src);
155 | lis[1].append(gift);
156 | document.getElementsByClassName("inv-transferlog-icon")[0].setAttribute('src', gift.src);
157 | lis[3].append(shirt);
158 | document.getElementsByClassName("inv-transferlog-icon")[1].setAttribute('src', shirt.src);
159 | lis[4].append(chest);
160 | document.getElementsByClassName("inv-transferlog-icon")[2].setAttribute('src', chest.src);
161 | lis[6].append(sword);
162 | document.getElementsByClassName("inv-transferlog-icon")[3].setAttribute('src', sword.src);
163 |
164 | let menuBar = document.getElementsByClassName("inv-menubar")[0];
165 | menuBar.append(topLink);
166 | menuBar.append(bottomLink);
167 |
168 | lis[7].append(shed);
169 | document.getElementsByClassName("inv-transferlog-icon")[4].setAttribute('src', shed.src);
170 | lis[8].append(display);
171 | document.getElementsByClassName("inv-transferlog-icon")[5].setAttribute('src', display.src);
172 | lis[9].append(stamp);
173 | document.getElementsByClassName("inv-transferlog-icon")[6].setAttribute('src', stamp.src);
174 | lis[10].append(card);
175 | document.getElementsByClassName("inv-transferlog-icon")[7].setAttribute('src', card.src);
176 | lis[11].append(album);
177 | document.getElementsByClassName("inv-transferlog-icon")[8].setAttribute('src', album.src);
178 |
179 |
180 | }
181 |
182 |
183 | function addStyle(css) {
184 | const style = document.getElementById("GM_addStyle") || (function() {
185 | const style = document.createElement('style');
186 | style.type = 'text/css';
187 | style.id = "GM_addStyle";
188 | document.head.appendChild(style);
189 | return style;
190 | })();
191 | const sheet = style.sheet;
192 | sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
193 | }
--------------------------------------------------------------------------------
/Neopets Daily Quest Helper.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Neopets Daily Quest Helper
3 | // @namespace http://tampermonkey.net/
4 | // @version 1.3
5 | // @description Add a "Go!" button to aid your daily questing
6 | // @author Harvey
7 | // @match https://www.neopets.com/questlog/
8 | // @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
9 | // @grant none
10 | // ==/UserScript==
11 |
12 | GM_addStyle (`
13 | .button-grid2__2020{
14 | grid-template:auto / repeat(3, 1fr)!important;
15 | }`);
16 |
17 | GM_addStyle (`
18 | .btn-single__2020{
19 | display:inline!important;
20 | }`);
21 |
22 | GM_addStyle (`
23 | .ql-quest-buttons{
24 | text-align: center;
25 | }`);
26 | GM_addStyle (`
27 | .ql-quest-buttons button{
28 | margin: 10px !important;
29 | }`);
30 | function adjustDailyChunks()
31 | {
32 | // Only activate when on the 'Daily Quests' tab
33 | if (sessionStorage.tabActive != 2) return;
34 | var results = document.getElementsByClassName("questlog-quest");
35 | for (var i = 0; i < results.length; i++)
36 | {
37 | var buttons = results[i].getElementsByClassName("ql-quest-buttons")[0];
38 | var helpButton = document.createElement("button");
39 | helpButton.classList.add("button-default__2020");
40 | helpButton.classList.add("btn-single__2020");
41 | helpButton.classList.add("button-yellow__2020");
42 | helpButton.innerHTML = "Go!";
43 |
44 | var questText = results[i].getElementsByClassName("ql-quest-description")[0].innerHTML;
45 |
46 | var linkWrapper = document.createElement("a");
47 | linkWrapper.href = turnQuestTypeToLink(questText);
48 |
49 | console.log("Quest text" + turnQuestTypeToLink(questText));
50 |
51 | linkWrapper.appendChild(helpButton);
52 |
53 | buttons.appendChild(linkWrapper);
54 |
55 |
56 | }
57 | }
58 |
59 | function turnQuestTypeToLink(questText)
60 | {
61 | var quest = questText.toLowerCase();
62 | if (quest.includes("wheel"))
63 | {
64 | if(quest.includes("mediocrity"))
65 | {
66 | return "/prehistoric/mediocrity.phtml";
67 | }
68 | else if (quest.includes("excitement"))
69 | {
70 | return ("/faerieland/wheel.phtml");
71 | }
72 | else if (quest.includes("misfortune"))
73 | {
74 | return ("/halloween/wheel/index.phtml");
75 | }
76 | else if (quest.includes("knowledge"))
77 | {
78 | return ("/medieval/knowledge.phtml");
79 | }
80 | }
81 | else if (quest.includes("purchase"))
82 | {
83 | return ("/generalstore.phtml");
84 | }
85 | else if (quest.includes("game"))
86 | {
87 | return ("/games.phtml");
88 | }
89 | else if (quest.includes("customise"))
90 | {
91 | return("/customise.phtml");
92 | }
93 |
94 | return "/inventory.phtml";
95 | }
96 |
97 | function observeChanges()
98 | {
99 | // The div is now blank on page load. Create a MutationObserver to detect changes.
100 | const targetNode = document.getElementById("QuestLogContent");
101 | const config = { childList: true };
102 | const contentObserver = new MutationObserver(adjustDailyChunks);
103 | contentObserver.observe(targetNode, config);
104 | }
105 | observeChanges();
106 |
107 |
108 | function GM_addStyle(css) {
109 | const style = document.getElementById("GM_addStyleBy8626") || (function() {
110 | const style = document.createElement('style');
111 | style.type = 'text/css';
112 | style.id = "GM_addStyleBy8626";
113 | document.head.appendChild(style);
114 | return style;
115 | })();
116 | const sheet = style.sheet;
117 | sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
118 | }
119 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # neopets-user-scripts
2 | A collection of userscripts for making your neopets prettier
3 |
4 | ## Installation
5 |
6 | You'll need tampermonkey or another script addon for your browser to use.
7 |
8 | Click the "raw" text to get a pretty install option.
9 |
10 | ## Big Pet
11 | 
12 |
13 | **NOTE**: Because this makes images load large it might take more time to load if you're on a super sluggish connection, keep this in mind!
14 |
15 | * Increases the size of pet images on the forums to full size
16 |
17 | * Centers pet names and aligns usernames a little
18 |
19 | ## Neopets Classic Inventory Header
20 | 
21 | * Replaces the desktop inventory link bar with images in a style that is similar (not exactly the same) to the classic headerbar
22 | * Adds two middle links to fit the format, top sends you to neopia central and bottom sends you to your shop stock page
23 | * Easily adjustable in the code to your own custom images (and the center options can be adjusted to be whatever links you want)
24 |
25 | ## Neopets Daily Quest Helper
26 | 
27 | * Adds a "Go!" button to help you go where you need to go to finish your daily quests!
28 |
29 | ## Neopets Add Important links
30 |
31 | 
32 | 
33 |
34 | * Adds an inventory link on your top bar
35 |
36 | * Adds the following links to your lefthand navigation
37 |
38 | -Quickref
39 |
40 | -Quickstock
41 |
42 | -Customization
43 |
44 | -Safety Deposit Box
45 |
46 | You can comment out any of these lines if you want to remove one:
47 |
48 | 
49 |
50 | ## Sidebar Always Open
51 |
52 | **NOTE**: Because this is doing some extra loading you should probably turn it off when you're trying to restock, just in case it causes more overhead and makes you lose out on an item!
53 |
54 | * Gives you the ability to toggle on and off the left sidebar, and it will remember your choice (keep it open or keep it closed)
55 | * Removes the whole page darkening effect when the sidebar is open
56 |
57 | ## Restock Tracker
58 | 
59 |
60 | **IMPORTANT:** This user script gives NO ADVANTAGE to restocking. It only runs on a successful haggle page and your shop, and simply saves a piece of data when you've made a purchase at a shop.
61 | You need to then manually enter when you sell the item (from your shop page).
62 |
63 | * Logs your item, purchase price, and date when you make a purchase on a neopets shop
64 | * Shows shop purchases under the "Sales History" tab of your shop
65 | * Ability to enter the sell price
66 | * Auto calculates your profits and keeps a running "Total Profit" history log
67 | * Clear items manually or with a quick button to remove all. Save history defaults to max of 30, once you reach this items will start being removed from the log.
68 | * Saves monthly total profit history
69 |
70 | ## Fixed Position SSW
71 | Keeps your SSW and bookmarks always on screen when the page scrolls down instead of hiding behind the top bar.
72 | Recommended you use this with "Sidebar Always Open" so that they don't overlap stuff on the screen.
73 |
74 | ## Neopets Beta Animation Toggler
75 |
76 | 
77 |
78 | * Adds a checkbox on the bottom bar that lets you turn off the beta animation for the birthday site theme
79 |
--------------------------------------------------------------------------------
/Restock History.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Restock History
3 | // @version 2.4
4 | // @description Track your neopets restocks
5 | // @author Harvey
6 | // @match https://www.neopets.com/haggle.phtml
7 | // @match https://www.neopets.com/market.phtml?type=sales
8 | // @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
9 | // @grant GM.setValue
10 | // @grant GM.getValue
11 | // @grant GM.log
12 | // ==/UserScript==
13 |
14 |
15 | (async () => {
16 |
17 | const dataStorage = "restockTrackerData";
18 | const idSave = "idSaveData";
19 | const maxSaves = 100;
20 | const foreverProfit = "foreverProfitData";
21 | const profitByMonth = "profitByMonth";
22 | var dropOpen = false;
23 | var dropOpenedBefore = false;
24 |
25 | //Check if we've successfully haggled an item
26 | const checkForHaggleWin = async ()=> {
27 | const addedText = "has been added to your inventory";
28 |
29 | var container = document.getElementById("container__2020");
30 | var successful = container.innerHTML.includes(addedText);
31 |
32 | if (successful){ //Haggle was a success!
33 |
34 | var pItems = container.getElementsByTagName("p");
35 |
36 | var haggleitem = container.getElementsByClassName("haggle-item");
37 | if (!haggleitem[0]){
38 | //Handle Trading Card Shop which has a different image box
39 | haggleitem = container.getElementsByClassName("haggle-tcg");
40 | }
41 |
42 | var itemImageDiv = haggleitem[0];
43 | const styles = window.getComputedStyle(itemImageDiv);
44 | var itemImageUrl = styles.backgroundImage.slice(5, -2);
45 |
46 |
47 | var itemPriceP = pItems[1]; //P item that contains item price
48 | var itemPrice = itemPriceP.getElementsByTagName("b")[1];
49 |
50 | var itemNameP = pItems[2]; //P item that contains item name
51 | var itemName = itemNameP.getElementsByTagName("b")[0];
52 |
53 | const itemData = await getSavedItems();
54 |
55 | var buyPrice = Number(itemPrice.innerHTML);
56 |
57 | var today = new Date();
58 |
59 | const item = {
60 | id: await getUpdateNextUnusedId(),
61 | name: itemName.innerHTML,
62 | buyprice: buyPrice,
63 | image: itemImageUrl,
64 | sold: false,
65 | sellprice: 0,
66 | timestamp: today.getTime(),
67 | soldtime: null
68 | }
69 |
70 | itemData.unshift(item); //Add item to list
71 |
72 |
73 | GM.setValue(dataStorage, JSON.stringify(itemData));
74 |
75 |
76 | await updateForeverProfit(-buyPrice);
77 | await setProfitPerMonth(-buyPrice, today.getMonth(), today.getYear());
78 | }
79 | }
80 |
81 |
82 | const getUpdateNextUnusedId = async () =>{
83 | const id = await GM.getValue(idSave);
84 | var newId;
85 | if (isNaN(id))
86 | {
87 | newId = 0;
88 | }
89 | else{
90 | newId = id + 1;
91 | }
92 |
93 |
94 | GM.setValue(idSave, newId);
95 |
96 | return newId;
97 |
98 | }
99 |
100 | //Display saved items
101 | const displaySavedItems = async () =>{
102 | var savedItems = await getSavedItems();
103 |
104 | //Display css
105 | const css = `
106 |
204 | `;
205 |
206 | //Create the table headers
207 |
208 | var header = document.createElement("h2");
209 | header.textContent = "Restock History";
210 |
211 | var buttonDiv = document.createElement("div");
212 | buttonDiv.setAttribute("id", "restockButtonDiv");
213 |
214 | var clearButton = document.createElement("button");
215 | clearButton.textContent="Clear Restock History";
216 | clearButton.addEventListener("click", confirmClear, false);
217 | buttonDiv.appendChild(clearButton);
218 |
219 | var tableDoc = document.createElement("table");
220 | tableDoc.setAttribute("id", "restock");
221 |
222 | var trDoc = document.createElement("tr");
223 |
224 | var deleteHeader = document.createElement("th");
225 | deleteHeader.textContent = "Del?";
226 | trDoc.appendChild(deleteHeader);
227 |
228 | var itemHeader = document.createElement("th");
229 | itemHeader.textContent="Item";
230 | trDoc.appendChild(itemHeader);
231 |
232 | var purchasePriceHeader = document.createElement("th");
233 | purchasePriceHeader.textContent="Purchase Price";
234 | trDoc.appendChild(purchasePriceHeader);
235 |
236 | var pDateHeader = document.createElement("th");
237 | pDateHeader.textContent="Purchase Date/Time";
238 | trDoc.appendChild(pDateHeader);
239 |
240 | var soldPriceHeader = document.createElement("th");
241 | soldPriceHeader.textContent="Sold Price";
242 | trDoc.appendChild(soldPriceHeader);
243 |
244 | var sDateHeader = document.createElement("th");
245 | sDateHeader.textContent="Sold Date/Time";
246 | trDoc.appendChild(sDateHeader);
247 |
248 | var profitHeader = document.createElement("th");
249 | profitHeader.textContent="Profit";
250 | trDoc.appendChild(profitHeader);
251 |
252 | //Create monthly profit bar
253 |
254 | var topTr = document.createElement("tr");
255 |
256 |
257 | var monthlyProfitTextTd = document.createElement("td");
258 |
259 | var monthlyDropButton = document.createElement("button");
260 | var mDropImg = document.createElement("img");
261 | mDropImg.setAttribute("src", "https://i.imgur.com/bf0iMNr.png");
262 | mDropImg.setAttribute("width", "10");
263 | monthlyDropButton.style.marginRight = "10px";
264 | monthlyDropButton.setAttribute("title", "Show or hide monthly stats over all time.");
265 | monthlyDropButton.appendChild(mDropImg);
266 | monthlyDropButton.addEventListener("click", await monthlyDropClick, false);
267 |
268 | monthlyProfitTextTd.setAttribute("colspan", "5");
269 | monthlyProfitTextTd.setAttribute("class", "totalProfitText");
270 | var helpImg1 = document.createElement("img");
271 | helpImg1.setAttribute("src", "//images.neopets.com/help/question_mark.png");
272 | helpImg1.setAttribute("width", "8");
273 | helpImg1.setAttribute("title", "Monthly profit takes into account buy and sell prices for this month only. It clears every month.");
274 | var mpText = document.createElement("b");
275 | mpText.textContent = "Monthly Profit:";
276 | monthlyProfitTextTd.appendChild(monthlyDropButton);
277 | monthlyProfitTextTd.appendChild(helpImg1);
278 | monthlyProfitTextTd.appendChild(mpText);
279 |
280 | var monthlyProfitAmountTd = document.createElement("td");
281 | monthlyProfitAmountTd.setAttribute("colspan", "4");
282 | var day = new Date();
283 | var mprof = await getProfitPerMonth(day.getMonth(), day.getYear());
284 | monthlyProfitAmountTd.textContent = mprof.toLocaleString("en-US") + " NP";
285 | if (mprof > 0){
286 | monthlyProfitAmountTd.setAttribute("class", "totalProfitText profit");
287 | }else if (mprof < 0){
288 |
289 | monthlyProfitAmountTd.setAttribute("class", "totalProfitText loss");
290 | }
291 | else
292 | {
293 | monthlyProfitAmountTd.setAttribute("class", "totalProfitText");
294 | }
295 |
296 |
297 | //Create total profit
298 | var topTr2 = document.createElement("tr");
299 |
300 | var totalProfitTextTd = document.createElement("td");
301 | totalProfitTextTd.setAttribute("colspan", "5");
302 | totalProfitTextTd.setAttribute("class", "totalProfitText");
303 |
304 | var helpImg = document.createElement("img");
305 | helpImg.setAttribute("src", "//images.neopets.com/help/question_mark.png");
306 | helpImg.setAttribute("width", "8");
307 | helpImg.setAttribute("title", "Total profit takes into account buy and sell prices from all time. It does not clear when you remove history.");
308 |
309 | var tpText = document.createElement("b");
310 | tpText.textContent = "Total Profit:";
311 |
312 | totalProfitTextTd.appendChild(helpImg);
313 | totalProfitTextTd.appendChild(tpText);
314 |
315 | var totalProfitAmntTd = document.createElement("td");
316 | totalProfitAmntTd.setAttribute("colspan", "4");
317 | var prof = await getForeverProfit();
318 | totalProfitAmntTd.textContent = prof.toLocaleString("en-US") + " NP";
319 |
320 | if (prof > 0){
321 | totalProfitAmntTd.setAttribute("class", "totalProfitText profit");
322 | }else if (prof < 0){
323 |
324 | totalProfitAmntTd.setAttribute("class", "totalProfitText loss");
325 | }
326 | else
327 | {
328 | totalProfitAmntTd.setAttribute("class", "totalProfitText");
329 | }
330 |
331 | topTr.appendChild(monthlyProfitTextTd);
332 | topTr.appendChild(monthlyProfitAmountTd);
333 |
334 | topTr2.appendChild(totalProfitTextTd);
335 | topTr2.appendChild(totalProfitAmntTd);
336 |
337 | var monthTr = document.createElement("tr");
338 | var monthTd = document.createElement("td");
339 |
340 | var monthDrop = document.createElement("table");
341 | monthDrop.setAttribute("id", "monthDrop");
342 | monthTd.setAttribute("colspan", "7");
343 | monthTr.appendChild(monthTd);
344 | monthTd.appendChild(monthDrop);
345 |
346 |
347 | tableDoc.appendChild(topTr);
348 |
349 | tableDoc.appendChild(monthTr);
350 | tableDoc.appendChild(topTr2);
351 | tableDoc.appendChild(trDoc);
352 |
353 | var history = document.createElement("div");
354 | history.setAttribute("class", "history");
355 | var historyInfo = document.createElement("p");
356 | historyInfo.textContent = savedItems.length + "/" + maxSaves + " items logged";
357 | history.appendChild(historyInfo);
358 | var historyHelpImg = document.createElement("img");
359 | historyHelpImg.setAttribute("src", "//images.neopets.com/help/question_mark.png");
360 | historyHelpImg.setAttribute("width", "8");
361 | historyHelpImg.setAttribute("title", "When you've reached your max history, items will start disappearing from your history log. Please remove items manually or clear out your history routinely.");
362 |
363 | history.appendChild(historyHelpImg);
364 |
365 | buttonDiv.appendChild(history);
366 |
367 | //remove saved items if maxSaves changed
368 | if (savedItems.length > maxSaves)
369 | {
370 | savedItems.shift();
371 | await GM.setValue(dataStorage, JSON.stringify(savedItems));
372 |
373 | }
374 |
375 |
376 | //For each restocked item create a row
377 | for (var i in savedItems){
378 |
379 | var buydate = new Date(savedItems[i].timestamp).toLocaleString();
380 | var selldate = new Date(savedItems[i].soldtime).toLocaleString();
381 |
382 | var innerTrDoc = document.createElement("tr");
383 |
384 | var delTd = document.createElement("td");
385 | var delButton = document.createElement("button");
386 | delButton.setAttribute("class", "button-24");
387 | delButton.setAttribute("role", "button");
388 | delButton.textContent = "x";
389 | delButton.itemIdParam = savedItems[i].id;
390 | delButton.addEventListener("click", deleteEntry, false);
391 | delTd.appendChild(delButton);
392 | innerTrDoc.appendChild(delTd);
393 |
394 | var itemTd = document.createElement("td");
395 | var itemImg = document.createElement("img");
396 | itemImg.setAttribute("height", "80");
397 | itemImg.setAttribute("src", savedItems[i].image);
398 | var itemP = document.createElement("p");
399 | itemP.textContent = savedItems[i].name;
400 | itemTd.appendChild(itemImg);
401 | itemTd.appendChild(itemP);
402 | innerTrDoc.appendChild(itemTd);
403 |
404 | var pPriceTd = document.createElement("td");
405 | pPriceTd.textContent = savedItems[i].buyprice.toLocaleString("en-US") + " NP";
406 | innerTrDoc.appendChild(pPriceTd);
407 |
408 | var pDateTd = document.createElement("td");
409 | pDateTd.textContent = buydate;
410 | innerTrDoc.appendChild(pDateTd);
411 |
412 | var sPriceTd = document.createElement("td");
413 | var sDateTd = document.createElement("td");
414 | var profitTd = document.createElement("td");
415 | if (savedItems[i].sold){
416 | sPriceTd.textContent = savedItems[i].sellprice.toLocaleString("en-US") + " NP";
417 | sDateTd.textContent = selldate;
418 |
419 | var profit = savedItems[i].sellprice - savedItems[i].buyprice;
420 | profitTd.textContent = profit.toLocaleString("en-US") + " NP";
421 |
422 | if (profit> 0)
423 | {
424 | profitTd.setAttribute("class", "profit");
425 | }
426 | else if (profit < 0)
427 | {
428 | profitTd.setAttribute("class", "loss");
429 | }
430 | }
431 | else
432 | {
433 | var sPriceInput = document.createElement("input");
434 | sPriceInput.value = 0;
435 | sPriceInput.setAttribute("id", "soldprice");
436 |
437 | sPriceTd.appendChild(sPriceInput);
438 |
439 | var soldButton = document.createElement("button");
440 | soldButton.textContent = "Sold";
441 | soldButton.itemIdParam = savedItems[i].id;
442 | soldButton.priceInputParam = sPriceInput;
443 | soldButton.addEventListener("click", setSold, false);
444 | sDateTd.appendChild(soldButton);
445 |
446 | profitTd.textContent= (-1*savedItems[i].buyprice).toLocaleString("en-US") + " NP";
447 | }
448 |
449 |
450 | innerTrDoc.appendChild(sPriceTd);
451 | innerTrDoc.appendChild(sDateTd);
452 | innerTrDoc.appendChild(profitTd);
453 |
454 |
455 | tableDoc.appendChild(innerTrDoc);
456 | }
457 |
458 | var insertNode = document.createElement("div");
459 | insertNode.setAttribute("id", "restockDiv");
460 | insertNode.innerHTML = css;
461 | insertNode.appendChild(header);
462 | insertNode.appendChild(buttonDiv);
463 | insertNode.appendChild(tableDoc);
464 |
465 | var getContentDiv = document.getElementById("content");
466 | getContentDiv.appendChild(insertNode);
467 |
468 |
469 | }
470 |
471 | //Set sold
472 | const setSold = async (evt)=>{
473 | var id = evt.currentTarget.itemIdParam;
474 |
475 | var items = await getSavedItems();
476 |
477 | var sellPrice = evt.currentTarget.priceInputParam.value;
478 | sellPrice = sellPrice.replace(",", "");
479 | sellPrice = sellPrice.replace("NP", "");
480 | sellPrice = sellPrice.replace(" ","");
481 | sellPrice = Number(sellPrice);
482 |
483 | if (!isNaN(sellPrice)){
484 |
485 | var item = items.find(x => x.id == id);
486 | if (item) {
487 | item.sold = true;
488 | item.sellprice = sellPrice;
489 |
490 | item.soldtime = new Date();
491 |
492 | await updateForeverProfit(item.sellprice)
493 | await setProfitPerMonth(item.sellprice, item.soldtime.getMonth(), item.soldtime.getYear());
494 |
495 | if (items.length > maxSaves)
496 | {
497 | items.shift();
498 | }
499 |
500 | await GM.setValue(dataStorage, JSON.stringify(items));
501 | }
502 |
503 |
504 |
505 | await refreshHistory();
506 | }
507 | else
508 | {
509 | alert("Please enter a number only in the Sold Price input box");
510 | }
511 | }
512 |
513 | //Delete entry
514 | const deleteEntry = async (evt)=>{
515 |
516 | var id = evt.currentTarget.itemIdParam;
517 |
518 | var items = await getSavedItems();
519 | var item = items.find(x => x.id == id);
520 | if (item) {
521 | var continueDelete = true;
522 | if (item.sold == false)
523 | {
524 | var confirm = window.confirm("Are you sure you want to delete this entry before selling it?");
525 | continueDelete = confirm;
526 | }
527 | if (continueDelete){
528 | const index = items.indexOf(item);
529 | items.splice(index, 1); //remove item from array
530 |
531 | //Resave values
532 | await GM.setValue(dataStorage, JSON.stringify(items));
533 |
534 | refreshHistory();
535 |
536 | }
537 | }
538 | }
539 |
540 | const refreshHistory = async()=>{
541 |
542 | var restockDiv = document.getElementById("restockDiv");
543 | restockDiv.remove();
544 |
545 | await displaySavedItems();
546 | }
547 |
548 | //Choose what to run based on location
549 | const actBasedOnLocation = async ()=>{
550 | var onMarketPlace = (document.URL == "https://www.neopets.com/market.phtml?type=sales");
551 | if (onMarketPlace){
552 | await displaySavedItems();
553 | }
554 | else
555 | {
556 | await checkForHaggleWin();
557 | }
558 | }
559 |
560 | //Gets the saved items
561 | const getSavedItems = async ()=>{
562 | const items = await GM.getValue(dataStorage, "[]");
563 | return JSON.parse(items);
564 | }
565 |
566 | //Get forever save amount
567 | const getForeverProfit = async()=>{
568 | var currForeverProfit = await GM.getValue(foreverProfit);
569 | if (!currForeverProfit){
570 | return 0;
571 | }
572 | else
573 | {
574 | return currForeverProfit;
575 | }
576 | }
577 |
578 | const getProfitPerMonth = async(month, year)=>{
579 |
580 | var items = await getAllProfitMonthlyItems();
581 | var perMonthItem = items.filter(x => x.month == month && x.year == year)[0];
582 | if (perMonthItem){
583 | return perMonthItem.profit;
584 | }
585 | else{
586 | return 0;
587 | }
588 | }
589 |
590 | const getAllProfitMonthlyItems = async()=>{
591 | const items = await GM.getValue(profitByMonth, "[]");
592 | return JSON.parse(items);
593 | }
594 |
595 | const updateForeverProfit = async(profit)=>
596 | {
597 | var currForeverProfit = await getForeverProfit();
598 | var newForeverProfit = currForeverProfit + profit;
599 | await GM.setValue(foreverProfit, newForeverProfit);
600 |
601 | }
602 |
603 |
604 | const setProfitPerMonth = async(profit, month, year)=>
605 | {
606 | var currProfitPerMonth = await getProfitPerMonth(month, year);
607 | var newProfitPerMonth = currProfitPerMonth + profit;
608 | var items = await getAllProfitMonthlyItems();
609 |
610 | var perMonthItem = items.filter(x => x.month == month && x.year == year)[0];
611 | if (perMonthItem) {
612 | perMonthItem.profit = perMonthItem.profit + profit;
613 | await GM.setValue(profitByMonth, JSON.stringify(items));
614 | }
615 | else{
616 | //create new month item
617 | const monthitem = {
618 | month: month,
619 | year: year,
620 | profit: profit
621 | }
622 |
623 | items.unshift(monthitem); //Add month item to list
624 |
625 | GM.setValue(profitByMonth, JSON.stringify(items));
626 | }
627 | }
628 |
629 | //Clears out all of the items saved
630 | const clearItems = () => {
631 | GM.setValue(dataStorage, "[]");
632 | GM.setValue(idSave, 0);
633 | }
634 |
635 | //open and close the monthly dropdown
636 | const monthlyDropClick = async() =>{
637 |
638 | var dropDiv = document.getElementById("monthDrop");
639 | if (dropOpen)
640 | {
641 | dropDiv.style.display = "none";
642 | }
643 | else{
644 | dropDiv.style.display = "table"
645 | if (!dropOpenedBefore){
646 | await loadMonthlyInfo();
647 | }
648 | }
649 | dropOpen= !dropOpen;
650 | }
651 | const monthNames = ["January", "February", "March", "April", "May", "June",
652 | "July", "August", "September", "October", "November", "December"
653 | ];
654 | //Only load this once, and if asked for
655 | const loadMonthlyInfo = async() =>{
656 | dropOpenedBefore = true;
657 | var items = await getAllProfitMonthlyItems();
658 | var dropDiv = document.getElementById("monthDrop");
659 |
660 |
661 | for (var i in items){
662 | var dropTr = document.createElement("tr");
663 |
664 | var dropTxtTd = document.createElement("td");
665 | var dropTxt = document.createElement("b");
666 | dropTxt.textContent = monthNames[items[i].month] + " 20" + (items[i].year-100);
667 | dropTxtTd.appendChild(dropTxt);
668 | dropTxtTd.setAttribute("width", "200");
669 | var dropAmnt = document.createElement("td");
670 | var dropAmntTxt = document.createElement("p");
671 | dropAmntTxt.textContent = items[i].profit.toLocaleString("en-US") + " NP";
672 | dropAmntTxt.style.textAlign = "right";
673 | dropAmntTxt.style.width = "140px";
674 | dropAmnt.appendChild(dropAmntTxt);
675 |
676 | dropTr.appendChild(dropTxtTd);
677 | dropTr.appendChild(dropAmnt);
678 | dropDiv.appendChild(dropTr);
679 | }
680 |
681 | }
682 |
683 |
684 | //Confirmation for clearing the data
685 | const confirmClear = () =>{
686 | var confirm = window.confirm("Are you sure you want to clear out all your restock history?");
687 |
688 | if (confirm){
689 | clearItems();
690 | refreshHistory();
691 | }
692 | return confirm;
693 | }
694 |
695 |
696 | await actBasedOnLocation();
697 |
698 |
699 | })().then();
700 |
701 |
702 |
--------------------------------------------------------------------------------
/Sidebar Always Open.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name Sidebar Always Open
3 | // @version 1.1
4 | // @description Keep that sidebar open please!
5 | // @author Harvey
6 | // @match http://www.neopets.com/*
7 | // @match https://www.neopets.com/*
8 | // @icon https://www.google.com/s2/favicons?sz=64&domain=neopets.com
9 | // @grant GM.getValue
10 | // @grant GM.setValue
11 |
12 | // @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
13 | // ==/UserScript==
14 | var $ = window.jQuery;
15 |
16 | GM_addStyle ( `
17 | .hp-carousel-container {
18 | margin-left:100px;
19 | }
20 | ` );
21 | GM_addStyle(`
22 | #navprofiledropdown__2020 *{/*CSS transitions*/
23 | transition-property: none !important;
24 | }
25 | `);
26 | $(document).ready(function () {
27 |
28 | var results = document.getElementsByClassName("nav-pet-menu-icon__2020");
29 | if (results[0]){
30 | results[0].addEventListener('click', function () {
31 | toggleSidebar();
32 | });
33 | }
34 |
35 | });
36 |
37 | function increaseTrack()
38 | {
39 | var results = document.getElementsByClassName("slick-track");
40 | for(var i = 0; i < results.length; i++){
41 |
42 | var newhtml = results[i].innerHTML.replace("width: 5100px;","width: 5200px;");
43 | results[i].innerHTML = newhtml;
44 | }
45 | }
46 | function EditAttributeValue(elemId, attribute, newvalue)
47 | {
48 | $("#"+elemId).attr(attribute,newvalue);
49 | }
50 |
51 | var isToggledOpen = true;
52 |
53 | async function toggleSidebar()
54 | {
55 | GM.setValue("sidebar_always_open_toggle_value", !isToggledOpen);
56 | openorcloseonload();
57 |
58 | }
59 |
60 |
61 | async function openorcloseonload()
62 | {
63 | var toggled = await GM.getValue("sidebar_always_open_toggle_value", -1);
64 |
65 | if (toggled == -1)
66 | {
67 | GM.setValue("sidebar_always_open_toggle_value", true);
68 | toggled = true;
69 | }
70 |
71 | if (toggled)
72 | {
73 | openSidebar();
74 | }
75 | else
76 | {
77 | closeSidebar();
78 | }
79 | isToggledOpen = toggled;
80 | }
81 |
82 | function closeSidebar()
83 | {
84 | EditAttributeValue("navprofiledropdown__2020", "style", "display: none!important;");
85 | moveShopWiz(false);
86 |
87 | }
88 |
89 | function openSidebar()
90 | {
91 | var results = document.getElementById("navprofiledropdown__2020");
92 | EditAttributeValue("navprofiledropdown__2020", "style", "display: block!important;");
93 | EditAttributeValue("nav-dropdown-shade__2020", "style", "display: none!important;");
94 | moveShopWiz(true);
95 | }
96 |
97 | function addJS_Node (text, s_URL, funcToRun, runOnLoad) {
98 | var D = document;
99 | var scriptNode = D.createElement ('script');
100 | if (runOnLoad) {
101 | scriptNode.addEventListener ("load", runOnLoad, false);
102 | }
103 | scriptNode.type = "text/javascript";
104 | if (text) scriptNode.textContent = text;
105 | if (s_URL) scriptNode.src = s_URL;
106 | if (funcToRun) scriptNode.textContent = '(' + funcToRun.toString() + ')()';
107 |
108 | var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
109 | targ.appendChild (scriptNode);
110 | }
111 |
112 | function moveShopWiz(open)
113 | {
114 | if (open)
115 | {
116 |
117 | GM_addStyle ( `
118 | .navsub-left__2020 {
119 | left:290px!important;
120 | }
121 | ` );
122 |
123 | }
124 | else{
125 |
126 |
127 | GM_addStyle ( `
128 | .navsub-left__2020 {
129 | left:10px!important;
130 | }
131 | ` );
132 |
133 | }
134 |
135 | }
136 |
137 | function removeShade()
138 | {
139 |
140 | var shade = document.getElementById('navdropdownshade__2020');
141 | shade.classList.remove("nav-dropdown-shade__2020");
142 | }
143 |
144 |
145 | function GM_addStyle(css) {
146 | const style = document.getElementById("GM_addStyleBy8626") || (function() {
147 | const style = document.createElement('style');
148 | style.type = 'text/css';
149 | style.id = "GM_addStyleBy8626";
150 | document.head.appendChild(style);
151 | return style;
152 | })();
153 | const sheet = style.sheet;
154 | sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
155 | }
156 | removeShade();
157 | openorcloseonload();
--------------------------------------------------------------------------------