Redeem Steam Key

Redirect to Steam Register Key page when copying key

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
	}
})();