diff --git a/client_plugins/default_hostname_setter/main.js b/client_plugins/default_hostname_setter/main.js new file mode 100644 index 0000000..a74b5e3 --- /dev/null +++ b/client_plugins/default_hostname_setter/main.js @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2025 The Foundry Visionmongers Ltd. All Rights Reserved. + */ + +/** + * Set your default hostname here. + */ +const DEFAULT_HOST_NAME = 'your-default-hostname.com' + +/** + * Sets the default hostname in the hostname input when on the login page and the input value is empty. + */ +function setDefaultHostname() { + if (!window.location.href.includes('login')) { + return; + } + + const hostInput = document.querySelector('input#login_hostname'); + if (!hostInput) { + console.warn('Default Hostname Setter: No hostname input found found.'); + return; + } + + if (hostInput.value.trim() === '') { + hostInput.value = DEFAULT_HOST_NAME; + console.info('Default Hostname Setter: Hostname set.'); + } +} + +if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', setDefaultHostname); +} else { + setDefaultHostname(); +} + diff --git a/client_plugins/default_hostname_setter/manifest.json b/client_plugins/default_hostname_setter/manifest.json new file mode 100644 index 0000000..c4b593d --- /dev/null +++ b/client_plugins/default_hostname_setter/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "Default Hostname Setter", + "version": "1.0", + "description": "Automatically sets a default hostname on the login page if hostname input value is empty.", + "content_scripts": [ + { + "matches": ["file://*"], + "js": ["main.js"], + "run_at": "document_idle" + } + ], + "manifest_version": 3 + } \ No newline at end of file