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.
Related
I tried WebBrowser but any solution related to WebBrowser I find uses the exact same codes, WebBrowser.DrawToBitmap
Problem with that is, it gives out inaccurate results depending on URL, to what page actually would look like, sometimes even blank pages.
So I am looking for any alternate solution to WebBrowser if there is any.
It needs to run in background, as in not open any browser on screen, render it in background with all scripts and get an image.
If I understand what you're trying to do, you might be interested in a framework called PhantomJS, which is a WebKit "browser" engine which runs the pages without visually rendering them. It can be used to capture screens.
Now this technique requires JavaScript, but there is something called Selenium WebDriver to help you wrapping that. Users here at SO posted a simple example and this comment looks useful as it contains the list of required Packages.
[edit] It is a requirement that the webpage spawn and open in IE and allow user manual interaction after the programmatic actions have completed.[/edit]
I've seen a lot of code examples online about opening webpages or filling in webpage textboxes and getting a return value without ever opening them visibly.
I would like to open a webpage in IE, fill in a few textbox buttons
and then click the submit button and view the results visibly.
I am able to do this with a dll called Selenium, but I do not want to use a 3rd party application and it seems that WebBrowser() should be able to do this?
I can post my failed code examples if that would help.
Thanks.
Maybe this qould fit better as a comment, but I don't have enoigh reputation.
Do you know how HTTP-Forms work?
It would probably be easier to send a HTTP-Request to the target of the form you want to fill, including the parameters you would like to fill into the form.
So you don't need any WebBrowser or similar, just a simple HttpWebRequest object, where you specity the target, the method (very likely POST) and the data you'd like to send.
You can use the webbrowser control in Winforms. It is possible to access every DOM object of the website using the control. No need to open the IE externally.
You just need to specify the webbrowser URL as your link.
Then, fill the textboxes with code,
BrowserID.Document.GetElementById("TextboxID").SetAttribute("Value", "NewVaue")
Also, you can click on the button using InvokeMember("click").
There are lots of stuff using WebBrowser. You can learn it here.
I am using a picture box in my C# application, I want it to cover a certain portion of the web browser (the username part on youtube).
I have a 21.5" monitor and this is what it looks like to me:
But then this is what it looks like to one of my users with a 24" monitor:
As you can see the position of the picture box has moved up due to that persons screen size (I believe)
Is there a way to make sure that it will always be over that section of the web browser or moving it to that section of the web browser?
Thanks.
I am convinced your approach is wrong and would break anytime either for screen resolution or size changes, or for using the mouse-wheel to zoom in/out the page or whatever. it is just unreliable and patching this by overlapping another UI control like a picture box or a panel on top of what you want to hide is simply insecure and unreliable.
I think the tow real options you have are these:
You try to interpret the page content and remove from the page's DOM the information you do not want to show to the user (eventually HTML Agility Pack could help for this DOM parsing and manipulation but I am not sure if you can read what the WebBrowser control is showing and inject changes into it);
use the YouTube APIs and Tools - .NET APIs to load the videos and details you want to load and show but rendering this information with your specific UI elements in your windows forms application, without using a browser to show the normal YouTube site.
Probably the second option takes more work but is more secure, I am not sure 100%, as I said, if the first option is viable at all. You could search for HTML Agility Pack and web browser control to see if anybody has done this before already :)
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 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?