Is there anyway to inject JavaScript so that I can tell every time JavaScript is executed in the web page?
For instance suppose a button triggers some function foo("bar") ... I would like to inject JavaScript such that when a user clicks the button another function is called first and passed the function name "foo" and arguments "bar".
The reason I want to do this is that I'm trying to mirror one users actions to another remote user -- so that as one user clicks I could intercept the JavaScript function send it over via node.js to the other user and execute the same function on the second users side programatically.
load the webpage in google chrome
open the developer tools (either via the wrench menu or with shift+ctrl+j)
activate the Scripts tab
click the little 'pause' symbol to the right of the page
Now, as soon as any javascript gets executed, chrome will show you the code and wait for your instructions.
Related
I am trying to make a bot that automatically plays a game on a web page. As of right now, I can navigate to the website, sign in, and load the game page, but I am stuck here.
I would like to inject a script at the webpage level that uses jQuery to constantly scrape the webpage and determine what state the game is in. When a certain event happens, I want the script to fire a custom event(?) that would notify a function at the Node.js./Puppeteer level to execute. My problem is that I do not understand how to make Puppeteer react when a custom event from the page is fired.
For example, let's say we have a webpage level function that is on a 1 second timeout that scrapes the webpage for X. When X is found, I want to scrape Y data off the webpage and send it up to the node level. When Y is received at the node level, it moves the mouse to Y location, or do something else with Y that cannot be done at the browser level.
I'm not sure if this is the most appropriate way to handle this kind of task, but trying to understand how async and promises work on the Node.js level without being able to use jQuery to select elements is giving me an advanced form of terminal ebola AIDS.
This answer has couple of different ways how to send data back from an injected script to your Node.js code:
Communicate "out" from Chromium via DevTools protocol
I am developing a wp application in which there is a webbrowser which loads a web page. I want to add javascript file which fills a text box in loaded web page with some data and click on submit button. I want this javascript file to run automatically once webbrowser tool loads web page completely.
When the web browser completely loads a page, the Navigated event will fire.
In the event handler, you can execute arbitrary JavaScript code by calling theBrazza.InvokeScript( "eval", SomeJavaScriptSource ); where SomeJavaScriptSource is a variable or constant containing the JavaScript you’d like to run (just don't forget to specify IsScriptEnabled="True" in your web browser).
If your page already has any JavaScript code in it - you'll be fine, otherwise this approach wont work: that thread is old, however now in Windows Phone 8 the problem is still present :-(
I'm trying to call element.requestfullscreen() function but i get following warning on mozilla console..
Request for full-screen was denied because Element.mozRequestFullScreen() was not called from inside a short running user-generated event handler.
I know what it means but how can still i call it using that event which is not connected to any element?
You're receiving the error because requestFullScreen requires a user action (generally a click, or key press) to launch into full screen. This is to prevent sites completely hijacking your browsing experience, and from embedded (or untrusted) content from trying to launch full screen, without proper action.
In order to fix this, you'll need to have the requestFullScreen trigger on a chain, that starts with that user action.
Here is a link to the relavent security/privacy considerations of full screen in the w3 spec.
I would like to know if there is javascript or jquery code I can use to check if a link would redirect the current page, instead of a it opening a new webpage.
I am using ruby on rails and on my site there are links that redirect and links that open a new webpage. I need js that executes when a user clicks on any of the links, if the link redirects, it should prompt a confirmation message then executes the link to redirect.
The only ways I'm aware that a link can open a new page are:
Downloading an attachment (not inline)
Running 'window.open' directly or through an event callback
Unfortunately, it can be extremely difficult to reliably determine through javascript inspection if these are going to happen. This is because you'll need to perform reflection on the event chain to check the javascript code, and you'll need to call the server (via ajax call) to check for a data attachment.
The simplest way to do this is to manually examine your own site and see where these are happening. Then modify the 'click' event to confirm before proceeding.
I'm writing an app which should load a website. After the website is loaded, I have to fire up a 2nd command to the web page, which is kind of Javascript scriptlet.
I did this manually in my browser and in generally it seems to work fine. They way I did it manually was I created two shortcuts in my browser:
the URL to this website (e.g. http://www.example.net/123456-e.aspx)
the shortcut to a Scriptlet which calls a function on this website (e.g. javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')).
I first click the URL shortcut and after its loaded, I fire up the 2nd shortcut.
But how can I do this in a C# application?
But, what I'm trying to do is quite the opposite I think.
I'd like to SEND a _postBack to an existing site.
I'm not writing my own site which contains a postBack control!
Let me explain a little in detail...
the site I'm loading in my app is an existing ASPX site in the web.
In this site, you'll find several _doPostback entries and in a browser, the postBack event (when I hit it manually within a bookmark/shortcut) will be send back and has its desired result (in this case, its assigning "5 stars" to tell everybody, that something is supergood ;-).
So, what I'd like to do is to write my C# App which will send this _postBack command every time I hit the OK button or some other events.
Just as it is with my link above
"javascript:__doPostBack('Video_Info1$Rating_control1$lnk_star5','')"
This is the bookmark I have on my browsers bookmark panel - a shortcut!
.... Just to be honest, its a kind of cheat, which will do an automatic voting on an external site...
My prob is now,... how can I send this _postBack straight to the site, to increase my stars?
I am not sure what exactly you are trying to achieve, The code which you are seeing (_doPastBack(..)) is actually going to invoke a server method (code in your codebehind of that page).
You can create a webpage and have an iframe and load your first page in that.The user will be able to click on any of the button and invoke the corresponding server code if there is one attached.
<html>
<body>
<iframe src="http://www.example.net/123456-e.aspx"></iframe>
</body>