Last active
October 13, 2025 08:17
-
-
Save mushonnip/8339fd32dbdd3d54f86fbc37d6945d19 to your computer and use it in GitHub Desktop.
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 Scalar Auto Fill Token Field | |
| // @namespace http://localhost:8000/ | |
| // @version 1.0 | |
| // @description Automatically fill the Token field on localhost | |
| // @match http://localhost:8000/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // ✏️ Change this to your desired token value | |
| const TOKEN_VALUE = 'YOUR_TOKEN_HERE'; | |
| // Function to fill the input once it appears | |
| function fillTokenField() { | |
| const input = document.querySelector('input[placeholder="Token"][id^="scalar-refs-"]'); | |
| if (input && !input.value) { | |
| input.value = TOKEN_VALUE; | |
| // Trigger input/change events so Vue/React detect it | |
| input.dispatchEvent(new Event('input', { bubbles: true })); | |
| input.dispatchEvent(new Event('change', { bubbles: true })); | |
| } | |
| } | |
| // Observe DOM changes (for SPA or dynamic rendering) | |
| const observer = new MutationObserver(() => fillTokenField()); | |
| observer.observe(document.body, { childList: true, subtree: true }); | |
| // Also run immediately on load | |
| fillTokenField(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment