Imports System.IO
Public Class Form1
Dim d As HtmlDocument
Dim source, log, waitloaded, CarTheft, CarTheft1, CarTheftC, CarTheftC1, CarTimer1, DoCrime, DoCrime1, CrimeTimer1 As String
Private Function GetCurrentWebDoc() As mshtml.HTMLDocument
Try
Return DirectCast(wb.Document, mshtml.HTMLDocument)
Catch ex As Exception
Return Nothing
End Try
End Function
Private Function GetCurrentWebForm() As mshtml.HTMLFormElement
Try
If GetCurrentWebDoc.forms.length > 0 Then
Return DirectCast(GetCurrentWebDoc.forms.item(0), mshtml.HTMLFormElement)
Else
Return Nothing
End If
Catch ex As Exception
Return Nothing
End Try
End Function
Public Function GetNumberOfLines(ByVal File_Path As String) As Integer
Dim SR As New StreamReader(File_Path)
Dim NumberOfLines As Integer
Do While SR.Peek >= 0
SR.ReadLine()
NumberOfLines += 1
Loop
Return NumberOfLines
SR.Close()
End Function
Private Sub NavInformation()
If wb.Url.ToString() = "http://www.barafranca.com/" Then
wb.Document.DomDocument.All("email").Value = "username"
wb.Document.DomDocument.All("pass").Value = "password"
For y = 0 To wb.Document.DomDocument.Forms.length - 1
For x = 0 To wb.Document.DomDocument.Forms(y).elements.length - 1
If wb.Document.DomDocument.Forms(y).elements(x).Value = "Login" Then
wb.Document.DomDocument.Forms(y).elements(x).Click()
Exit For
End If
Next x
Next y
End If
If wb.Url.ToString() = "http://www.barafranca.com/game.php" Then
wb.Navigate("http://www.barafranca.com/information.php")
End If
End Sub
Private Function StealCar()
CarTheft = ReadALine(log, GetNumberOfLines(log), 58)
CarTheft1 = Microsoft.VisualBasic.Left(ReadALine(log, GetNumberOfLines(log), 58), 6)
CarTheftC = ReadALine(log, GetNumberOfLines(log), 68)
CarTheftC1 = Microsoft.VisualBasic.Left(ReadALine(log, GetNumberOfLines(log), 68), 6)
If CarTheft1 = "oTimer" Then
If Len(CarTheft) = "20" Then
CarTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 58), 5)), 3)
ElseIf Len(CarTheft) = "19" Then
CarTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 58), 4)), 2)
ElseIf Len(CarTheft) = "18" Then
CarTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 58), 3)), 1)
End If
ElseIf CarTheftC1 = "oTimer" Then
If Len(CarTheftC) = "20" Then
CarTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 68), 5)), 3)
ElseIf Len(CarTheftC) = "19" Then
CarTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 68), 4)), 2)
ElseIf Len(CarTheftC) = "18" Then
CarTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 68), 3)), 1)
End If
Else
CarTimer1 = "0"
End If
End Function
Public Function ReadALine(ByVal File_Path As String, ByVal TotalLines As Integer, ByVal Line2Read As Integer) As String
Dim Buffer As Array
Dim Line As String
If TotalLines < Line2Read Or Line2Read = 0 Then
Return "No such line exists"
Else
Line2Read -= 1
Buffer = File.ReadAllLines(File_Path)
Line = Buffer(Line2Read)
Return Line
End If
End Function
Private Function DoCrimes()
DoCrime = ReadALine(log, GetNumberOfLines(log), 55)
DoCrime1 = Microsoft.VisualBasic.Left(ReadALine(log, GetNumberOfLines(log), 55), 6)
If DoCrime1 = "oTimer" Then
If Len(DoCrime) = "20" Then
CrimeTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 55), 5)), 3)
ElseIf Len(DoCrime) = "19" Then
CrimeTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 55), 4)), 2)
ElseIf Len(DoCrime) = "18" Then
CrimeTimer1 = Microsoft.VisualBasic.Left((Microsoft.VisualBasic.Right(ReadALine(log, GetNumberOfLines(log), 55), 3)), 1)
End If
Else
CrimeTimer1 = "0"
End If
End Function
Private Sub GetTimerSource()
If wb.Url.ToString = "http://www.barafranca.com/information.php" Then
Timer2.Enabled = "True"
End If
End Sub
Private Sub GetSource()
Try
Dim savef As New System.IO.StreamWriter(log)
savef.Write(source)
savef.Close()
Catch ex As IOException
MessageBox.Show(ex.Message)
End Try
DoCrimes()
'StealCar()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
log = "C:\Users\Frederic\Documents\stuff\log.txt"
End Sub
Private Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wb.DocumentCompleted
Dim d As HtmlDocument
d = wb.Document
source = d.Body.InnerHtml
NavInformation()
UrlText.Text = wb.Url.ToString()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoButton.Click
wb.Navigate(UrlText.Text)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
CrimeTimer1 = CrimeTimer1 - 1
CarTimer1 = CarTimer1 - 1
If CarTimer1 < 0 Then
CarTimer1 = 0
End If
If CrimeTimer1 < 0 Then
CrimeTimer1 = 0
End If
CrimeTime.Text = CrimeTimer1
CarTime.Text = CarTimer1
End Sub
Private Sub TestButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TestButton.Click
GetSource()
End Sub
Private Sub wb_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wb.Navigated
GetTimerSource()
End Sub
Private Sub Timer2_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer2.Tick
waitloaded = waitloaded + 1
If waitloaded > 1 Then
waitloaded = 0
Timer2.Enabled = "false"
End If
End Sub
End Class