// ==UserScript==
// @name Ontario Parks – Show Hidden Permit Quotas (XHR final)
// @namespace local.ontarioparks.quotas
// @version 3.0
// @description Shows hidden remaining/total permit quotas per lake or zone
// @match https://reservations.ontarioparks.ca/*
// @run-at document-start
// @grant none
// ==/UserScript==
(function () {
const origOpen = XMLHttpRequest.prototype.open;
const origSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.open = function (method, url) {
this._isQuotaRequest =
typeof url === "string" &&
url.includes("/api/availability/resourcestatus");
return origOpen.apply(this, arguments);
};
XMLHttpRequest.prototype.send = function () {
if (this._isQuotaRequest) {
this.addEventListener("readystatechange", () => {
if (this.readyState === 4 && this.status === 200) {
try {
const data = JSON.parse(this.responseText);
processQuota(data);
} catch (e) {
console.error("Quota JSON parse error", e);
}
}
});
}
return origSend.apply(this, arguments);
};
function processQuota(data) {
const remaining = data?.remainingReservableQuota;
const total = data?.remainingTotalQuota;
if (remaining == null || total == null) return;
const label =
data.resourceName ||
data.displayName ||
`Resource ${data.resourceId}`;
console.log(
"RESOURCSTATUS QUOTA:",
label,
remaining,
"/",
total
);
renderOverlay(`${label}\n${remaining} / ${total}`);
}
function renderOverlay(text) {
let box = document.getElementById("quota-overlay");
if (!box) {
box = document.createElement("div");
box.id = "quota-overlay";
Object.assign(box.style, {
position: "fixed",
top: "12px",
left: "12px",
zIndex: 2147483647,
background: "#000",
color: "#00ff00",
padding: "12px",
fontFamily: "monospace",
fontSize: "14px",
border: "2px solid #00ff00",
borderRadius: "6px",
whiteSpace: "pre-line",
boxShadow: "0 0 8px rgba(0,255,0,0.6)",
});
// Delay attach so Angular redraws don’t immediately remove it
setTimeout(() => {
if (!document.body.contains(box)) {
document.body.appendChild(box);
}
}, 100);
}
box.textContent = text;
}
})();2 views