Created
June 25, 2020 17:37
-
-
Save twnlink/d271bc1f6138135839a6eced68f9601e to your computer and use it in GitHub Desktop.
A userscript that adds a "Copy token" button for copying your minecraft.net auth token for usage in external applications (ex: name sniper)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MC TOKEN GRABBER | |
// @namespace https://creatable.cafe | |
// @match https://www.minecraft.net/en-us/profile | |
// @grant none | |
// @version 1.0 | |
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
// @author creatable | |
// @description Adds a button for grabbing your token. | |
// ==/UserScript== | |
waitForKeyElements (`div[data-testid="pii-disclaimer"]`, addCopyButton); | |
function addCopyButton() { | |
const button = document.createElement('button') | |
button.style = 'margin-top: 16px;' | |
button.className = 'btn btn-primary' | |
button.onclick = (e) => { | |
navigator.clipboard.writeText( | |
document.cookie | |
.split(';') | |
.find((i) => i.includes('bearer_token=')) | |
.split('=')[1] | |
) | |
alert('Successfully copied token!') | |
} | |
button.innerText = 'Copy token' | |
document.querySelector(`div[data-testid="pii-disclaimer"]`).append(button) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment