MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / notifyTypingEvent

Function notifyTypingEvent

scripts/fb_whoIsTyping.js:90–129  ·  view source on GitHub ↗
(uid, name, avatar, isTyping)

Source from the content-addressed store, hash-verified

88 );
89
90 function notifyTypingEvent(uid, name, avatar, isTyping) {
91 let divId = "ufs-who-is-typing";
92 let exist = document.querySelector("#" + divId);
93 if (!exist) {
94 exist = document.createElement("div");
95 exist.id = divId;
96 exist.innerHTML = `<div class="ufs-header clearfix">
97 <button class="ufs-clear-btn">X</button>
98 <button class="ufs-minimize-btn">-</button>
99 </div>`;
100
101 exist.querySelector(".ufs-header .ufs-minimize-btn").onclick = (e) =>
102 exist.classList.toggle("collapsed");
103 exist.querySelector(".ufs-header .ufs-clear-btn").onclick = (e) =>
104 confirm("Bạn có chắc muốn xoá hết thông báo?") && exist.remove();
105
106 document.body.appendChild(exist);
107 }
108
109 let time = new Date().toLocaleTimeString();
110 let text =
111 `<b><a target="_blank" href="https://fb.com/${uid}">${name}</a></b>` +
112 ` ${isTyping ? "đang gõ tin" : "ngưng gõ tin"} nhắn cho bạn.`;
113
114 let newNoti = document.createElement("div");
115 newNoti.className = "ufs-noti-item clearfix";
116 newNoti.innerHTML = `
117 <button class="ufs-close-btn">X</button>
118 <img src="${avatar}" class="ufs-avatar" />
119 <div class="ufs-content">
120 <p class="ufs-time">${time}</p>
121 <p class="ufs-text">${text}</p>
122 </div>
123 `;
124 newNoti.querySelector(".ufs-close-btn").onclick = () => {
125 newNoti.remove();
126 if (!exist.querySelector(".ufs-noti-item")) exist.remove();
127 };
128 exist.appendChild(newNoti);
129 }
130 },
131 },
132};

Callers 1

fb_whoIsTyping.jsFile · 0.85

Calls 1

removeMethod · 0.45

Tested by

no test coverage detected