· 5 years ago · May 31, 2020, 06:58 AM
1Imports CefSharp
2Imports CefSharp.WinForms
3Imports System.Net
4
5Public Class Form1
6
7 Dim r1 As Integer
8 Dim fname As String
9 Dim lname As String
10 Dim remail As String
11 Dim fnamefp As String = "C:\Users\johan\OneDrive\Desktop\fname.txt"
12 Dim lnamefp As String = "C:\Users\johan\OneDrive\Desktop\lname.txt"
13
14 Private WithEvents browser As ChromiumWebBrowser
15 Public Sub New()
16
17 ' This call is required by the designer.
18 InitializeComponent()
19 ' Add any initialization after the InitializeComponent() call.
20
21 End Sub
22 Private Sub Button5_Click(sender As Object, e As EventArgs) Handles TargetURLButton.Click
23 browser.Load(TargetURLValue.Text)
24 End Sub
25
26 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
27
28 Dim setting As New CefSettings
29 setting.RemoteDebuggingPort = 8080
30 CefSharp.Cef.Initialize(setting)
31 browser = New ChromiumWebBrowser("") 'With {
32 '.Dock = DockStyle.Fill
33 '}
34 WebBrowser1.Controls.Add(browser)
35
36 Dim IP As New WebClient
37 IPValueLabel.Text = IP.DownloadString("http://ifconfig.me/ip")
38
39 If IPValueLabel.Text = "##.###.###.##" Then
40 IPValueLabel.ForeColor = Color.Red
41 Else
42 IPValueLabel.ForeColor = Color.Green
43 End If
44
45 End Sub
46 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles NameTestButton.Click
47
48 Dim r1 As Integer
49 Randomize()
50 r1 = Int(Rnd() * 6) + 1 'Random interger is made up till 6 becuase the text file only contains 6 names.
51
52 Dim fpicker As String = System.IO.File.ReadAllLines(fnamefp)(r1) 'Reads and stores the name chosen from the list with r1 being the line number.
53 fname = fpicker 'it is then stored in a Global variable.
54 FirstNameValueLabel.Text = fname 'Displays the name to the user.
55
56 'Problem Starts with this code
57 Dim fscript As String = <js><![CDATA[document.all("FirstNameID.text").value = 'fname';]]></js>.Value
58 'The code snippet above is not working, It won't input the value onto the websites 'name' textbox from FirstNameID.text and fname.
59 'FirstNameID.text is what the user will input. It is the element ID of the 'name' textbox in a website.
60 'fname is a string varible in which the program should input into the websites email textbox.
61 'My theory on why the code doesn't work is becuase its 2 different programming languages. 2 varibles are from VB .NET and the script is javascript.
62 browser.ExecuteScriptAsync(fscript) 'Executes the javascript
63
64 Randomize()
65 r1 = Int(Rnd() * 6) + 1 'Random interger is made up till 6 becuase the text file only contains 6 names.
66
67 Dim lpicker As String = System.IO.File.ReadAllLines(lnamefp)(r1) 'Reads and stores the name chosen from the list with r1 being the line number.
68 lname = lpicker 'it is then stored in a Global variable.
69
70 If LastNameIDValue.Text = "" Then 'Some websites only need your first name so if the Element ID is "" then there is no need to show the generated name to the user.
71 LastNameValueLabel.Text = "None" 'However it is still generated to make the random email.
72 Else
73 LastNameValueLabel.Text = lname 'Displays the name to the user if the Element ID is present.
74 'Problem Starts with this code
75 Dim lscript As String = <js><![CDATA[document.all("LastNameID.Text").value = 'lname';]]></js>.Value
76 'The code snippet above is not working, It won't input the value onto the websites 'name' textbox from LastNameID.text and lname.
77 'LastNameID.text is what the user will input. It is the element ID of the 'name' textbox in a website.
78 'lname is a string varible in which the program should input into the websites email textbox.
79 'I think the code doesn't work becuase its 2 different programming languages. 2 varibles are from VB .NET and the code is javascript.
80 browser.ExecuteScriptAsync(lscript) 'Executes the javascript
81 End If
82
83 End Sub
84
85 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles EmailTestButton.Click
86
87
88 Randomize()
89 r1 = Int(Rnd() * 2020) + 1 'A random integer is made. So that it can be added to the random email that will be generated below.
90
91 remail = fname + lname + r1.ToString + "@gmail.com" 'Fname and Lname are names pre-picked from a text file stored on to the computer and is then stored in a variable.
92 EmailValueLabel.Text = remail 'The user is shown the generated e-mail in a label.
93
94 'Problem Starts with this code
95 Dim EmailScript As String = <js><![CDATA[document.all("EmailIDValue.text").value = 'remail';]]></js>.Value
96 'The code snippet above is not working, It won't input the value onto the websites email textbox from EmailIDValue.text and remail
97 'EmailIDValue.text is what the user will input. It is the element ID of the email textbox in a website.
98 'remail is a string varible in which the program should input into the websites email textbox.
99
100 browser.ExecuteScriptAsync(EmailScript) 'Executes the Script
101
102
103
104 End Sub
105
106
107End Class