Quantcast

Jump to content


Photo

Greasemonkey Userscript for Changing/Adding Text Idea/Help?


  • Please log in to reply
12 replies to this topic

#1 MC10

MC10
  • 353 posts


Users Awards

Posted 22 March 2014 - 11:53 PM

Hey guys, I'm sort of new to this forum but I'm loving it already. I was snooping around the Programming Area yesterday and was intrigued by what I saw. I'm just a first year in college planning to major in computer science. I mainly use and know Java as that is what I was taught in high school and currently in college. I've used some C and Python before but I'm not as confident about using them. I've also used some C# in Visual Studio.

 

I recently started a guide about semi-legit restocking (blocking images with AdBlock). I hear this method has it's dangers and I had an idea for an alternative. Instead of blocking images to indicate junk items, I wanted to change the color of the text for the item name and maybe add another line beneath the cost in the shop that shows the profit as listed on the item database on here. My idea was to make a Greasemonkey userscript for this. It would go through each item in the shop and check it against the database.

 

The text color for item names would be something like:

Red = negative profit

Orange = <1k profit

Black = <2k profit

Blue = <5k profit

Green = <10k profit

Cyan = <25k profit

Pink = <50k profit

 

I don't have any JavaScript experience and I'm not sure if this is possible. The way I would check an item on the database would be to take it's name and search it on the database in "quotes" so if it's something like Shampoo it doesn't show all the items with Shampoo in the name. Is it possible for a Greasemonkey userscript to access a webpage like the item database, submit a search, and find an element like the profit value without physically opening a new tab/window?

 

If anyone would like to help me with this, feel free to let me know. I basically just have this idea but no idea how to implement it. I'm going to start learning JS just to get a feel for it and hopefully make some useful scripts in the future.


Edited by MC10, 22 March 2014 - 11:53 PM.


#2 MC10

MC10
  • 353 posts


Users Awards

Posted 23 March 2014 - 12:07 AM

This would indeed be very helpful in legit restocking. I do know of an old chrome plugin (written in javascript) which ABed based on the profit by grabbing prices from jellyneo. The script doesn't work anymore :( But the interesting thing is you could turn off the ABing and just grab profits. If the profit was above 1000np, it boxed the item in a color, above 2500, different color, above 5000, different color. This made it easier to legit restock with no risk whatsoever (that is with the no ABing function). 

 

Anyways, making a program like this would be helpful. I do have the old source code of the plugin, PM me if you want it. 

Wow, that sounds almost exactly like what I want. This would be completely undetectable unlike blocking images right? I think many people would appreciate this, I definitely would. I miss seeing images of items while refreshing...plus, having different colors should add some spice to restocking :p.



#3 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 23 March 2014 - 01:56 AM

http://wiki.greasesp..._xmlhttpRequest

 

That's what you'll probably want to use for the web requests. Also, you'll want to cache the price information instead of having to request it every single time that item shows up otherwise you're not going to be popular with the website you use to lookup the item prices. ;)



#4 Eefi

Eefi
  • 1337 h4x0r

  • 1626 posts


Users Awards

Posted 23 March 2014 - 02:03 AM

I have a different idea. Instead of changing the color, just resize unprofitable items to 1x1 pixel. They still need to be loaded but you won't see them.

Also, you should preload your list before you actually start restocking. Asking the server when you see the items is going to be too slow.

 

I have my hands full with other programs but if you have any specific Javascript questions I can probably help.



#5 Dan

Dan
  • Resident Know-It-All

  • 6382 posts


Users Awards

Posted 23 March 2014 - 02:06 AM

 This would be completely undetectable unlike blocking images right?

 

Explain your thinking around what you said here...



#6 Waser Lave

Waser Lave

  • 25516 posts


Users Awards

Posted 23 March 2014 - 02:14 AM

Anything is detectable if they put the right checks in place, they almost certainly don't check for blocked images anyway though.



#7 MC10

MC10
  • 353 posts


Users Awards

Posted 23 March 2014 - 03:07 AM

http://wiki.greasesp..._xmlhttpRequest

 

That's what you'll probably want to use for the web requests. Also, you'll want to cache the price information instead of having to request it every single time that item shows up otherwise you're not going to be popular with the website you use to lookup the item prices. ;)

I have a different idea. Instead of changing the color, just resize unprofitable items to 1x1 pixel. They still need to be loaded but you won't see them.

Also, you should preload your list before you actually start restocking. Asking the server when you see the items is going to be too slow.

 

I have my hands full with other programs but if you have any specific Javascript questions I can probably help.

Thanks guys for the help. I still have a lot of learning to do though so I guess this isn't going to happen soon haha.

 

Explain your thinking around what you said here...

Anything is detectable if they put the right checks in place, they almost certainly don't check for blocked images anyway though.

I was thinking that it would just change how we view the text client-side and they would not notice it. Would they still be able to track something like this? I guess if anything is detectable than nothing is safe.



#8 Dan

Dan
  • Resident Know-It-All

  • 6382 posts


Users Awards

Posted 23 March 2014 - 03:20 AM

I was thinking that it would just change how we view the text client-side and they would not notice it.

 
You're correct, the userscript is run after the page has finished loading, so any hiding / recolouring is done only on the client post HTTP response.

 

Would they still be able to track something like this? I guess if anything is detectable than nothing is safe.

In theory, yes, but in practice it's very unlikely.

It's difficult for us to speculate on the information that neopets logs and their freezing patterns in general. It's entirely possible that neopets could implement some way to detect when a user isn't requesting (or loading - two different things) images on a shop page. Is it probable? No, it would be a very unreliable way to catch cheaters. 

 

Realistically I think you'd just need to be careful with timings. If you buy something too quick, whether you're restocking legitimately in a browser or illegitimately using a program, you can be frozen. 



#9 Eefi

Eefi
  • 1337 h4x0r

  • 1626 posts


Users Awards

Posted 23 March 2014 - 03:30 AM

It's not possible to track what javascript is executed in your browser unless the javascript calls home everytime it does something.

So you can definitely suppress the "do you really want to buy" prompt and change the text size/color/etc all you want.

 

Realistically I think you'd just need to be careful with timings. If you buy something too quick, whether you're restocking legitimately in a browser or illegitimately using a program, you can be frozen. 

And this.



#10 MC10

MC10
  • 353 posts


Users Awards

Posted 23 March 2014 - 04:13 AM

Ah ok, thanks for all the detailed info and advice. I'm going to try and learn JS and all the other things needed to get this working. I hope I'm able to actually make this in the near future. Maybe over the summer I'll dedicate more time to it.



#11 Dan

Dan
  • Resident Know-It-All

  • 6382 posts


Users Awards

Posted 23 March 2014 - 04:13 AM

It's not possible to track what javascript is executed in your browser unless the javascript calls home everytime it does something.

 

Precisely. Let's think about this: there are only two ways that Neopets could detect if you're loading or requesting images:

  • Client-side, by using a small script to check if images have indeed loaded, and then reporting back to a server (highly unlikely and unreliable to boot)
  • Server-side, by checking logs (manually or automatically) to see if you requested images around the same time you requested the main page (again, highly unlikely and unreliable).

Based on those two conclusions I'd deduce that the likelihood for neopets freezing based on requesting images alone is extremely low. Whether you load images or not on a webpage is detectable in theory, but it'd be an unreliable mess of a statistic to record when deciding whether or not to freeze a potential cheater.

 

----

 

It's worth understanding the basis for all of the desktop programs here. Every single one (at least on this site) spoofs a browser like-for-like and sends requests to Neopets in - precisely - the same way as a browser.

 

In programs there is no need to perform all of the normal tasks a browser does, e.g. display the contents of the page, evaluate any of the javascript, apply css rules, etc - skipping these stepx lessens the overhead significantly -- to the point where these programs will make requests, analyse and proceed far quicker than any user or semi-legitimate restocker could.

This is why human-like wait times are added to programs, because they actually run *too fast* and need slowing down to look real and avoid being frozen.

 

What I'm saying here is you're not solving any problems* here by doing this semi-legit restocking business. You're essentially doing everything Abrosia (or any other decently written AB) does, but slower and with far more effort. Neopets will freeze you without discrimination. They have no way of telling whether it's you restocking legitimately, you restocking with a greasemonkey script for help or you running a desktop program.

 

* - unless you just want to do this for fun, in which case, go for it, it would be good practice



#12 MC10

MC10
  • 353 posts


Users Awards

Posted 23 March 2014 - 05:03 AM

Yeah I understand that ABing would be much easier. This would probably be something that might be only used by me personally or anyone else who just wants to do it manually. The only reason I'm doing this right now is because I just got into it and it's a bit of fun. If I get bored I'll probably stick to just running Abrosia every once in a while. I might do it for the ambition and practice.



#13 Charmender

Charmender
  • Awesome

  • 4104 posts


Users Awards

Posted 12 April 2014 - 01:42 PM

Something as follows might be what your after, bearing in mind you would have to change the ajax call to suit w/e item database server you were calling:

this also calls per item, might be nicer on the server that you are calling to call once with a json containing all the items you want identified, and sort that out client side, it also makes the assumption that you are calling to a server that has given you api access and support CORS, it could be changed for one that supports JSONP, and i wouldnt advise using it with something like GM's xmlHttpRequest (i know if i was a server admin, i wouldn't want people calling my pages for specific information, and having them load the whole page)

var $ = unsafeWindow.jQuery;
var shopitems = {};

$('a[href^="buy_item"]').parent().each(function(index) {
    var cost = $($(this).contents().filter(function() {
        return this.nodeType === 3;
    })[3]).text().replace("Cost : ", "").replace(" NP", "").split(",").join();
    var name = $("b", this).text();
    shopitems[index] = {"name": name, "cost": cost, "container": this};
});

for (key in shopitems) {
    doItemCall(key);
}


function doItemCall(key) {

    //you would need to change the below ajax call depending on what item db server you were calling and if they supported jsonp or cors.
    $.ajax({
        url: "http://...",
        dataType: "json",
        data: {item: '"' + shopitems[key].name + '"'},
        success: function(response) {
            if ((parseInt(response.cost) - parseInt(shopitems[key].cost) > 1000)) {
                $(shopitems[key].container).css("color", "#ff8c00");
            }
            //etc
        },
        error: function(response) {
            $(shopitems[key].container).css("border","1px solid brown");
        }
    });
}



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users