Quantcast

Jump to content


Photo

[Help] Calling all Greasemonkey experts. Is this possible?

gm rubbish avatar greasemonkey userscript

  • Please log in to reply
9 replies to this topic

#1 dogma22

dogma22
  • 4 posts

Posted 25 January 2016 - 10:10 AM

So I was reading this thread on NeoBoards about how to get the Rubbish avatar. One of the methods involved buying around 4k "Red Long Hair Brush" from the General Store and discarding them. It was mentioned to be one of the quickest methods to get the Rubbish avatar. 4k of those would cost around 216k NPs.

 

What I'm suggesting is a GM script, that will buy Red Long Hair Brush from the General Store (note there is no haggle option in this store), after it buys 50 items, it will either alert or transfer those 50 to SDB and continue buying the next batch of 50 Red Long Hair Brush.

 

I have absolutely no knowledge of GM, that's why requesting anyone that can help in coding this. I think this will be helpful for those still seeking the Rubbish avatar and are too lazy to wait a month or so packing 4-5k junk items.

 

With this, lets say we buy 500 each day, just to be on the safer side, and in 8 days we should have 4k. 2 days more for discarding and I think the Rubbish avatar could be obtained in less than 10 days!

 

Let me know what you guys think.

Thanks :)



#2 Neoquest

Neoquest
  • 1760 posts


Users Awards

Posted 25 January 2016 - 10:52 AM

*cracks knuckles*
 

import re
import sys
import urllib
import urllib2
import cookielib
 
cookie_jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar))
 
 
def safeOpen(obj):
    try:
        src = opener.open(obj).read()
        if "http://images.neopets.com/neoboards/avatars/rubbish.gif" in src:
            sys.exit("Got the rubbish avatar")
        return src
    except Exception:
        print("HTTP request failed, trying again")
        return safeOpen(obj)
 
 
def buyBrush():
    store_src = safeOpen("http://www.neopets.com/generalstore.phtml")
    ref_ck = store_src.split(''''_ref_ck' value="''')[1].split('"')[0]
    req = urllib2.Request("http://www.neopets.com/generalstore.phtml", "buy_oii=91&store_type=&_ref_ck=%s&buy_oii_click.x=44&buy_oii_click.y=5&buy_oii_click=91" % ref_ck)
    safeOpen(req)
 
 
def discardInvent():
    stock_src = safeOpen("http://www.neopets.com/quickstock.phtml")
    item_ids = re.findall('id_arr\[\d+\]" value="\d+">', stock_src)
    data = {"buyitem": 0}
    for index, item in enumerate(item_ids):
        key, val = item_ids[index].replace('value="', "").replace(">", "").replace("'", "").replace('"', "").split(" ")
        data[key] = val
        data[key.replace("id_arr", "radio_arr")] = "discard"
    data["checkall"] = "on"
    data = urllib.urlencode(data)
    req = urllib2.Request("http://www.neopets.com/process_quickstock.phtml", data)
    safeOpen(req)
 
un = raw_input("Username: ")
pw = raw_input("Password: ")
opener.open('http://www.neopets.com/login.phtml', 'username=%s&password=%s' % (un, pw))
 
while 1:
    print("Buying 50 brushes...")
    for x in xrange(50):
        buyBrush()
    print("Discarding invent...")
    discardInvent()
 

I know it's not greasemonkey, but Python's better anyway, right? Download Python 2.7 and run that script with it, it'll buy and discard brushes until it gets the avatar.

Disclaimer: This script will discard your entire inventory, no matter the contents, so start with an empty invent.



#3 dogma22

dogma22
  • 4 posts

Posted 25 January 2016 - 12:59 PM

*cracks knuckles*
 

import re
import sys
import urllib
import urllib2
import cookielib
 
cookie_jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar))
 
 
def safeOpen(obj):
    try:
        src = opener.open(obj).read()
        if "http://images.neopets.com/neoboards/avatars/rubbish.gif" in src:
            sys.exit("Got the rubbish avatar")
        return src
    except Exception:
        print("HTTP request failed, trying again")
        return safeOpen(obj)
 
 
def buyBrush():
    store_src = safeOpen("http://www.neopets.com/generalstore.phtml")
    ref_ck = store_src.split(''''_ref_ck' value="''')[1].split('"')[0]
    req = urllib2.Request("http://www.neopets.com/generalstore.phtml", "buy_oii=91&store_type=&_ref_ck=%s&buy_oii_click.x=44&buy_oii_click.y=5&buy_oii_click=91" % ref_ck)
    safeOpen(req)
 
 
def discardInvent():
    stock_src = safeOpen("http://www.neopets.com/quickstock.phtml")
    item_ids = re.findall('id_arr\[\d+\]" value="\d+">', stock_src)
    data = {"buyitem": 0}
    for index, item in enumerate(item_ids):
        key, val = item_ids[index].replace('value="', "").replace(">", "").replace("'", "").replace('"', "").split(" ")
        data[key] = val
        data[key.replace("id_arr", "radio_arr")] = "discard"
    data["checkall"] = "on"
    data = urllib.urlencode(data)
    req = urllib2.Request("http://www.neopets.com/process_quickstock.phtml", data)
    safeOpen(req)
 
un = raw_input("Username: ")
pw = raw_input("Password: ")
opener.open('http://www.neopets.com/login.phtml', 'username=%s&password=%s' % (un, pw))
 
while 1:
    print("Buying 50 brushes...")
    for x in xrange(50):
        buyBrush()
    print("Discarding invent...")
    discardInvent()
 

I know it's not greasemonkey, but Python's better anyway, right? Download Python 2.7 and run that script with it, it'll buy and discard brushes until it gets the avatar.

Disclaimer: This script will discard your entire inventory, no matter the contents, so start with an empty invent.

 

 

Thank you for replying Neoquest. Python didn't come to my mind. This is great!

One small doubt, if I change

data[key.replace("id_arr", "radio_arr")] = "discard"

to

data[key.replace("id_arr", "radio_arr")] = "deposit"

it will deposit all of them in SDB and repeat buying?

What should I do, say if I want an alert when there are 4k brushes in my SDB?

 

Really appreciate your help. Thank you :)



#4 juvian

juvian
  • 123 posts


Users Awards

Posted 25 January 2016 - 02:31 PM

My chrome extension deals with general store autobuying, among other things ;). By the way, you don't need to deposit when buying from general store.

Have bought 3k in a day several times before, think you can buy a bit more than 500 per day (1k ?)


Edited by juvian, 25 January 2016 - 02:32 PM.


#5 Neoquest

Neoquest
  • 1760 posts


Users Awards

Posted 25 January 2016 - 03:53 PM

Thank you for replying Neoquest. Python didn't come to my mind. This is great!

One small doubt, if I change

data[key.replace("id_arr", "radio_arr")] = "discard"

to

data[key.replace("id_arr", "radio_arr")] = "deposit"

it will deposit all of them in SDB and repeat buying?

What should I do, say if I want an alert when there are 4k brushes in my SDB?

 

Really appreciate your help. Thank you :)

 

Yeah, changing that text to deposit will work.
Making an alert would be a bit more difficult. You could put a counter in there to only buy so many brushes, but actually getting that number from your SBD would require more code.



#6 dogma22

dogma22
  • 4 posts

Posted 25 January 2016 - 11:51 PM

Thank you Neoquest. You really helped out with this one :)

And thanks Juvian, I'll be sure to check your chrome extension.



#7 Altador

Altador
  • 20 posts


Users Awards

Posted 26 January 2016 - 12:03 AM

My chrome extension deals with general store autobuying, among other things ;). By the way, you don't need to deposit when buying from general store.

Have bought 3k in a day several times before, think you can buy a bit more than 500 per day (1k ?)

 

and what extension might that be? :)



#8 GetJinxed

GetJinxed
  • Reckless Cheater

  • 1423 posts


Users Awards

Posted 26 January 2016 - 11:08 AM

@Altadorhttp://www.neocodex....dpost&p=1926820



#9 juvian

juvian
  • 123 posts


Users Awards

Posted 26 January 2016 - 02:32 PM

Seems I got late. Thanks :)



#10 ib2ownyy

ib2ownyy
  • 10 posts

Posted 07 September 2016 - 09:29 AM

This is a fantastic thread.





Also tagged with one or more of these keywords: gm, rubbish, avatar, greasemonkey, userscript

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users