Created
July 27, 2019 12:45
-
-
Save Pipeliner/446b0f466b6ebe71264471c6b834a7bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
// TODOs: | |
// 1. Too many attempts -> sleep for a bit | |
// 2. Logged out -> log in | |
// 3. Already bought -> repost | |
// 4. OCR https://vk.com/steamgenerator + string replace | |
// 5. OCR https://vk.com/ls_keys | |
// 6. Reddit | |
(async () => { | |
async function waitForUpTo(page, msecs) { | |
await page.waitFor(Math.floor(Math.random() * msecs)); | |
} | |
const browser = await puppeteer.launch( | |
{ | |
executablePath: "/usr/bin/google-chrome-unstable", | |
headless: false, | |
//userDataDir: "/home/vadim/.config/google-chrome-unstable", | |
defaultViewport: null, | |
//slowMo: 300, | |
args: ['--user-data-dir=/home/vadim/.config/google-chrome-unstable'], | |
} | |
); | |
const keysPage = await browser.newPage(); | |
const WTFKEYS_URL = "https://vk.com/wtfkeys"; | |
const VK_SEARCH_URL = "https://vk.com/search?c%5Bper_page%5D=40&c%5Bq%5D=steam%20%D0%BA%D0%BB%D1%8E%D1%87&c%5Bsection%5D=statuses"; | |
await keysPage.goto(VK_SEARCH_URL); | |
let oldKeys = [ | |
'[object Promise]', 'undefined', 'WNB5N-T7QX0-IMR47', | |
undefined, 'P90MA-IYJEJ-99L93', 'G5KVZ-3E2V7-KZG36', | |
'PCBC3-GVBC7-NPTLK', '4GZN6-Q8J28-IBJ8G', 'NLJ53-87PLK-WJ4ZQ', | |
'P6P0L-IK6W6-Q6KA2', 'XI83X-BECR6-3A2QK', 'CC7MH-TKEGV-2EFPM', | |
'JYJY9-6R5PF-GE4CP', 'PLHCE-Y3GWB-JCW2V', 'M3N90-EBDHA-Q802H', | |
'MC8Q6-3XB2B-57WPW', 'ZBNKZ-2FCH6-TE2BB', '5C5W2-A3LL7-D8CH8', | |
'84C4V-FCIKW-EDNWT', 'QMNAC-43NG5-TM8LR', 'EPKEA-9D0GC-9CVWR', | |
'JA88I-RGPQ4-LXYPV', 'YB32Y-VZCKY-99MLE', 'GNZFQ-4C7IW-XHXCN', | |
'6XE6H-BJE9B-0QW8X', 'NF6HA-8Y7IN-HGHG7', 'RH93K-4NIGI-LG3DX', | |
'8VJBZ-X8IZA-YZLDW', 'PD6D2-W3RZZ-HDAMG', 'LE9GB-JF2EQ-6L4LF', | |
'L89R2-A5YED-HYZYB', 'X86DL-WKCP8-ZFDTB', 'G6CPP-WQL35-0YDLA', | |
'F2WBG-5JBYY-D0CGR', 'GTVEC-RP495-ZM8IB', '9Z8RK-8P3ZX-IJG32', | |
'BLDM9-VT2HZ-RP2IA', 'GDBJI-RVT2I-N06FE', 'GIQF7-A803J-VETB4', | |
'A96I9-NK2PC-VHGQG', 'I80W5-W720C-32QHX', '8TZWB-BLRQ7-3DZTH', | |
'AYG7J-FL4LW-EC6AD', 'NGM55-293X5-4N9QQ', 'NX2QW-B3TX7-V9QFT', | |
'GMPG9-3QXEP-KDHC9', 'FGZTB-H2WRZ-0BXC2', '2JIDQ-BTBEG-ARG4Q', | |
'ZII0K-ECCVH-7IE28', 'E9VCJ-4YKIR-0LKD3', '48H3T-CJL0Z-6I48Y', | |
'RTYLA-LCCMZ-PMH2P', '8VJ9H-06BXT-W5XNQ' | |
]; | |
console.log(browser.wsEndpoint()); | |
async function registerKeys(keys) { | |
for (const key of keys) { | |
await registerKey(key); | |
await waitForUpTo(keysPage, 180000); | |
} | |
} | |
async function registerKey(key) { | |
if (oldKeys.indexOf(key) !== -1) { | |
return; | |
} | |
const steamPage = await browser.newPage(); | |
await steamPage.goto(`https://store.steampowered.com/account/registerkey?key=${key}`); | |
await steamPage.waitForSelector("#accept_ssa"); | |
await waitForUpTo(steamPage, 2000); | |
steamPage.click("#accept_ssa"); | |
await waitForUpTo(steamPage, 2000); | |
steamPage.click("#register_btn"); | |
oldKeys.push(key); | |
console.log("Old keys: ", oldKeys); | |
} | |
async function getFreshKeyWTFkeys() { | |
const key = await keysPage.evaluate( | |
() => { | |
key = document.getElementsByClassName("wall_post_text")[1].innerText.split("\n")[4]; | |
return key; | |
} | |
); | |
// console.log(key); | |
return [key]; | |
} | |
async function getAllKeys() { | |
return getAllClearTextKeys(); | |
} | |
async function getAllClearTextKeys() { | |
const content = await keysPage.content(); | |
const key_re = /[0-9A-Z]{5}-[0-9A-Z]{5}-[0-9A-Z]{5}/g; | |
const keys = content.match(key_re); | |
return keys; | |
} | |
const getFreshKeys = getAllKeys; | |
while (true) { | |
await keysPage.waitFor(50); | |
await registerKeys(await getFreshKeys()); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment