Last active
November 26, 2019 17:50
-
-
Save m4heshd/823918e325bb2fdbe2057e06e8144685 to your computer and use it in GitHub Desktop.
Remaining quota display in GB for SLT Broadband portal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------------------------------------------ | |
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