-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathzaiko_show_queue_status.user.js
More file actions
43 lines (41 loc) · 1.63 KB
/
zaiko_show_queue_status.user.js
File metadata and controls
43 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ==UserScript==
// @name Zaiko show queue status
// @namespace https://github.com/stu43005
// @version 20250215
// @description
// @author stu43005
// @match https://zaiko.io/billing/order/*
// @match https://*.zaiko.io/billing/order/*
// @run-at document-start
// @grant none
// @allFrames true
// @require https://unpkg.com/mor-mini-toast@3.x/umd/bundle.js
// ==/UserScript==
window.fetch = new Proxy(fetch, {
apply: function (target, thisArg, args) {
const arg0 = args[0];
const url = arg0 && arg0 instanceof Request ? arg0.url : arg0?.toString();
if (url.includes("/graph/queue/status")) {
return target.apply(thisArg, args).then((response) => {
const contentType = response.headers.get("Content-Type");
if (contentType && contentType.includes("application/json")) {
return response
.clone()
.json()
.then((data) => {
if (data.in_front) {
window.miniToast.init(`queue in front: ${data.in_front}`, {}).show();
}
return new Response(JSON.stringify(data), {
status: response.status,
statusText: response.statusText,
headers: response.headers,
});
});
}
return response;
});
}
return target.apply(thisArg, args);
},
});