7

So I'm playing a game online on my laptop and it is a pretty simple html5 game but the optimization is nonexistant. The game with a few circles on my screen is using 85% of my cpu.

Logically, I started profiling the game and was trying to figure out if I could optimize it for my laptop. Now, what I'm wondering is how could I run the game but with a tweaked version of the JS script that is running.

If I try to save the page and run it from my laptop it of course has CORS issues so I can not access the server.

Can I somehow change the script a bit which is executing in my browser but while still staying "inside the webpage" which is running so that I may normally make XHR requests to the server?

Also, although this is not in the title of the question, can I somehow proxy the XHR request to my script but while not breaking the CORS rule?

Why is it so different if I run the same thing from my browser and from a saved HTML on my desktop? I have the same IP and am doing the same thing but from the url it "feels like" I'm running it from somewhere else. Can I somehow imitate that I'm running "from the webpage" but instead run it from a modified saved html?

sideshowbarker
  • 62,215
  • 21
  • 143
  • 153
ditoslav
  • 3,572
  • 8
  • 31
  • 61
  • What do you mean with "locally"? Your browser is local too and the javascript as well.. – greenhoorn Jul 06 '15 at 10:45
  • Thats what confuses me. I'm lacking the terminology but not sure where to find it. I'll edit the question – ditoslav Jul 06 '15 at 10:46
  • You are not the first and probably not the last that has come to this site asking how to "modify" the code for agar.io. This is not a hacking site, we can't tell you how to modify someone else's source, or how to stop them from detecting your "modifications". – Claies Jul 06 '15 at 13:02

1 Answers1

3

You could proxy, given there isn't a cross domain protection mechanism or some sort of logging in (which complicates stuff).

What you could very well do is use a browser extension which allows you to add CSS, HTML and JavaScript.

I'm not entirely savvy on extensions so I'm not sure you can modify existing code but I'm guessing that if you can add arbitrary JS code you may very well replace the script tag containing the game for a similar personally modified script based on it. It's worth a try...

Link to getting started with chrome extensions

Update:

If you're set on doing it, proxying ammounts to requesting an URL with your application and do something with the page (html) instead of the original source. I assume you want to change the page and serve it to your browser.

With this in mind you will need the following, I dont know C# so you'll have to google around for libraries and utilities:

  • a way to request URLs (see link at bottom)
  • a way to modify the page, you need a DOM crawler
  • a way to start said process and serve it to your browser by hitting your own URL, meaning you need some sort of web server

I found the following question specifically on proxying with C#

Community
  • 1
  • 1
JSelser
  • 3,151
  • 1
  • 17
  • 33
  • Do you have any suggestions on where to start reading about proxying? I would actually like to figure out how to maybe proxy this to a C# application. I'm mostly confused as to how the whole identification of who's actually running the code is done and how to do some pretending – ditoslav Jul 06 '15 at 18:57