Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contact #1

Open
Evolutionzzz opened this issue May 6, 2021 · 0 comments
Open

Contact #1

Evolutionzzz opened this issue May 6, 2021 · 0 comments

Comments

@Evolutionzzz
Copy link

I saw that you had created a Neopets script for Account Overview... I downloaded it but it does not seem to work. Do you have an updated version, or.... It seems no one else has one out there (that I have been able to find) and it would be very helpful. If you could contact me that would be great! Id throw ya a bone or 2 for it.

Discord: EvolutionzZz #8816

`// ==UserScript==
// @name Generate Neopets account overview
// @Version 1.0.0
// @grant none
// @include http://www.neopets.com/myaccount.phtml
// @author yesnt
// @description Generates an overview of the currently logged in account on Neopets
// ==/UserScript==

const parser=new DOMParser;let username=unsafeWindow.userIDApp;const run=async()=>{const e=rarePercentInput.value,t=obscureNamesInput.checked;log.send("Getting profile...");const n=await getProfile();log.send("Getting trophies...");const r=getTrophies(n);log.send("Getting account age...");const o=[IMG]https://images.weserv.nl/?url=${n.querySelector("#userinfo img").src}[/IMG];log.send("Getting stamps count...");const s=n.querySelector("#usercollections").textContent.match(/Stamps:[\s\S]?(?\d+)/).groups.count;log.send("Getting avvies...");const a=await getUserAvvies(),l=await getRetiredAvvies(),i=await getRareAvvies(e,l),c=a.filter((e,t)=>l.includes(e)&&a.indexOf(e)===t).map(e=>[IMG]https://images.weserv.nl/?url=http://images.neopets.com/neoboards/avatars/${e}.gif[/IMG]),p=a.filter((e,t)=>i.includes(e)&&a.indexOf(e)===t).map(e=>[IMG]https://images.weserv.nl/?url=http://images.neopets.com/neoboards/avatars/${e}.gif[/IMG]),d=n.querySelector("#usercollections").textContent.match(/Secret Avatars:[\s\S]?(?\d+)/).groups.count;log.send("Getting pets...");const h=await getPets(t);log.send("Checking lab access...");const u=await checkLabAccess();log.send("Getting bank balance...");let m=await getBankBalance();log.send("Getting stocks...");let b=await getStockValue();t&&(username=obscureText(username));const g=\n [CENTER]<br>\n [B]${username}[/B]<br><br>\n ${o}<br><br><br>\n ${c.length>0?"[B]Retired Avvies[/B]<br><br>":""}\n ${c.join("")}<br><br><br>\n ${p.length>0?"[B]Noteable Avvies[/B]<br><br>":""}\n ${p.join("")}<br><br><br>\n ${r.length>0?"[B]Trophies[/B]<br><br>":""}\n ${r.join("")}<br><br><br>\n [B]Pets[/B]<br>\n ${h.join("<br>")}<br><br><br>\n [B]Other[/B]<br>\n ${u?"Has lab access<br>":""}\n ${document.querySelector("#npanchor").textContent} NP on hand <br>\n ${m} in bank<br>\n ${b?b+" NP in stocks<br>":""}\n ${s>0?s+" stamps<br>":""}\n ${d>0?d+" total avvies<br>":""}\n [/CENTER];log.send(g)},getProfile=()=>fetch(http://www.neopets.com/userlookup.phtml?user=${username}).then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")),getTrophies=e=>[...e.querySelectorAll("#usertrophies .trophy_cell img")].map(e=>[IMG]https://images.weserv.nl/?url=${e.src}[/IMG]).filter(e=>!e.includes("talisman")),getUserAvvies=async()=>{return[...(await fetch("http://www.neopets.com/neoboards/preferences.phtml").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html"))).querySelectorAll('[name="activeAv"] option')].map(e=>e.value)},getRetiredAvvies=()=>fetch("https://thedailyneopets.com/neoavatars/solutions?category=7").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")).then(e=>[...e.querySelectorAll("html body div.wrap article div.left div.pad div div a img")]).then(e=>e.map(e=>e.src.replace(/^.?neoboards/avatars/(.?).gif/,"$1"))),getRareAvvies=(e=30,t=[])=>fetch("https://thedailyneopets.com/neoavatars/stats").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")).then(e=>[...e.querySelectorAll("table.center tr")].map(e=>{let t=e.querySelector("img");return{img:t?t.src.replace(/^.?neoboards/avatars/(.?).gif/,"$1"):"default",percent:t?Number(e.innerHTML.match(/(?[\d.]+)%</b> have/).groups.percent):100}})).then(n=>n.filter(n=>n.percent<e&&!t.includes(n.img))).then(e=>e.map(e=>e.img)),getPets=(e=!1)=>fetch("http://www.neopets.com/quickref.phtml").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")).then(t=>[...t.querySelectorAll(".contentModule")].map(t=>{let n=[...t.querySelectorAll(".pet_stats tr")].reduce((e,t)=>{let n=t.querySelector("th"),r=t.querySelector("td b");return n&&r?(e[n.textContent.replace(":","")]=r.textContent,e):e},{}),r=t.querySelector(".contentModuleHeaderAlt a, .contentModuleHeader a").textContent;return e&&(r=obscureText(r)),${r} the ${t.querySelector(".pet_notices").textContent.includes("must be converted")?"UC ":""}${n.Colour} ${n.Species}})),checkLabAccess=()=>fetch("http://www.neopets.com/lab.phtml").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")).then(e=>!!e.querySelector('[action="lab2.phtml"]')),getBankBalance=()=>fetch("http://www.neopets.com/bank.phtml/").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")).then(e=>e.querySelector(".content > div:nth-child(12) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1) > table:nth-child(5) > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(2)").textContent),getStockValue=()=>fetch("http://www.neopets.com/stockmarket.phtml?type=portfolio").then(e=>e.text()).then(e=>parser.parseFromString(e,"text/html")).then(e=>{const t=e.querySelector("#postForm > table:nth-child(2) > tbody:nth-child(1) > tr:last-child > td:nth-child(4) > b");return t?t.textContent:0}),obscureText=e=>e.replace(/[A-Z]/g,"X").replace(/[a-z]/g,"x").replace(/[0-9]/g,"#");let display=document.createElement("div");display.setAttribute("style","padding: 50px; text-align: center"),display.classList.add("yesnt-account-overview");let title=document.createElement("h2");title.prepend("Generate account overview"),display.appendChild(title);let options=document.createElement("form");options.setAttribute("style","padding: 10px 0"),options.addOption=function(e,t,n="",r="text"){let o=document.createElement("label");o.textContent=t,o.setAttribute("for",e),o.setAttribute("style","display: block; font-weight: 700; margin-bottom: 10px;");let s=document.createElement("input");s.name=e,s.setAttribute("style","padding: 10px; border: 2px solid #333333"),s.setAttribute("id",e),s.setAttribute("type",r);let a=document.createElement("p");return a.setAttribute("style","margin-bottom: 40px;"),a.textContent=n,this.appendChild(o),this.appendChild(s),this.appendChild(a),s};let optionsTitle=document.createElement("h3");optionsTitle.prepend("Options"),options.appendChild(optionsTitle);let rarePercentInput=options.addOption("rare-percent","Noteable avvie user percentage",'If an avvie has below this percentage of users (according to thedailyneopets) it will be counted as "noteable".');rarePercentInput.value=31;let obscureNamesInput=options.addOption("obscure-names","Obscure names","Replace user/pet names with Xs and #s","checkbox");obscureNamesInput.checked=!0,display.appendChild(options);let button=document.createElement("a");button.setAttribute("style","display: inline-block; padding: 10px; background: dodgerblue; color: white;"),button.setAttribute("href","#"),button.text="Generate",button.addEventListener("click",e=>(e.preventDefault(),button.remove(),title.remove(),options.setAttribute("style","display: none"),run().catch(console.error))),display.appendChild(button);let log=document.createElement("p");display.appendChild(log),log.send=function(e){this.innerHTML=e},document.querySelector(".content").prepend(display);`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant