Redeem Steam Key

Redirect to Steam Register Key page when copying key

目前為 2017-10-02 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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