credits: me
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HomeBox6441_Reboot
{
class Program
{
private static bool completed;
private static WebBrowser browser;
[STAThread]
static void Main(string[] args)
{
var start = DateTime.UtcNow;
browser = new WebBrowser();
browser.Navigate("http://192.168.1.1/restore.htm");
browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
while (!completed)
{
Application.DoEvents();
Thread.Sleep(1);
}
// override javascript window confirm function to return always true
var head = browser.Document.GetElementsByTagName("head")[0];
var script = browser.Document.CreateElement("script");
script.SetAttribute("type", "text/javascript");
script.SetAttribute("text", "window.alert = function () { }; window.confirm=function () { return true; }; ");
head.AppendChild(script);
// click the 'Neu starten' button
HtmlElementCollection elemenets = browser.Document.All;
foreach (HtmlElement e in elemenets)
{
if (e.GetAttribute("value") != null && e.GetAttribute("value").Equals(("Neu starten")))
{
e.InvokeMember("Click");
Console.WriteLine("Clicked");
break;
}
}
while(start.AddSeconds(10) > DateTime.UtcNow)
{
Application.DoEvents();
Thread.Sleep(1);
}
}
static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
Console.WriteLine(browser.Document.Body.InnerHtml);
completed = true;
}
}
}