I have a WebView in UWP which is getting some html content (including javascript).
I need a way to track actions performed on the Webview content, for instance if the user has clicked a button I would like to know.
I know https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview.scriptnotify
but for this to work javascript has to call window.external.notify().
But the problem is that I don't own this content and it doesn't make sense to ask the owners to change their handler to publish this window.external.notify().
So, is there any way I can track all the user actions without modifiying the content?
I don't think you can accomplish what you're wanting to do with the UWP web viewer.
One alternative to consider is CefSharp which has a WPF implementation of Chromium.
It gives you a lot of hooks and handlers to intercept requests and do a lot of custom work on JavaScript that you don't control. I used it to build a WPF based help system and it allowed me to intercept links to PDFs and videos so that I could display them in special viewers.
Related
I haven't looked into it very much but am struggling to find relevant information on the topic. I basically want to create a browser that applies a filter to a webpage by changing colors in a webpage. My guess is that I will have to change the html once loaded or something, would this work? Do I have other options?
PS. I don't just want to make every color darker, I would more like to invert the colors.
Edit:
If any you were wondering, I am talking about the XAML browser component that can be used in a Windows Phone application.
I think the simplest way to do that is to inject some Javascript into your page once it has loaded.
To do that, you need to set the IsScriptEnabled to true on your WebBrowser control and then subscribe to the Navigated event.
When that event occurs you can inject some JS codeby using the WebBrowser.InvokeScript method.
Here is an example of JS code that darken the page : JavaScript: Invert color on all elements of a page
If you are talking about in a PC internet browser, you can find an add-on to execute Javascript automatically, such as Greasemonkey for Firefox. If you are talking about Windows Phone's Internet Explorer, I don't really know what you could do there, as I don't think they allow add-ons.
I want to be able to use the .NET WebBrowserControl to record and repeat user actions to automate the collection and retrieval of text from web pages for a data extraction tool that I'm building, but am unsure about how to best approach this.
I specifically want to use the .NET WebBrowserControl as it can be embedded in a .NET form and also used within a server side process without a UI. I'm aware that there are other means of recording and repeating user actions such as Selenium, but for now I am interested in a solution around the web browser control (just to keep answers focused).
Actions to be recorded are those such as button clicks, drop down list selection, link clicks etc.
Potential solutions I have looked at so far:
(Please correct me if my notes based on brief evaluations are wrong)
iMacro (doesn't appear to have a component that can be used within a project, to record user actions, rather the GUI has to be used).
WaitN - Good for programmatic play back - but no recording facility that can be hooked up to the web browser control?
I'm presuming this is possible as services like Mozenda appear to make use of the WebBrowserControl, or some IE like version based on mshtml.dll.
Are there any other options I can look at?
Any insight would be appreciated.
yap, as in Mozenda ,when user create any action like goto mainpage>click on images>download image etc... the XPath is recorded with the each page url into XML file. So, use self learning algorithm to implement such kind of XML better way than mozenda.
i have developed one application using JSOUP and Regular Expression Parsing works same as mozenda do. i created the configuration file which contains the XPath of all the items you want . Which works great for me.
Hope this helps,
I am currently playing a little bit around with the development environment. At the moment I am writing a small app, which adresses a Webbrowser-Control.
Therefore I was looking for an opportunity, to show the URL-bar and maybe manipulating the URL via input of the user. Is this anyway possible, or not implemented for the webbrowser control?
Thanks in advance!
The WebBrowser control itself doesn't have a URL bar. It is simply a control that has the ability to display HTML and run Javascript. The easiest way way to simulate one would be to create a textbox. You can then use its Navigate method to load the webpage:
myWebBrowserControl.Navigate(myTextboxUrl.Text);
Alternatively, you can use the WebBrowserTask, but your app loses all control of the user's activities within this task.
I think it'd be easier to just launch the web browser task directly. Customizing the URL bar would probably require rolling your own.
Here's a related question about opening the browser: Open webbrowser with specific url in WP7
I would like to integrate moneybookers payment-gateway into a WPF-application. Accroding to the official gateway manual I need to redirect the user to the moneybookers payment-page and submit some fields posted within an html-form.
Has anyone an idea how I could solve this task?
Best regards!
Yes, all you need to do is:
Include a Frame control in your WPF application.
Include a .html file in your WPF application that contains a element with the appropriate data and some JavaScript to automatically post the form when the page is loaded.
When it is time for payment, have your display the Frame control and set its Url to the relative path of the .html file.
When the user is done paying you can give them a button to close the Frame yourself, or you can subscribe to the Navigated event on the Frame and when the payment processor causes them to navigate back to your fake HTML you can automatically close the Frame and use your own WPF UI to tell them "congratulations, thanks for paying".
I have a WinForms program written on .NET 2 which hosts a webbrowser control and renders asp.net pages from a known server.
I would like to be able to drag, say, a tree node from a treeview in my winforms app into a specific location in the hosted web page and have it trigger a javascript event there.
Currently, I can implement the IDocHostUIHandler interface and getting drag\drop events on the browser control, then call Navigate("javascript:fire_event(...)") on the control to execute a script on the page. However, I want this to work only when I drop data on a specific part of the page.
One solution, I suppose, would be to bite the bullet and write a custom browser plugin in the form of an activex control, embed that in the location I want to drop to and let that implement the needed drag\drop interfaces.
Would that work?
Is there a cleaner approach? Can I take advantage of the fact that the browser control is hosted in my app and provide some further level of interaction?
Take a look at the BrowserPlus project at Yahoo.
It looks like they have built a toolkit so that you don't have to do the gritty work of writing the browser plugin yourself.
If you can find out the on screen position of the part of the page you are interested in, you could compare this with the position of the mouse when you receive the drop event. I'm not sure how practical this is if you can get the info out of the DOM or whatnot.
As an alternative could you implement the mouse events on the bit of the page using javascript?