Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==UserScript==
// @name Reveal and Copy Steam Keys
// @namespace http://jnv.github.io
// @include https://www.bundlestars.com/*/orders/*
// @version 1
// @grant none
// @domain www.bundlestars.com
// @run-at document-idle
// ==/UserScript==
const BUNDLE_STARS_REDEEM_SEL = '.hidden-xs [ng-click^=redeemSerial]'
const BUNDLE_STARS_KEY_SEL = '.hidden-xs [ng-model="game.key"]'
const KEYS_EL_ID = 'userscript-injected-textarea'
function bundleStarsRedeem () {
document.querySelectorAll(BUNDLE_STARS_REDEEM_SEL).forEach(el => el.click())
}
function bundleStartsDisplayKeys () {
const inputs = Array.from(document.querySelectorAll(BUNDLE_STARS_KEY_SEL))
const keys = inputs.map(el => el.value).join('\r\n')
console.log(keys)
if (keys) {
injectKeys(keys)
}
}
function injectKeys (keys) {
let txt = document.getElementById(KEYS_EL_ID)
if (!txt) {
txt = document.createElement('textarea')
txt.id = KEYS_EL_ID
txt.style = 'position: fixed; left: 0; top: 0; z-index: 999999; color: #000 !important; background: #fff !important;'
document.body.appendChild(txt)
}
txt.value = keys
txt.setAttribute('readonly', 'readonly')
}
window.setTimeout(bundleStartsDisplayKeys, 3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment