SHARE
TWEET

Untitled

a guest Mar 18th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import IO from 'fs'
  2. import Network from 'request'
  3.  
  4. import color from 'chalk'
  5. const log = console.log
  6. const error = color.bold.red
  7. const success = color.bold.green
  8. const warning = color.bold.orange
  9.  
  10. let hotels = [
  11.     'com',
  12.     'com.br',
  13.     'com.tr',
  14.     'de',
  15.     'es',
  16.     'fi',
  17.     'fr',
  18.     'nl',
  19.     'it'
  20. ]
  21.  
  22. let totalBadges = 0
  23. let successfulBadges = 0
  24.  
  25. const commonUA = [
  26.     'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3029.110 Safari/537.36',
  27.     'Mozilla/5.0 (compatible, MSIE 11, Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
  28.     'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2704.79 Safari/537.36 Edge/14.14393',
  29.     'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0',
  30.     'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0; MDDCJS)',
  31.     'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0;  Trident/5.0)',
  32.     'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36 OPR/56.0.3051.116',
  33.     'Mozilla/5.0 (Linux; U; Android 5.0.2; zh-CN; Redmi Note 3 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 OPR/11.2.3.102637 Mobile Safari/537.36'
  34. ]
  35.  
  36. let Download = (url, badgeName, callback) => {
  37.     Network.head(url, (error, response, body) => {
  38.         log(`Downloading ${badgeName}...`)
  39.         Network(url).pipe(IO.createWriteStream(`./web-build/c_images/badges/${badgeName}.gif`)).on('close', callback)
  40.     })
  41. }
  42.  
  43. hotels.forEach((hotel, index, array) => {
  44.  
  45.     const randomCache = Math.random().toString(36).substr(2, 16)
  46.     const externalVariables = `https://habbo.${hotel}/gamedata/external_flash_texts/${randomCache}`
  47.  
  48.     log(`Creating a badge stream for ${color.red('https://habbo.',hotel)}`)
  49.  
  50.     let requestExternalVariables = {
  51.         url: externalVariables,
  52.         headers: {
  53.             'User-Agent': commonUA[Math.floor(Math.random() * commonUA.length)]
  54.         }
  55.     }
  56.  
  57.     Network.get(requestExternalVariables, (error, response, body) => {
  58.         if(!error && response.statusCode == 200) {
  59.             success(`Successfully created badge stream for https://habbo.${hotel}`)
  60.  
  61.             let externalVariablesContent = body.split(/\r?\n/)
  62.  
  63.             externalVariablesContent.forEach((line, index, array) => {
  64.  
  65.                 if(line.includes('badge_name_')) {
  66.                     let badgeName = line.substring(0, line.indexOf('=')).replace('badge_name_', '').replace(' ', '')
  67.  
  68.                     IO.stat(`./web-build/c_images/badges/${badgeName}.gif`, (error, stats) => {
  69.                         if(error == null) {
  70.                             console.log(`Badge ${badgeName} already exists`)
  71.                         } else if(error.code == 'ENOENT') {
  72.  
  73.                             Download(`https://habboo-a.akamaihd.net/c_images/album1584/${badgeName}.gif`, badgeName, () => {
  74.                                 console.log(`Successfully downloaded ${badgeName}`)
  75.                             })
  76.  
  77.                         } else {
  78.                             console.log(`Error ${error.code} while checking for ${badgeName} on file system`)
  79.                         }
  80.                     })
  81.                 }
  82.  
  83.             })
  84.  
  85.         } else {
  86.             console.log(`Failed to create a badge stream for https://habbo.${hotel}`)
  87.         }
  88.  
  89.     })
  90. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top