Adrià Vilanova MartÃnez | 3465e77 | 2021-07-11 19:18:41 +0200 | [diff] [blame] | 1 | export function removeChildNodes(node) { |
| 2 | while (node.firstChild) { |
| 3 | node.removeChild(node.firstChild); |
| 4 | } |
| 5 | } |
| 6 | |
| 7 | export 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 | |
| 13 | export 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 | } |