![]() |
|
What's wrong with this JS code? - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: What's wrong with this JS code? (/Thread-What-s-wrong-with-this-JS-code) |
What's wrong with this JS code? - Cyb3rNuX - 01-07-2019 So I was making simple javascript code for auto-following on Instagram: follows 25 users, then waits for 10 minutes and does it again. Yet I get this exception (when pasting it into console on Instagram website): Uncaught SyntaxError: await is only valid in async function on line 11 Code: start:
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var items = document.querySelectorAll("._0mzm-");
for (var i = 0; i < 25; i++) {
if (items[i].innerText === "Follow") {
items[i].click();
}
}
await sleep(601500);
goto start;I believe it's something up to waiting function (obviously), but I'm not sure how to fix it. Any ideas? RE: What's wrong with this JS code? - mothered - 01-08-2019 If I'm not mistaken, the await can only work within an async function, hence the syntax error. Try wrapping the await within the async function. RE: What's wrong with this JS code? - Hoss - 01-08-2019 Did you know God kills innocent kittens when you write code like that? Like... brutally murders them and laughs. I did this to save lives: Code: setInterval(() => {
let items = document.querySelectorAll('._0mzm-')
let bound = items.length >= 25 ? 25 : items.length
for (var i = 0; i < bound; i++) {
if (items[i].innerText === 'Follow') {
items[i].click()
}
}
}, 601500)You may also want to experiment with variable sleep times along with spreading requests over proxies. DM me if you have questions. RE: What's wrong with this JS code? - Cyb3rNuX - 01-09-2019 (01-08-2019, 06:18 AM)mothered Wrote: If I'm not mistaken, the await can only work within an async function, hence the syntax error. I guess that's what return exception was saying, but I didn't understand any of it. (01-08-2019, 08:09 AM)Hoss Wrote: Did you know God kills innocent kittens when you write code like that? Like... brutally murders them and laughs. Seems to work like a charm, thank you for this
RE: What's wrong with this JS code? - Hoss - 01-09-2019 I've never tried working with Instagram's website before but I would assume this would keep clicking the same 25, unless you have another part of the script you didn't post. RE: What's wrong with this JS code? - Cyb3rNuX - 01-09-2019 (01-09-2019, 04:18 AM)Hoss Wrote: I've never tried working with Instagram's website before but I would assume this would keep clicking the same 25, unless you have another part of the script you didn't post. I had it running for quite some time now and looks like it runs the code only once, instead of repeating it every n milliseconds. Or maybe it's clicking the same 25 as you said, but I need it to click on new "Follow" buttons. Any idea? RE: What's wrong with this JS code? - Hoss - 01-09-2019 (01-09-2019, 05:15 AM)Cyb3rNuX Wrote:(01-09-2019, 04:18 AM)Hoss Wrote: I've never tried working with Instagram's website before but I would assume this would keep clicking the same 25, unless you have another part of the script you didn't post. How many results populate the page on which you're running the script? RE: What's wrong with this JS code? - Hoss - 01-09-2019 If you are looking to make this into a business I can write you a much more efficient and effective headless application you can throw up on a VPS. PM me if you're interested. RE: What's wrong with this JS code? - Cyb3rNuX - 01-11-2019 (01-09-2019, 05:42 AM)Hoss Wrote: How many results populate the page on which you're running the script? Not sure what do you mean by results, but before I inject the script, I open "following" window on random account, which is showing list of other random accounts with "follow" button (the one that script is clicking on). Script is supposed to click X number of those buttons, then wait X time and loop, but do NOT click on same follow buttons (e.g re-follow/unfollow same accounts from previous loop), but to follow new ones (e.g every 15 minutes). Hope that's what you asked ![]() (01-09-2019, 06:31 AM)Hoss Wrote: If you are looking to make this into a business I can write you a much more efficient and effective headless application you can throw up on a VPS. PM me if you're interested. Thank you but I just want to "advertise" my hobby IG account, I'm not interested in something serious if you meant that, I just want to boost my account a little bit, but thanks again. |