Skip to content

Instantly share code, notes, and snippets.

@mushonnip
Last active October 13, 2025 08:17
Show Gist options
  • Select an option

  • Save mushonnip/8339fd32dbdd3d54f86fbc37d6945d19 to your computer and use it in GitHub Desktop.

Select an option

Save mushonnip/8339fd32dbdd3d54f86fbc37d6945d19 to your computer and use it in GitHub Desktop.
// ==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