Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save timperrett/e3370a8154bd300c05fc386dc19d0dde to your computer and use it in GitHub Desktop.
Save timperrett/e3370a8154bd300c05fc386dc19d0dde to your computer and use it in GitHub Desktop.
JS Code To Disable WiFi for T-Mobile 5G Home Internet Router

This script can be copied into the browser console and used to disable wifi on the T-Mobile 5G Home Internet router. The web interface for the router doesn't allow you to disable it.

Steps

  1. Go to http://192.168.12.1
  2. Open dev console (on mac [cmd]+[opt]+i)
  3. Copy the code from the below JS file and with the password value updated to be your actual password and hit enter
  4. Call the code by typing tmobileHomeInternetDisableWifi() and hitting enter
async function tmobileHomeInternetDisableWifi() {
const username = 'admin'
const password = 'REPLACE-WITH-REAL-PASSWORD' // <<------- Make sure to replace this
async function loginTmobile(username, password) {
const resp = await fetch("http://192.168.12.1/TMI/v1/auth/login", {
"headers": {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"cache-control": "max-age=0",
"content-type": "text/plain;charset=UTF-8"
},
"referrer": "http://192.168.12.1/home",
"referrerPolicy": "strict-origin-when-cross-origin",
// "body": "{\"username\":\"admin\",\"password\":\"tug.ecologist.cover.facility\"}",
body: JSON.stringify({ username, password }),
"method": "POST",
"mode": "cors",
"credentials": "include"
});
console.log('resp', { headers: resp.headers })
if (resp.ok) {
const jsonValue = await resp.json(); // Get JSON value from the response body
const authToken = jsonValue?.auth?.token
return Promise.resolve(authToken);
} else {
return Promise.reject('Failed to get JSON respon value');
}
}
async function getAccessPointConfig(authToken) {
const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?get=ap", {
headers: {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"authorization": `Bearer ${authToken}`,
"cache-control": "max-age=0"
},
referrer: "http://192.168.12.1/networks",
referrerPolicy: "strict-origin-when-cross-origin",
body: null,
method: "GET",
mode: "cors",
credentials: "include"
});
console.log('ap config resp', resp)
if (resp.ok) {
const jsonValue = await resp.json(); // Get JSON value from the response body
return Promise.resolve(jsonValue);
} else {
return Promise.reject('Failed to get JSON respon value');
}
}
function disableWifiProps(apConfig) {
const configWifiOff = {
...apConfig,
'2.4ghz': { ...apConfig['2.4ghz'], isRadioEnabled: false },
'5.0ghz': { ...apConfig['5.0ghz'], isRadioEnabled: false },
}
console.log('configWifiOff', configWifiOff)
return configWifiOff
}
async function disableAccessPointWifi(authToken) {
const apConfig = await getAccessPointConfig(authToken)
const wifiOffConfig = disableWifiProps(apConfig)
const resp = await fetch("http://192.168.12.1/TMI/v1/network/configuration?set=ap", {
headers: {
"accept": "application/json",
"accept-language": "en-US,en;q=0.9",
"authorization": `Bearer ${authToken}`,
"cache-control": "max-age=0",
"content-type": "text/plain;charset=UTF-8"
},
referrer: "http://192.168.12.1/networks",
referrerPolicy: "strict-origin-when-cross-origin",
body: JSON.stringify(wifiOffConfig),
method: "POST",
mode: "cors",
credentials: "include"
});
console.log('ap config resp', resp)
if (resp.ok) {
const jsonValue = await resp.json(); // Get JSON value from the response body
return Promise.resolve(jsonValue);
} else {
return Promise.reject('Failed to get JSON respon value');
}
}
const authToken = await loginTmobile(username, password)
const result = await disableAccessPointWifi(authToken)
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment