Check that styles haven't already been inserted
parent
b8ad644871
commit
e91b6d7aaf
|
@ -161,6 +161,7 @@ function insertCSS() {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
style = document.createElement('style');
|
style = document.createElement('style');
|
||||||
|
style.classList.add('iwb-styles');
|
||||||
style.textContent = styleString;
|
style.textContent = styleString;
|
||||||
document.head.append(style);
|
document.head.append(style);
|
||||||
}
|
}
|
||||||
|
@ -426,12 +427,12 @@ function filterSearchResults(searchResults, searchEngine, storage) {
|
||||||
if (filteredWikis.length === 0) {
|
if (filteredWikis.length === 0) {
|
||||||
// Wait for head to be available
|
// Wait for head to be available
|
||||||
const headElement = document.querySelector('head');
|
const headElement = document.querySelector('head');
|
||||||
if (headElement) {
|
if (headElement && !document.querySelector('.iwb-styles')) {
|
||||||
insertCSS();
|
insertCSS();
|
||||||
} else {
|
} else {
|
||||||
const docObserver = new MutationObserver(function (mutations, mutationInstance) {
|
const docObserver = new MutationObserver(function (mutations, mutationInstance) {
|
||||||
const headElement = document.querySelector('head');
|
const headElement = document.querySelector('head');
|
||||||
if (headElement) {
|
if (headElement && !document.querySelector('.iwb-styles')) {
|
||||||
insertCSS();
|
insertCSS();
|
||||||
mutationInstance.disconnect();
|
mutationInstance.disconnect();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue