blob: 67a87685b7b2c18094fe76fd72b1305c965bfc98 [file] [log] [blame]
avm999632485a3e2021-09-08 22:18:38 +02001import {createPlainTooltip} from '../../../common/tooltip.js';
2
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +02003export function removeChildNodes(node) {
4 while (node.firstChild) {
5 node.removeChild(node.firstChild);
6 }
7}
8
9export function getNParent(node, n) {
10 if (n <= 0) return node;
11 if (!('parentNode' in node)) return null;
12 return getNParent(node.parentNode, n - 1);
13}
14
15export function createExtBadge() {
avm999632485a3e2021-09-08 22:18:38 +020016 let badge = document.createElement('div');
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020017 badge.classList.add('TWPT-badge');
avm999632485a3e2021-09-08 22:18:38 +020018 let badgeTooltip = createPlainTooltip(
19 badge,
20 chrome.i18n.getMessage(
21 'inject_extension_badge_helper', [chrome.i18n.getMessage('appName')]),
22 false);
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020023
avm999632485a3e2021-09-08 22:18:38 +020024 let badgeI = document.createElement('i');
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020025 badgeI.classList.add('material-icon-i', 'material-icons-extended');
26 badgeI.textContent = 'repeat';
27
28 badge.append(badgeI);
avm999632485a3e2021-09-08 22:18:38 +020029 return [badge, badgeTooltip];
Adrià Vilanova Martínez3465e772021-07-11 19:18:41 +020030}