Rm header injection for BreezeWiki / Removing IWB promo + duplicative notices from BreezeWiki
parent
69e384c22c
commit
5fb980f4da
|
@ -129,68 +129,6 @@ 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());
|
||||
}
|
||||
|
||||
function updateDeclarativeRule() {
|
||||
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"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function redirectToBreezeWiki(storage, tabId, url) {
|
||||
function processRedirect(host) {
|
||||
// Extract article from URL
|
||||
|
|
|
@ -223,6 +223,14 @@ function displayRedirectBanner(newUrl, id, destinationName, destinationLanguage,
|
|||
} else {
|
||||
chrome.storage.sync.set({ 'countAlerts': (storage.countAlerts ?? 0) + 1 });
|
||||
}
|
||||
|
||||
// Hide duplicative indie wiki notice on BreezeWiki instances
|
||||
if (currentURL.hostname.match(breezewikiRegex)) {
|
||||
const bwIndieNotice = document.querySelector('aside.niwa__notice');
|
||||
if (bwIndieNotice) {
|
||||
bwIndieNotice.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove readystatechange listener
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// Hide Indie Wiki Buddy promo banner
|
||||
const bwTopBanners = document.querySelectorAll('.bw-top-banner');
|
||||
bwTopBanners.forEach((banner) => {
|
||||
if (banner.innerText.includes('affiliated browser extension')) {
|
||||
banner.style.display = 'none';
|
||||
}
|
||||
});
|
|
@ -5,7 +5,6 @@
|
|||
"permissions": [
|
||||
"storage",
|
||||
"webRequest",
|
||||
"declarativeNetRequest",
|
||||
"notifications",
|
||||
"scripting",
|
||||
"https://*.fandom.com/*",
|
||||
|
@ -84,6 +83,26 @@
|
|||
],
|
||||
"run_at": "document_start"
|
||||
},
|
||||
{
|
||||
"matches": [
|
||||
"https://breezewiki.com/*",
|
||||
"https://antifandom.com/*",
|
||||
"https://bw.projectsegfau.lt/*",
|
||||
"https://breeze.hostux.net/*",
|
||||
"https://breezewiki.pussthecat.org/*",
|
||||
"https://bw.vern.cc/*",
|
||||
"https://breezewiki.esmailelbob.xyz/*",
|
||||
"https://bw.artemislena.eu/*",
|
||||
"https://bw.hamstro.dev/*",
|
||||
"https://nerd.whatever.social/*",
|
||||
"https://breeze.nohost.network/*",
|
||||
"https://breeze.whateveritworks.org/*"
|
||||
],
|
||||
"js": [
|
||||
"content-breezewiki.js"
|
||||
],
|
||||
"run_at": "document_end"
|
||||
},
|
||||
{
|
||||
"matches": [
|
||||
"https://*.bing.com/search*",
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
"permissions": [
|
||||
"storage",
|
||||
"webRequest",
|
||||
"declarativeNetRequest",
|
||||
"notifications",
|
||||
"scripting"
|
||||
],
|
||||
|
@ -277,6 +276,26 @@
|
|||
"content-banners.js"
|
||||
],
|
||||
"run_at": "document_start"
|
||||
},
|
||||
{
|
||||
"matches": [
|
||||
"https://breezewiki.com/*",
|
||||
"https://antifandom.com/*",
|
||||
"https://bw.projectsegfau.lt/*",
|
||||
"https://breeze.hostux.net/*",
|
||||
"https://breezewiki.pussthecat.org/*",
|
||||
"https://bw.vern.cc/*",
|
||||
"https://breezewiki.esmailelbob.xyz/*",
|
||||
"https://bw.artemislena.eu/*",
|
||||
"https://bw.hamstro.dev/*",
|
||||
"https://nerd.whatever.social/*",
|
||||
"https://breeze.nohost.network/*",
|
||||
"https://breeze.whateveritworks.org/*"
|
||||
],
|
||||
"js": [
|
||||
"content-breezewiki.js"
|
||||
],
|
||||
"run_at": "document_end"
|
||||
}
|
||||
],
|
||||
"host_permissions": [
|
||||
|
|
Loading…
Reference in New Issue