Skip to content

Instantly share code, notes, and snippets.

@Haoose
Forked from pedrofracassi/quicksteamactivator.user.js
Last active November 28, 2023 17:58
Show Gist options
  • Save Haoose/c081fa5dd95c4d2139f3e3bb310598cb to your computer and use it in GitHub Desktop.
Save Haoose/c081fa5dd95c4d2139f3e3bb310598cb to your computer and use it in GitHub Desktop.
Steam Key Quick Activator
// ==UserScript==
// @name Steam Key Quick Activator
// @namespace http://pedrofracassi.me/
// @version 1.2
// @description Activates Steam Keys Quickly!
// @author Pedro Fracassi (http://pedrofracassi.me)
// @match https://store.steampowered.com/account/registerkey?key=*
// @grant none
// @run-at document-end
// ==/UserScript==
'use strict';
var key = document.getElementById('product_key').value;
if (key != '') {
// Check for Key
var flag = true;
var array = key.split("-");
if (array.length === 3 || array.length === 5){
array.forEach(y => {
if (y.length !== 5) flag = false;
});
}
else flag = false;
if (flag === true) {
document.getElementById('accept_ssa').click();
document.getElementById('register_btn').click();
}
}
javascript:
var selection = window.getSelection().toString();
if (selection) {
location.href = 'https://store.steampowered.com/account/registerkey?key=' + selection;
} else {
result = prompt('Insert Steam Key');
if(result != null){
location.href = 'https://store.steampowered.com/account/registerkey?key=' + result;
} else {
location.href = 'https://store.steampowered.com/account/registerkey';
}
}
@DaniDipp
Copy link

DaniDipp commented Sep 3, 2017

It took way too long, but I managed to work out the regex for the steam key formats:

key.match(/((((?![osuOSU])[a-zA-z1-9]){5}-){2}){1,2}((?![osuOSU])[a-zA-z1-9]){5}$|((?![osuOSU])[a-zA-z1-9]){15}$/g);

It matches to
AAAAA-BBBBB-CCCCC
AAAAA-BBBBB-CCCCC-DDDDD-EEEEE
237ABCDGHJLPRST
With case-insensitive alphabet and digits but without O, S, U, and 0, probably because they look too similar to other characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment