blob: ca452b3727cdf3df5120dc5f2fb8cbf6ad09d33a [file] [log] [blame]
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02001export function removeChildNodes(node) {
2 while (node.firstChild) {
3 node.removeChild(node.firstChild);
4 }
5}
6
7export function getNParent(node, n) {
8 if (n <= 0) return node;
9 if (!('parentNode' in node)) return null;
10 return getNParent(node.parentNode, n - 1);
11}
12
13export function createExtBadge() {
14 var badge = document.createElement('div');
15 badge.classList.add('TWPT-badge');
16 badge.setAttribute(
17 'title', chrome.i18n.getMessage('inject_extension_badge_helper', [
18 chrome.i18n.getMessage('appName')
19 ]));
20
21 var badgeI = document.createElement('i');
22 badgeI.classList.add('material-icon-i', 'material-icons-extended');
23 badgeI.textContent = 'repeat';
24
25 badge.append(badgeI);
26 return badge;
27}