wolfyflutter

67. www.screenshotmachine.com [ssweb]

Nov 6th, 2025
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 4.15 KB | Source Code | 0 0
  1. /*
  2.   nama   : skrinsot web
  3.   base   : https://www.screenshotmachine.com/
  4.   by     : wolep
  5.   update : 7 November 2025, 3:17 wita (gbs tdr gw jir)
  6.   node   : v25.0.0
  7.   note   : kata web nya ada limit 100ss / bulan, gw kasih output buffer
  8.            instead of url, karena perlu kuki buat donlot file ss
  9.            lu bisa ubah user agent kek
  10.            pov liat situs dari hp/table/desktop. cuma di skrep ini
  11.            gw males bkinnya wkwkwk. liat aja payload di fungsi req.
  12.            skrep mungkin gw update lagi kalau mood :v.
  13.   module : esm (tested) / cjs (gak tau coba test yah :v)
  14. */
  15.  
  16. import fs from 'fs'
  17.  
  18. const ssweb = {
  19.     _static: Object.freeze({
  20.         baseUrl: 'https://www.screenshotmachine.com',
  21.         baseHeaders: {
  22.             'content-encoding': 'zstd'
  23.         },
  24.         taskName: 'ssweb',
  25.         displayLog: true,
  26.         maxOutputLength: 200
  27.  
  28.     }),
  29.  
  30.     log: function (message) {
  31.         if (this._static.displayLog) {
  32.             console.log(`[${this._static.taskName}] ${message}`)
  33.         }
  34.     },
  35.  
  36.     pretyError: function (string) {
  37.         if (!string) return '(empty message)'
  38.         let message = ''
  39.         try {
  40.             message = JSON.stringify(string, null, 2)
  41.         } catch (_) {
  42.             message = string
  43.         }
  44.         if (message.length >= this._static.maxOutputLength) {
  45.             message = message.substring(0, this._static.maxOutputLength) + ' [trimmed]'
  46.         }
  47.         return message
  48.     },
  49.  
  50.  
  51.     getCookie: async function () {
  52.         this.log('coba ambil kuki')
  53.         const r = await fetch(this._static.baseUrl,
  54.             { headers: this._static.baseHeaders }
  55.         )
  56.         if (!r.ok) throw Error(`${r.status} ${r.statusText} at getCookie function. ${this.pretyError(await r.text())}`)
  57.         const cookie = r.headers.getSetCookie().map(kuki => kuki.split(';')[0]).join('; ')
  58.         if (!cookie) throw Error('gagal mendapatkan kuki')
  59.         return { cookie }
  60.     },
  61.  
  62.     getBuffer: async function (reqObj, cookie) {
  63.         this.log('coba download buffer')
  64.         if (reqObj.status !== "success") throw Error("status nya gak sukses nih objek req nyah O.o")
  65.         const { link } = reqObj
  66.         const api = this._static.baseUrl + '/' + link
  67.         const r = await fetch(api, {
  68.             headers: {
  69.                 cookie
  70.             }
  71.         })
  72.         if (!r.ok) throw Error(`${r.status} ${r.statusText} at getBuffer function. ${this.pretyError(await r.text())}`)
  73.         const ab = await r.arrayBuffer()
  74.         const buffer = Buffer.from(ab)
  75.         return { buffer }
  76.     },
  77.  
  78.     req: async function (url, cookie) {
  79.         this.log('mencoba hit server.. agak lama emang disini')
  80.         const headers = {
  81.             cookie,
  82.             "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
  83.             ...this._static.baseHeaders
  84.         }
  85.         const path = '/capture.php'
  86.         const r = await fetch(this._static.baseUrl + path, {
  87.             headers,
  88.             "body": "url=" + encodeURIComponent(url) + "&device=desktop&cacheLimit=0",
  89.             "method": "POST"
  90.         });
  91.         if (!r.ok) throw Error(`${r.status} ${r.statusText} at req function. ${this.pretyError(await r.text())}`)
  92.         const reqObj = await r.json()
  93.         return { reqObj }
  94.     },
  95.  
  96.     capture: async function (url) {
  97.         if (!url) throw Error('param url gak boleh kosong')
  98.         const { cookie } = await this.getCookie()
  99.         const { reqObj } = await this.req(url, cookie)
  100.         const { buffer } = await this.getBuffer(reqObj, cookie)
  101.         this.log('all task success')
  102.         return buffer
  103.     }
  104. }
  105.  
  106. // cara pakai
  107. ssweb.capture('https://alex.paxsenix.org/')
  108.     .then(buff => {
  109.  
  110.         // handle buffer suka suka ...
  111.  
  112.         const filePath = './hasil.jpg'
  113.         fs.writeFileSync(filePath,buff)
  114.         console.log('ss web di simpan di ' + filePath)
  115.     })
  116.     .catch(error => {
  117.         console.log('skrep gagal!' + error.message)
  118.     })
  119.  
  120. /* log output
  121. [ssweb] coba ambil kuki
  122. [ssweb] mencoba hit server.. agak lama emang disini
  123. [ssweb] coba download buffer
  124. [ssweb] all task success
  125. ss web di simpan di ./hasil.jpg
  126. */
Advertisement
Add Comment
Please, Sign In to add comment