-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstaScript.ahk
136 lines (94 loc) · 3.5 KB
/
instaScript.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
InstaScript() {
; Get list of hashtags from hashtags.txt
hashtags := Object()
Loop, read, % A_ScriptDir "\hashtags.txt"
hashtags[A_Index] := A_LoopReadLine
; How many posts we want to like
Posts = 3 ; 15
; How many posts we have liked
LikedPosts = 0;
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := true
For i in hashtags {
; The hashtag we want to like
hash := hashtags[i]
StringReplace , hash, hash, %A_Space%,,All
HashTag := hash
; Stuff we need for the script to work
Url = https://www.instagram.com/explore/tags/%HashTag%/
QuerySelector = a[href*='%HashTag%']
wb.Navigate(Url)
while wb.busy or wb.ReadyState != 4
Sleep 0
; wait 5 seconds before getting the links so that the page is populated
Sleep 2000
; this is the first link on the page
Links := wb.document.querySelectorAll(QuerySelector)
; Click that first link
Links[0].Click()
; Loop through 15 posts
Loop %Posts% {
; Set Variables for Like action Interval
low = 10 ; 42
high = 15 ; 60
Random, Time_To_Wait, low, high
; Set variable for Randomizer
Random, FRand, 1, 5
; This will click through a random number of times so that we aren't liking every post in a row.
; It will only do it if the FRand number is three though, so it is programmed chaos.
if FRand = 3
{
Random, ClickTimes, 1, 5
Loop %ClickTimes% {
; Get the next arrow
NextArrow := wb.document.getElementsByClassName("_3a693")
Sleep 3000
if NextArrow[0] {
NextArrow[0].Click()
} else {
break
}
}
}
InnerLinks := wb.document.getElementsByClassName("_eszkz _l9yih")
; Wait this long before liking the post and moving on to the next
Sleep, Time_To_Wait * 1000
; This only likes the post if we haven't liked it already.
if (wb.document.getElementsByClassName("coreSpriteHeartOpen").length > 0) {
; Click that heart
InnerLinks[0].Click()
LikedPosts += 1
}
Random, FollowRand, 1, 10
; Randomly follow people.
if FollowRand = 2
{
FollowLink := wb.document.getElementsByClassName("_qv64e")
Sleep 3000
if FollowLink[0] {
FollowLink[0].Click()
} else {
break
}
}
; Get the next arrow
NextArrow := wb.document.getElementsByClassName("_3a693")
Sleep 4000
if NextArrow[0] {
NextArrow[0].Click()
} else {
break
}
}
}
if (i == hashtags.length) {
Sleep 3600000
instaScript()
}
}
instaScript()
Esc::ExitApp