Check that styles haven't already been inserted

pull/311/head
Kevin Payravi 2023-11-02 08:58:25 -05:00
parent b8ad644871
commit e91b6d7aaf
1 changed files with 3 additions and 2 deletions

View File

@ -161,6 +161,7 @@ function insertCSS() {
}
`
style = document.createElement('style');
style.classList.add('iwb-styles');
style.textContent = styleString;
document.head.append(style);
}
@ -426,12 +427,12 @@ function filterSearchResults(searchResults, searchEngine, storage) {
if (filteredWikis.length === 0) {
// Wait for head to be available
const headElement = document.querySelector('head');
if (headElement) {
if (headElement && !document.querySelector('.iwb-styles')) {
insertCSS();
} else {
const docObserver = new MutationObserver(function (mutations, mutationInstance) {
const headElement = document.querySelector('head');
if (headElement) {
if (headElement && !document.querySelector('.iwb-styles')) {
insertCSS();
mutationInstance.disconnect();
}