Advertisement
WILDAN_IZZUDIN

[JS] SCREENSHOT MACHINE

Sep 8th, 2024
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { axios, FormData } = require('./_')
  2. const { upload } = require('@neoxr/helper')
  3.  
  4. module.exports = (url, device = 'desktop') => new Promise(async resolve => {
  5.    try {
  6.       if (!['desktop', 'tablet', 'phone'].includes(device)) return resolve({
  7.          creator: global.creator,
  8.          status: false,
  9.          msg: 'Invalid device!'
  10.       })
  11.       const parse = await (await axios.get('https://www.screenshotmachine.com/', {
  12.          headers: {
  13.             "Accept": "*/*",
  14.             "User-Agent": "Mozilla/5.0 (Linux; Android 6.0.1; SM-J500G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Mobile Safari/537.36",
  15.             "Origin": "https://www.screenshotmachine.com",
  16.             "Referer": "https://www.screenshotmachine.com/",
  17.             "Referrer-Policy": "strict-origin-when-cross-origin",
  18.             "sec-ch-ua": '"Chromium";v="107", "Not=A?Brand";v="24"',
  19.             "sec-ch-ua-platform": "Android",
  20.             "sec-fetch-dest": "empty",
  21.             "sec-fetch-mode": "cors",
  22.             "sec-fetch-site": "same-origin",
  23.             "x-requested-with": "XMLHttpRequest"
  24.          }
  25.       }))
  26.       const cookie = parse.headers['set-cookie'][0]
  27.       let form = new FormData
  28.       form.append('url', url)
  29.       form.append('device', device)
  30.       form.append('cacheLimit', 0)
  31.       const json = await (await axios.post('https://www.screenshotmachine.com/capture.php', form, {
  32.          headers: {
  33.             "Accept": "*/*",
  34.             "User-Agent": "Mozilla/5.0 (Linux; Android 6.0.1; SM-J500G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Mobile Safari/537.36",
  35.             "Origin": "https://www.screenshotmachine.com",
  36.             "Referer": "https://www.screenshotmachine.com/",
  37.             "Referrer-Policy": "strict-origin-when-cross-origin",
  38.             "sec-ch-ua": '"Chromium";v="107", "Not=A?Brand";v="24"',
  39.             "sec-ch-ua-platform": "Android",
  40.             "sec-fetch-dest": "empty",
  41.             "sec-fetch-mode": "cors",
  42.             "sec-fetch-site": "same-origin",
  43.             cookie,
  44.             ...form.getHeaders(),
  45.             "x-requested-with": "XMLHttpRequest"
  46.          }
  47.       })).data
  48.       if (json.status != 'success') return resolve({
  49.          creator: global.creator,
  50.          status: false,
  51.          msg: 'Failed to screenshot!'
  52.       })
  53.       const buffer = await (await axios.get('https://www.screenshotmachine.com/serve.php?file=result&attachment', {
  54.          responseType: "arraybuffer",
  55.          headers: {
  56.             cookie
  57.          }
  58.       })).data
  59.       const proc = await upload(buffer)
  60.       if (!proc.status) return resolve({
  61.          creator: global.creator,
  62.          status: false,
  63.          msg: 'Failed to upload!'
  64.       })
  65.       delete proc.data.page
  66.       return resolve(proc)
  67.    } catch (e) {
  68.       resolve({
  69.          creator: global.creator,
  70.          status: false,
  71.          msg: e.message
  72.       })
  73.    }
  74. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement