Skip to content

Commit 59959d4

Browse files
committed
update
1 parent d281edc commit 59959d4

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

scripts/content-scripts/ufs_global.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ function getNumberFormatter(optionSelect, locale) {
991991
?.getAttribute("href")
992992
)?.searchParams?.get("locale");
993993
} catch {
994-
cLog(
994+
console.log(
995995
"Cannot find browser locale. Use en as default for number formatting."
996996
);
997997
locale = "en";

scripts/fb_getPostReactionCount.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ export default {
5050
};
5151

5252
const getTotalPostReactionCount = async (id) => {
53+
if (CACHED[id] === "loading") return;
54+
5355
const { setText, closeAfter } = UfsGlobal.DOM.notify({
5456
msg: "Đang đếm số lượng reaction...",
5557
duration: 10000,
5658
});
59+
const numberFormater = UfsGlobal.Utils.getNumberFormatter("standard");
5760

5861
let res;
5962
if (CACHED[id]) {
6063
res = CACHED[id];
6164
} else {
65+
CACHED[id] = "loading";
6266
res = {
6367
total: 0,
6468
each: {},
@@ -67,18 +71,22 @@ export default {
6771
const count = await getPostReactionsCount(id, reactionId);
6872
res.total += count;
6973
res.each[name] = count;
70-
setText(`Đang đếm số lượng reaction ${name}... Tổng: ${res.total}`);
74+
setText(
75+
`Đang đếm số lượng reaction ${name}... Tổng: ${numberFormater.format(
76+
res.total
77+
)}`
78+
);
7179
}
7280
CACHED[id] = res;
7381
}
7482

7583
setText(
7684
"<p style='color:white;font-size:20px;padding:0;margin:0'>Tổng " +
77-
res.total +
85+
numberFormater.format(res.total) +
7886
" reaction.<br/>Bao gồm " +
7987
Object.entries(res.each)
8088
.filter(([key, value]) => value > 0)
81-
.map(([key, value]) => `${value}${key}`)
89+
.map(([key, value]) => `${numberFormater.format(value)}${key}`)
8290
.join(", ") +
8391
"</p>"
8492
);
@@ -88,9 +96,11 @@ export default {
8896
const originalXMLSend = XMLHttpRequest.prototype.send;
8997
XMLHttpRequest.prototype.send = function () {
9098
let s = arguments[0]?.toString() || "";
91-
if (s.includes("CometUFIReactionsCountTooltipContentQuery")) {
92-
console.log(this);
93-
const original = this.onreadystatechange;
99+
if (
100+
s.includes("CometUFIReactionsCountTooltipContentQuery") ||
101+
s.includes("CometUFIReactionIconTooltipContentQuery")
102+
) {
103+
const originalReady = this.onreadystatechange;
94104
this.onreadystatechange = function () {
95105
if (this.readyState == 4) {
96106
try {
@@ -106,7 +116,7 @@ export default {
106116
console.log(err);
107117
}
108118
}
109-
original.apply(this, arguments);
119+
originalReady.apply(this, arguments);
110120
};
111121
}
112122
originalXMLSend.apply(this, arguments);

working_note.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 30/05/2024 - ?
44

5+
- [ ] modify responseText xhr <https://stackoverflow.com/a/37532556/23648002>
6+
57
- [ ] auto refresh tab <https://chromewebstore.google.com/detail/aabcgdmkeabbnleenpncegpcngjpnjkc>
68

79
- [ ] <https://www.maxai.me/affiliate/> <https://www.maxai.me/partners/installed/?name=Useful-script>

0 commit comments

Comments
 (0)