Last active
October 28, 2025 04:33
-
-
Save AlexDev404/a4697ae7d4a490413f178a5ff721ff5e to your computer and use it in GitHub Desktop.
Login to your provisioned OKX subaccount
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 OKX - Sign in with Pool Token | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Set token and isLogin cookies with custom values | |
| // @author AlexDev404 (Immanuel Garcia) | |
| // @match https://www.okx.com/account/users?logged_in=true | |
| // @match https://www.okx.com/account/login* | |
| // @match https://www.okx.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function () { | |
| "use strict"; | |
| // Function to set a cookie with 1 year expiration | |
| function setCookie(name, value, days) { | |
| const d = new Date(); | |
| d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000); | |
| const expires = "expires=" + d.toUTCString(); | |
| document.cookie = name + "=" + value + ";" + expires + ";path=/"; | |
| } | |
| // Function to get a cookie value | |
| function getCookie(name) { | |
| const nameEQ = name + "="; | |
| const ca = document.cookie.split(";"); | |
| for (let i = 0; i < ca.length; i++) { | |
| let c = ca[i]; | |
| while (c.charAt(0) == " ") c = c.substring(1, c.length); | |
| if (c.indexOf(nameEQ) == 0) | |
| return c.substring(nameEQ.length, c.length); | |
| } | |
| return null; | |
| } | |
| // Check if we need to prompt for token | |
| const currentToken = getCookie("token"); | |
| const isLogin = getCookie("isLogin"); | |
| const needs_refresh = localStorage.getItem("needs_refresh") === "1"; | |
| const is_pool = localStorage.getItem("is_pool") === "1"; | |
| const currentURL = location.href; | |
| (function _x() { | |
| if (!is_pool) return; | |
| const SUBS_ID = "oxnv-plain-button SubAccountSwitchButton_switch-button_"; | |
| const SubAccountSwitchButton = document.querySelector( | |
| `[class^="${SUBS_ID}"]`, | |
| ); | |
| const LOGOUT_ID = "extend-link icon okx-header-footer-logout"; | |
| const LogoutButton = document.querySelector(`[class^="${LOGOUT_ID}"]`); | |
| if (SubAccountSwitchButton != undefined) { | |
| SubAccountSwitchButton.remove(); | |
| LogoutButton.insertAdjacentHTML( | |
| "beforeBegin", | |
| `<button id="subLogoutButton" type="button" class="extend-link icon okx-header-footer-logout nav-menu-icon logout">Logout from pool</button>`, | |
| ); | |
| const SubLogoutButton = document.getElementById("subLogoutButton"); | |
| SubLogoutButton.onclick = subLogoutFunction; | |
| LogoutButton.remove(); | |
| } else { | |
| setTimeout(() => { | |
| _x(); | |
| }, 1000); | |
| } | |
| })(); | |
| // Always set isLogin to 1 | |
| if (isLogin !== "1") { | |
| setCookie("isLogin", "1", 365); | |
| } | |
| // Check if the client needs a refresh | |
| if (needs_refresh === true) { | |
| document.body.innerHTML = | |
| '<h1 style="font-weight: bold; font-size: 50px">You will be redirected in a few seconds...</h1>'; | |
| localStorage.removeItem("needs_refresh"); | |
| setTimeout(() => { | |
| location.reload(); | |
| }, 3500); | |
| } | |
| if (currentURL.includes("https://www.okx.com/account/login")) { | |
| const TPPC_ID = "ThirdPartyLogin_provider-container"; | |
| const ThirdPartyProviderContainer = document.querySelector( | |
| `[class^="${TPPC_ID}"]`, | |
| ); | |
| setTimeout(() => { | |
| ThirdPartyProviderContainer.insertAdjacentHTML( | |
| "afterBegin", | |
| `<button id="poolTokenProvider" type="button" class="login login-button-var login-btn btn-lg btn-outline-primary mobile" style="width: 100%; min-width: 100%;"><span class="btn-content"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" style="width: 20px; margin-right: 5px"><!--!Font Awesome Free v7.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M400 416C497.2 416 576 337.2 576 240C576 142.8 497.2 64 400 64C302.8 64 224 142.8 224 240C224 258.7 226.9 276.8 232.3 293.7L71 455C66.5 459.5 64 465.6 64 472L64 552C64 565.3 74.7 576 88 576L168 576C181.3 576 192 565.3 192 552L192 512L232 512C245.3 512 256 501.3 256 488L256 448L296 448C302.4 448 308.5 445.5 313 441L346.3 407.7C363.2 413.1 381.3 416 400 416zM440 160C462.1 160 480 177.9 480 200C480 222.1 462.1 240 440 240C417.9 240 400 222.1 400 200C400 177.9 417.9 160 440 160z"></path></svg>Pool Token</span></button>`, | |
| ); | |
| const poolTokenProvider = document.getElementById("poolTokenProvider"); | |
| poolTokenProvider.onclick = signInWithPoolToken; | |
| }, 2000); | |
| } | |
| // Optional: Add a keyboard shortcut to change the token (Ctrl+Shift+T) | |
| document.addEventListener("keydown", function (e) { | |
| if (e.ctrlKey && e.shiftKey && e.key === "L") { | |
| signInWithPoolToken(); | |
| } | |
| }); | |
| async function signInWithPoolToken() { | |
| const newToken = prompt( | |
| "Paste in your pool's token:", | |
| getCookie("token") || "", | |
| ); | |
| if (newToken !== null && newToken !== "") { | |
| const res = await fetch( | |
| `https://sigauthbroker.fly.dev/token/${newToken}`, | |
| ).then((r) => r.json()); | |
| if (res.success === false) return alert(res.error); | |
| const token = res.content; | |
| const finger = res.finger; | |
| setCookie("token", token, 365); | |
| setCookie("devId", finger, 365); | |
| setCookie("fingerprint_id", finger, 365); | |
| localStorage.setItem("needs_refresh", "1"); | |
| localStorage.setItem("is_pool", "1"); | |
| location.href = "https://www.okx.com/account/users?logged_in=true"; | |
| } | |
| } | |
| function subLogoutFunction() { | |
| localStorage.clear(); | |
| deleteAllCookies(); | |
| location.reload(); | |
| } | |
| function deleteAllCookies() { | |
| const cookies = document.cookie.split(";"); | |
| for (let i = 0; i < cookies.length; i++) { | |
| let cookie = cookies[i]; | |
| // Remove leading whitespace if present | |
| while (cookie.charAt(0) === " ") { | |
| cookie = cookie.substring(1); | |
| } | |
| // Extract the cookie name | |
| const name = cookie.split("=")[0]; | |
| // Set the expiration date to a past date (e.g., January 1, 1970) | |
| // and ensure the path is set to '/' for broader deletion | |
| document.cookie = | |
| name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | |
| } | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment