Repository navigation
Expand file tree
/
Copy pathserver.js
More file actions
73 lines (60 loc) · 1.84 KB
/
Copy pathserver.js
File metadata and controls
73 lines (60 loc) · 1.84 KB
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
const { By, Builder } = require("selenium-webdriver");
const dotenv = require("dotenv");
dotenv.config();
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function clickButton(driver, xpath) {
const button = await driver.findElement(By.xpath(xpath));
await button.click();
}
async function enterInput(driver, inputName, value) {
const inputField = await driver.findElement(By.name(inputName));
await inputField.sendKeys(value);
}
async function login(driver) {
await clickButton(
driver,
"/html/body/div[2]/div[1]/div[2]/ul[2]/li[2]/button"
);
await enterInput(driver, "user", process.env.LOGIN);
await enterInput(driver, "pass", process.env.PASSWORD);
await enterInput(driver, "pass", "\n");
await sleep(1000);
}
async function navigateToDesignPage(driver) {
await clickButton(
driver,
"/html/body/div[6]/div[1]/div[2]/div[2]/div/ul[1]/li[5]"
);
}
async function scrollToBottom(driver) {
await driver.executeScript("window.scrollTo(0, document.body.scrollHeight)");
}
async function navigateToFavorites(driver) {
await sleep(1000);
await clickButton(
driver,
"/html/body/div[6]/div[1]/div[3]/div/div[2]/div[1]/div/a"
);
await sleep(1000);
}
async function vote(driver) {
for (let i = 0; i < 5000; i++) {
await clickButton(
driver,
"/html/body/div[6]/div[1]/div[3]/div/div[1]/div[1]/div[1]/ul/li[3]/form/div[2]/button"
);
await sleep(800);
}
}
(async function StardollVote() {
let driver = await new Builder().forBrowser("chrome").build();
await driver.get("https://www.stardoll.com/br/");
await login(driver);
await navigateToDesignPage(driver);
await scrollToBottom(driver);
await navigateToFavorites(driver);
await vote(driver);
await driver.quit();
})();