Skip to content
Merged
35 changes: 35 additions & 0 deletions client_plugins/default_hostname_setter/main.js
Original file line number Diff line number Diff line change
@@ -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();
}

13 changes: 13 additions & 0 deletions client_plugins/default_hostname_setter/manifest.json
Original file line number Diff line number Diff line change
@@ -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
}