-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (35 loc) · 1.04 KB
/
index.js
File metadata and controls
42 lines (35 loc) · 1.04 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
import SnapBot from "./snapbot.js";
import dotenv from "dotenv";
dotenv.config();
const bot = new SnapBot();
let credentials = {
username: process.env.USER_NAME,
password: process.env.USER_PASSWORD,
};
async function sendSnap() {
await bot.launchSnapchat({
headless: false, // makes the browser visible
args: [
"--start-maximized",
"--force-device-scale-factor=1",
"--allow-file-access-from-files",
"--use-fake-ui-for-media-stream", // Bypass permission prompt
"--enable-media-stream",
],
// userDataDir:
// "C:\\Users\\your_name\\AppData\\Local\\Google\\Chrome\\User Data\\Default",
});
const isLogged = await bot.isLogged();
if (!isLogged) {
await bot.login(credentials);
} else {
console.log("Bot is already Logged in");
}
await bot.handlePopup();
await bot.captureSnap({ caption: "Hello world" });
await bot.screenshot({ path: "screenshot.png" });
await bot.send("BestFriends"); // or bot.useShortcut([)
await bot.wait(2000);
await bot.closeBrowser();
}
sendSnap();