Skip to content

Instantly share code, notes, and snippets.

@Mearman
Last active February 15, 2023 09:51
Show Gist options
  • Save Mearman/ba6a2df80b1c1fb4598196b153394ad1 to your computer and use it in GitHub Desktop.
Save Mearman/ba6a2df80b1c1fb4598196b153394ad1 to your computer and use it in GitHub Desktop.
Steam Redeem Bookmarklet

Steam Key Redemption Bookmarklets

These bookmarklets allow you to redeem Steam keys directly from your browser. They are available in three versions, each using a different method for inputting the key:

  • Prompt: Prompts the user to enter the key manually.
  • Selection: Attempts to automatically fill in the key using the current text selection.
  • Clipboard: Attempts to automatically fill in the key using the contents of the clipboard.

Usage

Unfortunately due to limitations in GFMD (Github Flavored Markdown) there is no way to directly embed the bookmarklets.

To use the bookmarklets, create a a new bookmark in your browser and paste the code for the bookmarklet you want to use into the URL field.

Requirements

  • A browser that supports bookmarklets.
  • A browser that supports the clipboard API, if you want to use the clipboard bookmarklet.

Bookmarklets

Steam Redeem Prompt

javascript: (function () {
	var key = prompt("Please enter your Steam serial key:");
	if (key != null) {
		window.location.href =
			"https://store.steampowered.com/account/registerkey?key=" + key;
	}
})();

Steam Redeem from Selection

javascript: (function () {
	var selectedText = window.getSelection().toString();
	var key = prompt("Please enter your Steam serial key:", selectedText);
	if (key != null) {
		window.location.href =
			"https://store.steampowered.com/account/registerkey?key=" + key;
	}
})();

Steam Redeem from Clipboard

javascript: (function () {
	function registerKey(key) {
		var url = "https://store.steampowered.com/account/registerkey?key=" + key;
		window.open(url, "_blank");
	}

	function promptKey(defaultText) {
		var key = prompt("Please enter your Steam serial key:", defaultText);
		if (key != null) {
			registerKey(key);
		}
	}

	(async function () {
		try {
			var selectedText = window.getSelection().toString();
			var defaultText = selectedText || (await navigator.clipboard.readText());
			promptKey(defaultText);
		} catch (error) {
			alert("Your browser does not support the clipboard API.");
		}
	})();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment