From 44ba1183dceb64430eb91a1eb9e7d371dead0b93 Mon Sep 17 00:00:00 2001 From: SavageCore <171312+SavageCore@users.noreply.github.com> Date: Mon, 2 Oct 2017 14:16:46 +0100 Subject: [PATCH] First Commit --- .editorconfig | 8 ++++++++ .gitignore | 1 + LICENSE.md | 25 +++++++++++++++++++++++++ README.md | 3 +++ package.json | 8 ++++++++ src/redeem-steam-key.user.js | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 package.json create mode 100644 src/redeem-steam-key.user.js diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..aaac325 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +indent_style = tab +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..702f813 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,25 @@ + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to diff --git a/README.md b/README.md new file mode 100644 index 0000000..dd32bb4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# 🔑 Redeem Steam Key + +[Install](https://github.com/SavageCore/redeem-steam-key/raw/master/src/redeem-steam-key.user.js) diff --git a/package.json b/package.json new file mode 100644 index 0000000..fb5dae7 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "test": "xo" + }, + "devDependencies": { + "xo": "^0.17.0" + } +} diff --git a/src/redeem-steam-key.user.js b/src/redeem-steam-key.user.js new file mode 100644 index 0000000..0ada9df --- /dev/null +++ b/src/redeem-steam-key.user.js @@ -0,0 +1,34 @@ +// ==UserScript== +// @name Redeem Steam Key +// @namespace https://savagecore.eu +// @version 0.1.0 +// @description Redirect to Steam Register Key page when copying key +// @author SavageCore +// @include * +// @grant GM_openInTab +// ==/UserScript== +// +/* global document window GM_openInTab */ + +(function () { + 'use strict'; + + // Automatically accept Steam Subscriber Agreement + if (window.location.href.match(/^https?:\/\/store.steampowered.com\/account\/registerkey/)) { + const ssaElem = document.getElementById('accept_ssa'); + if (ssaElem) { + ssaElem.checked = 'checked'; + } + } else { + const activateProduct = function (e) { + const productKey = window.getSelection().toString().trim() || e.target.value; + let m; + if ((m = /^[\d\w]{2,5}(-[\d\w]{4,5}){2,4}$/.exec(productKey)) !== null) { + // GM_openInTab so that the 'popup' is not blocked by browser + GM_openInTab('https://store.steampowered.com/account/registerkey?key=' + m[0]); // eslint-disable-line new-cap + } + }; + + window.addEventListener('copy', activateProduct, false); + } +})();