@@ -82,7 +82,7 @@ function start(maxPosts, waitMin, waitMax) {
82
82
const btns = Array . from ( document . querySelectorAll ( selector ) ) ;
83
83
84
84
if ( ! btns . length ) {
85
- alert ( "Không tìm thấy bài nào" ) ;
85
+ alert ( "Không tìm thấy người nào để mời " ) ;
86
86
return ;
87
87
}
88
88
@@ -101,12 +101,16 @@ function start(maxPosts, waitMin, waitMax) {
101
101
count : 0 ,
102
102
} ;
103
103
104
+ let container ;
104
105
while ( window . fb_group_ext . count < maxPosts && ! window . fb_group_ext . stop ) {
105
106
if ( btns . length > 0 ) {
106
107
const btn = btns . shift ( ) ;
107
108
109
+ container = findParent ( btn , ".html-div" ) ?. children ?. [ 0 ] ;
110
+ console . log ( container ) ;
111
+
108
112
btn . scrollIntoView ( { block : "start" , behavior : "smooth" } ) ;
109
- console . log ( "click" , btn ) ;
113
+ // console.log("click", btn);
110
114
btn . click ( ) ;
111
115
112
116
window . fb_group_ext . count ++ ;
@@ -115,18 +119,26 @@ function start(maxPosts, waitMin, waitMax) {
115
119
await sleep ( waitTime , ( ) => window . fb_group_ext . stop ) ;
116
120
} else {
117
121
// scroll to end
118
- window . scrollTo ( 0 , document . body . scrollHeight ) ;
122
+ if ( container ) container . scrollTo ( 0 , container . scrollHeight ) ;
123
+ else window . scrollTo ( 0 , document . body . scrollHeight ) ;
124
+
119
125
// wait for load more
120
126
await sleep ( 1000 ) ;
121
127
}
122
128
}
123
129
124
130
window . fb_group_ext . running = false ;
125
- alert ( "Duyệt xong " + window . fb_group_ext . count + " bài " ) ;
131
+ alert ( "Mời xong " + window . fb_group_ext . count + " người " ) ;
126
132
}
127
133
128
134
main ( ) ;
129
135
136
+ function findParent ( ele , selector ) {
137
+ if ( ! ele ) return null ;
138
+ if ( ele . matches ( selector ) ) return ele ;
139
+ return findParent ( ele . parentElement , selector ) ;
140
+ }
141
+
130
142
function ranInt ( min , max ) {
131
143
return Math . floor ( Math . random ( ) * ( max - min ) + min ) ;
132
144
}
0 commit comments