Running Browser as terminal process - javascript

I am trying to do some high scale testing with my nodejs server so I want to find out how its possible to run the chrome browser on the terminal, similar to how nodejs runs the server.
I want to have a few hundred on a single machine which is why I want to avoid running the actually browser tab instances. It also needs to specifically be google chrome.
Right now Im trying to figure out how this is possible, even if it's just somehow running the messaging javascript from the terminal.
Can someone please point me to the right direction :]

Have you looked into Request, CasperJS, or PhantomJS? I think they may be just what you're looking for. Phantom is a headless browser that can browse webpages for you (useful for testing, taking screenshots, and taking actions on pages for you). CasperJS can help you out with that, as well, and Request allows you to make http requests from your server, rather than client. If you need to search/ traverse the page your server gets back, you can also use Cheerio, which is pretty much jQuery for your server.
Hope that helps!

Related

How do I make a chrome extension that will take the current webpage and upload it to my custom domain via FTP so I can view it on a phone?

Overview
I am trying to make a Chrome Extension that takes the currently open html page and all its dependencies (CSS, JS) and uploads it to a custom domain via FTP. I would then be able to open it on my phone to make sure the website looks good on a phone.
Basically, I am trying to replicate the VSCode extension Live Server's functionality, but with it uploading the file to a custom domain. I know you'd normally be able to access live server's locally hosted server from a phone, but my university's internet setup doesn't seem to allow for this, hence my desire for an extension like this.
All I know about my hosting service is that it uses cPanel and supports FTP, which I assume is all I need. I can set up new FTP connections and logins. All the FTP details in the code will be hardcoded, but drawn from a separate file and .gitignored so they aren't in my commit history, which I hope is enough.
What I've Tried & What I'm Stuck On
I have most of the chrome extension stuff figured out; The FTP transfer process is what's giving me issues.
I first tried using chrome-app-ftp, but quickly realized that was old and was running into issues, so I switched to jsftp.
I used browserify to fix the "require" issue, and that cleared up some stuff.
I'm currently stuck on the following bug:
Error: TypeError: createConnection is not a function
I've done my research, and I do not think the error is because of an issue in my code; I believe that it is just a limitation of the tools I am using. This seems to be an issue with front-end JS not supporting the "net" module, which brings me to my question.
My Question
How do I circumvent my lack of support for the "net" module in the front-end? Do I need to set up some sort of local back-end for this with node or something like that? I have basically zero experience with anything back-end, so I might need pointed towards what sort of back-end is best for this. I more just need to know which tech stack is best for doing this.
If additional information is necessary I'll be checking back frequently and happy to help. Thanks in advance.

Browser timeout waiting for JSP to finish Java method

I really can't solve a problem: I've finished to write a web application during my internship which allows me, after a series of queries to Oracle DBs, to create my own tables on MySQL, then export the results in a custom fancy to XLS or PDF. The server side is in Java, the client side is in Javascript, some JQuery, and obviously HTML5. The server is set up with Apache Tomcat.
The method I use to run the queries and then export the results to a direct-download file (nothing stays in local, I use OutputStreams) is written in a jsp which I call by a button press from index.jsp.
As I was in local on my laptop with my own Tomcat, the browser waited patiently for the Java to end, then returned the generated files. Right now, after the remote deploy in a local server, the browser times out "casually" giving an err_no_response code. This happens both in Chrome and Firefox. The queries do take from 2 to 12 minutes to be done, and that's the problem.
I tried both polling with Ajax and websockets, but none of them worked: the firewall is in the way and I can't tunnel in a proxy it seems.
Any idea on how to keep the page alive while the server is running? Thanks.
PS: I can't edit indexes on the Oracle tables, nor alter them in any way. The queries are already quite optimized.
Also, I know I'm doing a lot of mistakes (plain Java code in JSPs...), yet this is the best I can do for now. Changing the whole logical structure of the code is hard at this point and I just need a painless solution to make everything work.

Is it possible to change script running clientside on a webpage?

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?
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#

how to create web pages in which network requests cannot be captured by browser's debugger

This doesn't involve coding. I am just curious on how to make a page like the one described below.
I came across a website where we can attend quiz/tests.
I tried to debug the browser so that I can see if I could hack through the codes by getting the values that are getting passed in debugger.
But to my surprise the debugger is not coming up when I click F12 in that page.
Somehow I opened debugger for that page and I clicked on the Network tab to capture requests that are sent.
But as I was proceeding through the test, not even one request is getting captured in the debugger but the answers are getting validated and scores are getting updated !! I was not even able to do inspect element
I guess its a java applet as i saw the below line in the the launch button
flagPlayerCourse = true;launchApplet(secureSessionId,courseName, courseType,winParams, use508);disablePlayButton(1, 0);
the url had SinglePassUserCmd.cfm?sessionid=3xxxxx
So my question is how can we create such a webpage in which the requests are not captured in the debugger!? I would be happy if someone could tell me how do the same in asp.net. In which language can we develop such web pages!?
Applets are completely different world. Its almost as good as running a .net application on your client machine.
What you see in the debugger are ajax requests and resources loading. If a site doesn't make them, you won't see any network requests in the browser.
That doesn't mean that you can't capture the data being send. You can always use a debugging proxy like fiddler to see what traffic is going across. Ofcourse a secure site would secure their traffic over https.
Applets require a java plugin in your browser. There are similar plugins like Silverlight, flash/shockwave(swf) that too can make network requests.

Any way to run Firefox with GreaseMonkey scripts without a GUI/X session

I need to build a small "monitoring" scraper for a 3rd party website (it's an external website that has stats about our visitors).
Unfortunately, this website is very hard to scrape through the normal "wget" mechanism, because it uses a ton of sophisticated JS, part of it generated by GWT. So my workaround was to create a GreaseMonkey script and then have this script call a PHP page that would log the scraped data. Then as soon as Firefox starts with this webpage-to-scrape, the script goes to work.
This works well, but now I am trying to make it more robust as far as monitoring tools go. I want it to run on the server using a cron job. As far as I understand such things, this requires a DISPLAY variable to be set and for an X session to exist (Firefox is refusing to run for me). Is there any nice way to allow it to run from the batchuser account as a cron job?
I've done something similar to get Selenium running headless on a server. I used Xvfb.
http://en.wikipedia.org/wiki/Xvfb
This article has some tips for using Xvfb with Firefox:
http://semicomplete.com/blog/geekery/xvfb-firefox.html
The best way to do that is to build Firefox in the headless mode: http://hg.mozilla.org/incubator/offscreen

Categories

Resources