avm99963 | 2485a3e | 2021-09-08 22:18:38 +0200 | [diff] [blame] | 1 | import {createPlainTooltip} from '../../../common/tooltip.js'; |
| 2 | |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 3 | export function removeChildNodes(node) { |
| 4 | while (node.firstChild) { |
| 5 | node.removeChild(node.firstChild); |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | export 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 | |
| 15 | export function createExtBadge() { |
avm99963 | 2485a3e | 2021-09-08 22:18:38 +0200 | [diff] [blame] | 16 | let badge = document.createElement('div'); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 17 | badge.classList.add('TWPT-badge'); |
avm99963 | 2485a3e | 2021-09-08 22:18:38 +0200 | [diff] [blame] | 18 | let badgeTooltip = createPlainTooltip( |
| 19 | badge, |
| 20 | chrome.i18n.getMessage( |
| 21 | 'inject_extension_badge_helper', [chrome.i18n.getMessage('appName')]), |
| 22 | false); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 23 | |
avm99963 | 2485a3e | 2021-09-08 22:18:38 +0200 | [diff] [blame] | 24 | let badgeI = document.createElement('i'); |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 25 | badgeI.classList.add('material-icon-i', 'material-icons-extended'); |
| 26 | badgeI.textContent = 'repeat'; |
| 27 | |
| 28 | badge.append(badgeI); |
avm99963 | 2485a3e | 2021-09-08 22:18:38 +0200 | [diff] [blame] | 29 | return [badge, badgeTooltip]; |
Adrià Vilanova Martínez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 30 | } |