Adding support for Fextralife + adding Baldur's Gate 3 Wiki

pull/118/head
Kevin Payravi 2023-04-14 03:00:30 -05:00
parent 647e930278
commit dd1d96419e
6 changed files with 31 additions and 11 deletions

View File

@ -118,7 +118,7 @@ async function main(eventInfo, eventName) {
// Check if tabId is > 0 (some background events may have tabId < 0)
// & check for fandom.com in hostname and quit early if it's not:
if (eventInfo.tabId > 0 && url.hostname.includes('.fandom.com')) {
if (eventInfo.tabId > 0 && (url.hostname.includes('.fandom.com') || url.hostname.includes('wiki.fextralife.com'))) {
// Check if tab is actually available
// This is mainly to prevent background processes from triggering an event
chrome.tabs.get(eventInfo.tabId, async function (tab) {

View File

@ -1,5 +1,6 @@
const searchEngineRegex = /www\.google\.|duckduckgo\.com|www\.bing\.com/;
const fandomRegex = /\.fandom\.com$/;
const fextraRegex = /\.fextralife\.com$/;
const breezeWikiRegex = /breeze\.777\.tf$|breeze\.hostux\.net$|bw\.projectsegfau\.lt$|antifandom\.com$|breezewiki\.pussthecat\.org$|bw\.vern\.cc$|breezewiki\.esmailelbob\.xyz$|bw\.artemislena\.eu$/;
const currentURL = new URL(document.location);
@ -58,7 +59,7 @@ function displayRedirectBanner(url, destination, storage) {
// Output banner
var banner = document.createElement('div');
banner.id = 'indie-wiki-banner';
banner.style.fontSize = '1.2em';
banner.style.fontSize = '18px';
banner.style.fontFamily = 'sans-serif';
banner.style.width = '100%';
banner.style.zIndex = '2147483647';
@ -194,7 +195,7 @@ function filterSearchResults(fandomSearchResults, searchEngine, storage) {
// Check if search engine results, Fandom, or a BreezeWiki host:
function checkSite() {
if (currentURL.hostname.match(searchEngineRegex) || currentURL.hostname.match(fandomRegex) || currentURL.hostname.match(breezeWikiRegex)) {
if (currentURL.hostname.match(searchEngineRegex) || currentURL.hostname.match(fandomRegex) || currentURL.hostname.match(fextraRegex) || currentURL.hostname.match(breezeWikiRegex)) {
return true;
}
}
@ -206,9 +207,9 @@ function main(mutations = null, observer = null) {
chrome.storage.sync.get(function (storage) {
// Check if extension is on:
if ((storage.power ?? 'on') === 'on') {
// Check if on Fandom or BreezeWiki
// Check if on Fandom, Fextralife, or BreezeWiki
// If on BreezeWiki, check if there is a pathname (which indicates we are looking at a wiki)
if (currentURL.hostname.match(fandomRegex) || (currentURL.hostname.match(breezeWikiRegex) && currentURL.pathname.length > 1)) {
if (currentURL.hostname.match(fandomRegex) || currentURL.hostname.match(fextraRegex) || (currentURL.hostname.match(breezeWikiRegex) && currentURL.pathname.length > 1)) {
let origin = currentURL;
// If on a BreezeWiki site, convert to Fandom link to match with our list of wikis:
if (currentURL.hostname.match(breezeWikiRegex)) {
@ -277,16 +278,16 @@ function main(mutations = null, observer = null) {
if (currentURL.hostname.includes('www.google.')) {
// Check if doing a Google search:
function filterGoogle() {
let fandomSearchResults = document.querySelectorAll("div[lang] a[href*='fandom.com']");
filterSearchResults(fandomSearchResults, 'google', storage);
let searchResults = document.querySelectorAll("div[lang] a[href*='fandom.com'], div[lang] a[href*='fextralife.com']");
filterSearchResults(searchResults, 'google', storage);
}
addLocationObserver(main);
filterGoogle();
} else if (currentURL.hostname.includes('duckduckgo.com') && currentURL.search.includes('q=')) {
// Check if doing a Duck Duck Go search:
function filterDuckDuckGo() {
let fandomSearchResults = document.querySelectorAll("h2>a[href*='fandom.com']");
filterSearchResults(fandomSearchResults, 'duckduckgo', storage);
let searchResults = document.querySelectorAll("h2>a[href*='fandom.com'], h2>a[href*='fextralife.com']");
filterSearchResults(searchResults, 'duckduckgo', storage);
}
// Need to wait for document to be ready
if (document.readyState === 'complete') {
@ -303,8 +304,8 @@ function main(mutations = null, observer = null) {
} else if (currentURL.hostname.includes('www.bing.com')) {
// Check if doing a Bing search:
function filterBing() {
let fandomSearchResults = Array.from(document.querySelectorAll(".b_attribution>cite")).filter(el => el.innerHTML.includes('fandom.com'));
filterSearchResults(fandomSearchResults, 'bing', storage);
let searchResults = Array.from(document.querySelectorAll(".b_attribution>cite")).filter(el => el.innerHTML.includes('fandom.com') || el.innerHTML.includes('fextralife.com'));
filterSearchResults(searchResults, 'bing', storage);
}
// Need to wait for document to be ready
if (document.readyState === 'complete') {

View File

@ -63,6 +63,22 @@
"destination_platform": "mediawiki",
"destination_icon": "bakugan.png"
},
{
"id": "en-baldursgate3",
"origins_label": "Baldur's Gate 3 Fextralife Wiki",
"origins": [
{
"origin": "Baldur's Gate 3 Fextralife Wiki",
"origin_base_url": "baldursgate3.wiki.fextralife.com",
"origin_content_path": "/"
}
],
"destination": "Baldur's Gate 3 Wiki",
"destination_base_url": "bg3.wiki",
"destination_content_path": "/wiki/",
"destination_platform": "mediawiki",
"destination_icon": "baldursgate3.png"
},
{
"id": "en-banjokazooie",
"origins_label": "Banjo-Kazooie Fandom Wiki",

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -43,6 +43,7 @@
{
"matches": [
"https://*.fandom.com/*",
"https://*.fextralife.com/*",
"https://breezewiki.com/*",
"https://antifandom.com/*",
"https://bw.projectsegfau.lt/*",

View File

@ -37,6 +37,7 @@
],
"matches": [
"https://*.fandom.com/*",
"https://*.fextralife.com/*",
"https://breezewiki.com/*",
"https://antifandom.com/*",
"https://bw.projectsegfau.lt/*",
@ -248,6 +249,7 @@
{
"matches": [
"https://*.fandom.com/*",
"https://*.fextralife.com/*",
"https://breezewiki.com/*",
"https://antifandom.com/*",
"https://bw.projectsegfau.lt/*",