diff --git a/background.js b/background.js index 197f105..ac6e8cb 100644 --- a/background.js +++ b/background.js @@ -132,61 +132,67 @@ function setPowerIcon(status) { if (chrome.declarativeNetRequest) { // Whenever stored settings change, update the header // that is sent to BreezeWiki instances to inform them the user has IWB - updateDeclarativeRule(); - chrome.storage.onChanged.addListener(event => updateDeclarativeRule()); + addBreezeWikiDeclarativeRule(); + chrome.storage.onChanged.addListener(event => addBreezeWikiDeclarativeRule()); } -function updateDeclarativeRule() { +function addBreezeWikiDeclarativeRule() { chrome.storage.local.get((localStorage) => { chrome.storage.sync.get((syncStorage) => { const storage = { ...syncStorage, ...localStorage }; - const headerValue = JSON.stringify({ - 'power': storage.power ?? 'on', - 'breezewiki': storage.breezewiki ?? 'off' - }); - let urls = [ - "breezewiki.com", - "antifandom.com", - "bw.projectsegfau.lt", - "breeze.hostux.net", - "breezewiki.pussthecat.org", - "bw.vern.cc", - "breezewiki.esmailelbob.xyz", - "bw.artemislena.eu", - "bw.hamstro.dev", - "nerd.whatever.social", - "breeze.nohost.network", - "breeze.whateveritworks.org" - ]; - if (storage.breezewikiCustomHost) { - urls.push(storage.breezewikiCustomHost.replace(/^https?:\/\//, '')); - }; - - chrome.declarativeNetRequest.updateDynamicRules({ - removeRuleIds: [1], - addRules: [ - { - "id": 1, - "priority": 1, - "action": { - "type": "modifyHeaders", - "requestHeaders": [ - { - "operation": "set", - "header": "x-indie-wiki", - "value": headerValue - } - ] - }, - "condition": { - "requestDomains": urls, - "resourceTypes": [ - "main_frame" - ] + if (storage.breezewikiSendHeader === 'off') { + chrome.declarativeNetRequest.updateDynamicRules({ + removeRuleIds: [1] + }); + } else { + const headerValue = JSON.stringify({ + 'power': storage.power ?? 'on', + 'breezewiki': storage.breezewiki ?? 'off' + }); + let urls = [ + "breezewiki.com", + "antifandom.com", + "bw.projectsegfau.lt", + "breeze.hostux.net", + "breezewiki.pussthecat.org", + "bw.vern.cc", + "breezewiki.esmailelbob.xyz", + "bw.artemislena.eu", + "bw.hamstro.dev", + "nerd.whatever.social", + "breeze.nohost.network", + "breeze.whateveritworks.org" + ]; + if (storage.breezewikiCustomHost) { + urls.push(storage.breezewikiCustomHost.replace(/^https?:\/\//, '')); + }; + + chrome.declarativeNetRequest.updateDynamicRules({ + removeRuleIds: [1], + addRules: [ + { + "id": 1, + "priority": 1, + "action": { + "type": "modifyHeaders", + "requestHeaders": [ + { + "operation": "set", + "header": "x-indie-wiki", + "value": headerValue + } + ] + }, + "condition": { + "requestDomains": urls, + "resourceTypes": [ + "main_frame" + ] + } } - } - ] - }); + ] + }); + } }); }); } diff --git a/settings.html b/settings.html index 5b8fa35..ca71216 100644 --- a/settings.html +++ b/settings.html @@ -111,6 +111,23 @@ } } + /* TOOLTIPS */ + .tooltip { + display: inline-block; + } + .tooltip:hover::after { + content: attr(data-title); + text-align: center; + padding: 8px; + width: fit-content; + max-width: 250px; + color: #fff; + background: #000; + position: absolute; + transform: translate(calc(-100% - 5px), 20px); + z-index: 999999; + } + /* HEADER */ #header { line-height: 1.5rem; @@ -384,20 +401,6 @@ cursor: pointer; } - #togglesKeys .inputsContainer button:hover::after, - #togglesDefaults .inputsContainer label:hover::after { - content: attr(data-title); - padding: 5px; - width: fit-content; - border: 1px solid #000; - position: absolute; - color: #fff; - background: #000; - z-index: 999999; - transform: translateX(calc(-100% - 5px)); - top: 30px; - } - #togglesColumnLabels { background-color: white; padding: 5px 0; @@ -604,6 +607,13 @@ +