72 lines
3.0 KiB
JavaScript
72 lines
3.0 KiB
JavaScript
require("dotenv").config();
|
|
var Discord = require("discord.js");
|
|
var puppeteer = require('puppeteer');
|
|
|
|
var wh_hmpps = new Discord.WebhookClient(process.env.WH_HMPPS_ID, process.env.WH_HMPPS_TOKEN);
|
|
var wh_hrprs = new Discord.WebhookClient(process.env.WH_HRPRS_ID, process.env.WH_HRPRS_TOKEN);
|
|
var wh_howps = new Discord.WebhookClient(process.env.WH_HOWPS_ID, process.env.WH_HOWPS_TOKEN);
|
|
|
|
global.screenshotter = {
|
|
capture: async function () {
|
|
console.log('Starting screen captures');
|
|
try {
|
|
var browser = await puppeteer.launch(/*{ args: ['--no-sandbox'] }*/);
|
|
var page = await browser.newPage();
|
|
await page.setViewport({ width: 1440, height: 900 });
|
|
try {
|
|
await page.goto('https://www.multiplayerpiano.com/');
|
|
try {await page.evaluate(function () {
|
|
document.getElementById('modal').click();
|
|
//MPP.client.uri = "wss://mpp_proxy.qonq.gq";
|
|
});} catch(e) {console.error(e.message)}
|
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
let screenshot = await page.screenshot({ type: 'png' });
|
|
let filename = `Screenshot of www.multiplayerpiano.com @ ${new Date().toISOString()}.png`;
|
|
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
|
await wh_hmpps.send(attachment);
|
|
} catch (error) {
|
|
await wh_hmpps.send(`:warning: ${error.stack}`);
|
|
}
|
|
try {
|
|
await page.evaluate(function () {
|
|
MPP.client.setChannel("✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧");
|
|
});
|
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
let screenshot = await page.screenshot({ type: 'png' });
|
|
let filename = `Screenshot of www.multiplayerpiano.com/✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧ @ ${new Date().toISOString()}.png`;
|
|
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
|
await wh_hrprs.send(attachment);
|
|
} catch(error) {
|
|
await wh_hrprs.send(`:warning: ${error.stack}`);
|
|
}
|
|
try {
|
|
await page.goto('http://ourworldofpixels.com');
|
|
await page.evaluate(function (owopcaptcha) {
|
|
localStorage.owopcaptcha = owopcaptcha;
|
|
OWOP.camera.zoom = 1;
|
|
}, process.env.OWOP_CAPTCHA_PASSWORD);
|
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
await page.evaluate(function () {
|
|
for (let butt of document.getElementsByTagName('button')) {
|
|
if (butt.innerText == 'OK') {butt.click();break}
|
|
}
|
|
});
|
|
await new Promise(resolve => setTimeout(resolve, 13000));
|
|
let screenshot = await page.screenshot({ type: 'png' });
|
|
let filename = `Screenshot of ourworldofpixels.com/main @ ${new Date().toISOString()}.png`;
|
|
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
|
await wh_howps.send(attachment);
|
|
} catch (error) {
|
|
await wh_howps.send(`:warning: ${error.stack}`);
|
|
}
|
|
} catch(error) {
|
|
console.error(`Error occured with screen capture:\n${error.stack}`)
|
|
} finally {
|
|
if (browser) await browser.close();
|
|
console.log('Finished screen captures');
|
|
}
|
|
},
|
|
interval: setInterval(() => { screenshotter.capture(); }, 1000 * 60 * 60)
|
|
};
|
|
|
|
screenshotter.capture(); |