| 68 | let lastAutoDarkModeState = null; |
| 69 | |
| 70 | function addOrUpdateExtraElements() { |
| 71 | |
| 72 | let style = document.getElementById('hc_style'); |
| 73 | if (!style) { |
| 74 | let baseUrl = window.location.href.replace(window.location.hash, ''); |
| 75 | let css = cssTemplate.replace(/#/g, baseUrl + '#'); |
| 76 | style = document.createElement('style'); |
| 77 | style.id = 'hc_style'; |
| 78 | style.setAttribute('type', 'text/css'); |
| 79 | style.innerHTML = css; |
| 80 | document.head.appendChild(style); |
| 81 | } |
| 82 | |
| 83 | let bg = document.getElementById('_fh_filter_bkgnd'); |
| 84 | if (!bg) { |
| 85 | bg = document.createElement('div'); |
| 86 | bg.id = '_fh_filter_bkgnd'; |
| 87 | bg.style.position = 'fixed'; |
| 88 | bg.style.left = '0px'; |
| 89 | bg.style.top = '0px'; |
| 90 | bg.style.right = '0px'; |
| 91 | bg.style.bottom = '0px'; |
| 92 | bg.style.zIndex = -1999999999; |
| 93 | document.body.appendChild(bg); |
| 94 | } |
| 95 | bg.style.display = 'block'; |
| 96 | bg.style.background = window.getComputedStyle(document.body).background; |
| 97 | |
| 98 | let c = (bg.style.backgroundColor || '').replace(/\s\s*/g, ''); |
| 99 | let match = /^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/i.exec(c); |
| 100 | if (match && match[4] === '0') { |
| 101 | bg.style.backgroundColor = '#fff'; |
| 102 | } |
| 103 | |
| 104 | let wrap = document.getElementById('_fh_filter_svg_filters'); |
| 105 | if (!wrap) { |
| 106 | wrap = document.createElement('span'); |
| 107 | wrap.id = '_fh_filter_svg_filters'; |
| 108 | if (!/Firefox/.test(navigator.userAgent)) { |
| 109 | wrap.setAttribute('hidden', 'hidden'); |
| 110 | } |
| 111 | wrap.innerHTML = svgContent; |
| 112 | document.body.appendChild(wrap); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | |
| 117 | function isEnabledSetting(value) { |