Graciously handle multiple entries in wikidata for fetching images and showing articles, verious bug fixes

This commit is contained in:
Pieter Vander Vennet 2021-10-07 22:06:47 +02:00
parent 8d52ef1106
commit a996ba2a7c
14 changed files with 231 additions and 90 deletions

View file

@ -22,6 +22,10 @@ export default class Wikipedia {
"mw-selflink",
"hatnote" // Often redirects
]
private static readonly idsToRemove = [
"sjabloon_zie"
]
private static readonly _cache = new Map<string, UIEventSource<{ success: string } | { error: any }>>()
@ -59,6 +63,13 @@ export default class Wikipedia {
}
}
for (const forbiddenId of Wikipedia.idsToRemove) {
const toRemove = content.querySelector("#"+forbiddenId)
toRemove?.parentElement?.removeChild(toRemove)
}
const links = Array.from(content.getElementsByTagName("a"))
// Rewrite relative links to absolute links + open them in a new tab