Skip to content

Commit 64d4093

Browse files
committed
easier to use
1 parent 6266acd commit 64d4093

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

scripts/fb_messengerCount.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444
text-decoration: none;
4545
}
4646

47+
table a:hover {
48+
text-decoration: underline;
49+
}
50+
4751
input#search-inp {
4852
width: 50%;
4953
margin: auto;
@@ -70,17 +74,27 @@
7074
.avatar-list .avatar:not(:first-child) {
7175
margin-left: -20px;
7276
}
77+
78+
#searchCount {
79+
font-weight: bold;
80+
}
81+
82+
.center {
83+
text-align: center;
84+
font-size: 1.5em;
85+
}
7386
</style>
7487

7588
</head>
7689

7790
<body>
7891
<h1>Useful script</h1>
7992
<h1>Facebook Messenger Count - Đếm tin nhắn Facebook</h1>
93+
<p class="center">Tìm thấy <span id="searchCount">~</span> cuộc trò chuyện.</p>
8094
<input id="search-inp" type="text" placeholder="Tìm theo tên, rank, count, group...">
8195
<span>Gợi ý: Nhập ✅ để tìm tất cả tin nhắn group</span>
8296
<table></table>
8397
<script src="./fb_messengerCount_main.js"></script>
8498
</body>
8599

86-
</html>
100+
</html>

scripts/fb_messengerCount.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export default {
1010
en: "Counts the number of messages sent from your Facebook Messenger account.",
1111
vi: "Đếm tin nhắn từ tài khoản Facebook Messenger của bạn.",
1212
},
13-
whiteList: ["https://*.facebook.com/*", "https://*.messenger.com/*"],
1413

1514
onClickExtension: async () => {
1615
let { closeLoading, setLoadingText } = showLoading("Đang chuẩn bị...");

scripts/fb_messengerCount_main.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
const inputSearch = document.querySelector("#search-inp");
22
const tableDiv = document.querySelector("table");
3+
const searchCount = document.querySelector("#searchCount");
4+
5+
function numberWithCommas(x) {
6+
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
7+
}
38

49
function main() {
510
try {
6-
let data = JSON.parse(localStorage.ufs_fb_msg_kount);
11+
let data = JSON.parse(localStorage.ufs_fb_msg_kount) || [];
12+
13+
searchCount.innerHTML = data.length;
714

815
tableDiv.innerHTML = `
916
<tr>
@@ -18,7 +25,10 @@ function main() {
1825
let isGroup = c.type === "GROUP";
1926
let group = isGroup ? "✅" : "";
2027
let participants_name = c.participants
21-
.map((_) => _.name)
28+
.map(
29+
(_) =>
30+
`<a target="_blank" href="https://fb.com/${_.id}">${_.name}</a>`
31+
)
2232
.filter((_) => _)
2333
.join(", ");
2434
let name = isGroup
@@ -39,7 +49,7 @@ function main() {
3949
${avatar}
4050
<a href="${link}" target="_blank">${name}</a>
4151
</td>
42-
<td>${c.count}</td>
52+
<td style="text-align: right">${numberWithCommas(c.count)}</td>
4353
</tr>`;
4454
})
4555
.join("")}
@@ -54,6 +64,7 @@ function main() {
5464
}
5565

5666
function search(text) {
67+
let count = 0;
5768
[...tableDiv.querySelectorAll("tr")].forEach((tr, index) => {
5869
if (index == 0) return; // ignore table header
5970

@@ -62,8 +73,10 @@ function search(text) {
6273
tr.classList.add("hidden");
6374
} else {
6475
tr.classList.remove("hidden");
76+
count++;
6577
}
6678
});
79+
searchCount.innerHTML = count;
6780
}
6881

6982
main();

0 commit comments

Comments
 (0)