Created
March 11, 2017 17:02
-
-
Save jnv/7e88ac3f75e05e8e19f9805af01b5e7c 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
// ==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