-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdom-cleanup.js
More file actions
26 lines (23 loc) · 760 Bytes
/
dom-cleanup.js
File metadata and controls
26 lines (23 loc) · 760 Bytes
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
import { emptyBubbleMessage } from './config.js';
import * as selector from './selector.js';
const extractDescendants = (span) => {
const childOfSpan = span.firstElementChild;
if (childOfSpan !== null) {
childOfSpan.remove();
span.parentNode.insertBefore(childOfSpan, span);
}
span.remove();
};
const notifyUserIfFailed = (bubble) => {
if (
/^\s*$/.test(bubble.textContent) &&
bubble.querySelector('img, [aria-label$="sticker"], [role="img"]') === null
) {
const bubbleText = bubble.querySelector(selector.chatBubbleText);
if (bubbleText !== null) {
bubbleText.classList.add('empty-bubble-message');
bubbleText.textContent = emptyBubbleMessage;
}
}
};
export { extractDescendants, notifyUserIfFailed };