Skip to content

Instantly share code, notes, and snippets.

@m4heshd
Last active November 26, 2019 17:50
Show Gist options
  • Save m4heshd/823918e325bb2fdbe2057e06e8144685 to your computer and use it in GitHub Desktop.
Save m4heshd/823918e325bb2fdbe2057e06e8144685 to your computer and use it in GitHub Desktop.
Remaining quota display in GB for SLT Broadband portal
/* ------------------------------------------------
Use this code with a Javascript injector for your browser
Chrome - https://chrome.google.com/webstore/detail/user-javascript-and-css/nbhcbdghjpllgmfilhnhkllmkecfmpld
------------------------------------------------ */
let stdSel = "#root > div > div > div:nth-child(3) > div > div > div > div:nth-child(3) > div.col-md-8 > div > div:nth-child(1) > div > div > div > div:nth-child(1) > div > div > div:nth-child(3) > svg > text";
let totSel = "#root > div > div > div:nth-child(3) > div > div > div > div:nth-child(3) > div.col-md-8 > div > div:nth-child(1) > div > div > div > div:nth-child(2) > div > div > div:nth-child(3) > svg > text";
let xhrnew = null;
function updUI(pkgData) {
let std = document.querySelector(stdSel);
std.innerHTML = pkgData.usageDetails["0"].remaining + "GB";
let tot = document.querySelector(totSel);
tot.innerHTML = pkgData.usageDetails["1"].remaining + "GB";
}
let req = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
this.addEventListener('load', function () {
if (this.responseURL === "https://omniscapp.slt.lk/mobitelint/slt/sltvasservices/dashboard/mypackage") {
xhrnew = this;
let pkgData = JSON.parse(this.responseText);
setTimeout(function () {
updUI(pkgData);
}, 200);
}
if (this.responseURL === "https://omniscapp.slt.lk/mobitelint/slt/sltvasservices/dashboard/summary") {
xhrnew = this;
let pkgData = JSON.parse(this.responseText);
setTimeout(function () {
updUI(pkgData.my_package_info);
}, 200);
}
});
req.apply(this, arguments);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment