Skip to content

Instantly share code, notes, and snippets.

@Tombarr
Last active June 24, 2026 14:29
Show Gist options
  • Select an option

  • Save Tombarr/d3572d27a57eb67e43d929d345c137fc to your computer and use it in GitHub Desktop.

Select an option

Save Tombarr/d3572d27a57eb67e43d929d345c137fc to your computer and use it in GitHub Desktop.
JSEscalated 6/24
(function() {
"use strict";
var DEFAULT_ASSET_BASE = "https://jscalated.netlify.app/";
var entryScript = document.currentScript;
var scripts;
var i;
var assetBase;
if (window.__kaiosAdbUiLoaderState === "loading" ||
window.__kaiosAdbUiLoaderState === "ready") {
return;
}
window.__kaiosAdbUiLoaderState = "loading";
if (!entryScript) {
scripts = document.getElementsByTagName("script");
for (i = scripts.length - 1; i >= 0; i--) {
if (String(scripts[i].src || "").indexOf("/adb.js") >= 0) {
entryScript = scripts[i];
break;
}
}
}
assetBase = entryScript && entryScript.src ?
entryScript.src.replace(/[^\/?#]+(?:[?#].*)?$/, "") :
DEFAULT_ASSET_BASE;
if (assetBase.charAt(assetBase.length - 1) !== "/") {
assetBase += "/";
}
window.KAIOS_ADB_ASSET_BASE = assetBase;
window.KAIOS_ADB_SHARED_KEY_BASE = assetBase + "keys/community";
function loadScript(filename, callback) {
var script = document.createElement("script");
script.src = assetBase + filename + "?t=" + Date.now();
script.setAttribute("data-kaios-adb-dependency", filename);
script.onload = function() {
callback(null);
};
script.onerror = function() {
callback(new Error("Failed to load " + script.src));
};
document.head.appendChild(script);
}
function showLoaderError(error) {
var status = document.getElementById("status");
window.__kaiosAdbUiLoaderState = "failed";
if (status) {
status.textContent =
"ADB tool failed to load.\nAsset base: " + assetBase + "\n" +
String(error && (error.stack || error.message || error));
}
}
function buildUi() {
var style = document.createElement("style");
document.title = "KaiOS Privileged Loader";
style.id = "kaios-adb-ui-style";
style.textContent = [
"html,body{margin:0;min-height:100%;max-width:100%;overflow-x:hidden;",
"background:#050505;color:#29f36a;font-family:monospace;font-size:14px}",
"body{box-sizing:border-box;width:100vw}",
"main{box-sizing:border-box;width:100vw;max-width:100%;min-height:100vh;",
"padding:10px;overflow-x:hidden}",
"h1{margin:0 0 8px;font-size:18px}h2{margin:0 0 6px;font-size:15px}",
"p{margin:6px 0}",
"input,button,textarea,select{box-sizing:border-box;width:100%;min-width:0;",
"max-width:100%;margin:4px 0;padding:8px;border:1px solid #1d9e4b;",
"border-radius:4px;background:#101010;color:#d8ffe4;font:inherit;",
"overflow-wrap:anywhere;white-space:normal}",
"button{word-break:break-word}",
"input[type=checkbox]{width:auto;margin-right:7px;vertical-align:middle}",
"input[type=file]{font-size:12px;overflow:hidden}",
"button:focus,input:focus,textarea:focus,select:focus{outline:3px solid #f6e94b;",
"background:#18321f;color:#fff}",
"textarea{min-height:56px;resize:vertical}",
"#status{min-height:150px;max-height:42vh;overflow:auto;margin-top:8px;",
"padding:8px;border:1px solid #1d9e4b;background:#000;white-space:pre-wrap;",
"overflow-wrap:anywhere}",
".hint{color:#9cebb5;font-size:12px}",
".warning{color:#ffd86b;font-size:12px}",
"section{box-sizing:border-box;width:100%;max-width:100%;margin:10px 0;",
"padding:8px;border:1px solid #1d9e4b;overflow-wrap:anywhere}",
".choice{box-sizing:border-box;width:100%;max-width:100%;margin:7px 0;",
"padding:7px;border:1px dashed #1d9e4b;overflow-wrap:anywhere}",
".consent{display:block;margin:8px 0;padding:8px;border:1px solid #ffd86b;",
"color:#ffd86b}",
"#adbKeyStatus{padding:6px;color:#9cebb5;overflow-wrap:anywhere}"
].join("");
document.head.appendChild(style);
document.body.innerHTML = [
"<main>",
"<h1>KaiOS Privileged Loader</h1>",
"<p class=\"hint\">Up/Down moves focus. Center/Enter activates.</p>",
"<button id=\"btnProbe\" tabindex=\"0\">Probe Privileged APIs</button>",
"<input id=\"serverUrl\" tabindex=\"0\" value=\"http://192.168.40.252:9000\" ",
"aria-label=\"Relay server URL\">",
"<button id=\"btnRelay\" tabindex=\"0\">Start Or Restart Relay</button>",
"<button id=\"btnStopRelay\" tabindex=\"0\">Stop Relay</button>",
"<section><h2>ADB Public-Key Installer</h2>",
"<p class=\"hint\">Choose a matching PC key, or import an existing adbkey.pub.</p>",
"<div class=\"choice\"><strong>Recommended: private generated key</strong>",
"<p class=\"hint\">Creates a unique key pair on your relay computer. ",
"The private-key ZIP is also saved to phone storage. Keep it private.</p>",
"<button id=\"btnGeneratePrivateKey\" tabindex=\"0\">",
"Generate Private PC Key Bundle</button></div>",
"<div class=\"choice\"><strong>Easy: shared community key</strong>",
"<p class=\"warning\">The matching private key is public. Anyone with that key ",
"can access a connected phone that trusts it.</p>",
"<button id=\"btnPrepareSharedKey\" tabindex=\"0\">",
"Use Shared Key And Save PC Bundle</button></div>",
"<div class=\"choice\"><strong>Advanced: existing computer key</strong>",
"<p class=\"hint\">Select adbkey.pub from your phone or type its one-line ",
"contents below.</p>",
"<input id=\"adbPublicKeyFile\" type=\"file\" tabindex=\"0\" ",
"accept=\".pub,text/plain\" aria-label=\"Choose adbkey.pub file\"></div>",
"<label class=\"consent\"><input id=\"adbRiskConsent\" type=\"checkbox\" ",
"tabindex=\"0\">I understand that installing an ADB key grants shell access. ",
"I will keep private keys private, or I accept the wider access risk of the ",
"shared key.</label>",
"<textarea id=\"adbPublicKey\" tabindex=\"0\" rows=\"5\" ",
"aria-label=\"ADB public key\" placeholder=\"AAAA... user@computer\"></textarea>",
"<div id=\"adbKeyStatus\">No ADB public key prepared yet.</div>",
"<button id=\"btnInstallAdbKey\" tabindex=\"0\">Install ADB Public Key</button>",
"<label class=\"hint\"><input id=\"adbPersistUsb\" type=\"checkbox\" ",
"tabindex=\"0\">Keep the selected USB+ADB mode after reboot</label>",
"<button id=\"btnEnableUsbAdb\" tabindex=\"0\">Enable USB ADB</button>",
"<button id=\"btnRestoreUpdater\" tabindex=\"0\">",
"Legacy: Restore Original Updater Daemon</button>",
"<p class=\"warning\">Key installation runs directly through ",
"navigator.b2g.engmodeManager and does not install a native helper or modify ",
"the updater daemon. server.py is needed only for relay and private-key ",
"generation. Back up existing computer .android/adbkey files before replacing ",
"them. This tool does not disable ADB authentication.</p></section>",
"<section id=\"safeAppManager\"><h2>Safe Preinstalled App Manager</h2>",
"<p class=\"hint\">This disables apps through KaiOS AppsManager. It does not ",
"delete files, rewrite vroot, or free read-only system storage. Disabled apps ",
"can be restored here or by a factory reset.</p>",
"<p class=\"warning\">Launcher, keyboard, phone, emergency, messaging, ",
"settings, shared-resource, and system-role apps are protected by this tool. If you want to remove them then do it yourself.</p>",
"<button id=\"btnRefreshApps\" tabindex=\"0\">Refresh Installed Apps</button>",
"<select id=\"appManagerSelect\" tabindex=\"0\" ",
"aria-label=\"Installed application\"><option>Refresh the app list</option></select>",
"<pre id=\"appManagerDetails\" class=\"hint\">",
"Refresh the app list to begin.</pre>",
"<label class=\"consent\"><input id=\"appManagerAdvanced\" type=\"checkbox\" ",
"tabindex=\"0\">Advanced: allow disabling caution apps. I understand that ",
"their activities or background features may stop working.</label>",
"<button id=\"btnDisableApp\" tabindex=\"0\" disabled>",
"Disable Selected App</button>",
"<button id=\"btnEnableApp\" tabindex=\"0\" disabled>",
"Restore Selected App</button>",
"<button id=\"btnRestoreApps\" tabindex=\"0\" disabled>",
"Restore All Apps Disabled By This Tool</button></section>",
"<textarea id=\"command\" tabindex=\"0\" aria-label=\"Shell command\">",
"id; id -Z</textarea>",
"<button id=\"btnCommand\" tabindex=\"0\">Run Diagnostic Command</button>",
"<button id=\"btnInit\" tabindex=\"0\">Test API-Daemon Shared APIs</button>",
"<button id=\"btnClear\" tabindex=\"0\">Clear Output</button>",
"<div id=\"status\">Injected UI loaded; loading dependencies from ",
assetBase.replace(/&/g, "&amp;").replace(/</g, "&lt;"),
" ...</div></main>"
].join("");
}
try {
if (!document.head) {
document.documentElement.insertBefore(
document.createElement("head"),
document.documentElement.firstChild
);
}
if (!document.body) {
document.documentElement.appendChild(document.createElement("body"));
}
buildUi();
loadScript("adb_key_installer.js", function(installerError) {
if (installerError) {
showLoaderError(installerError);
return;
}
loadScript("app_manager.js", function(appManagerError) {
if (appManagerError) {
var status = document.getElementById("status");
var appDetails = document.getElementById("appManagerDetails");
if (status) {
status.textContent += "\nOptional app manager failed to load: " +
String(appManagerError &&
(appManagerError.stack || appManagerError.message ||
appManagerError));
}
if (appDetails) {
appDetails.textContent =
"App manager unavailable. ADB and relay tools can still be used.";
}
}
loadScript("a.js", function(controllerError) {
if (controllerError) {
showLoaderError(controllerError);
return;
}
window.__kaiosAdbUiLoaderState = "ready";
});
});
});
} catch (error) {
showLoaderError(error);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment