mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
(control) Better refresh script that doesn't cause weird artifacts
This commit is contained in:
parent
789e8eea85
commit
bc330acfc9
@ -4,11 +4,19 @@ function refresh(ids) {
|
||||
.then(html => {
|
||||
const parser = new DOMParser();
|
||||
const newDocument = parser.parseFromString(html, "text/html");
|
||||
console.log(newDocument);
|
||||
|
||||
ids.forEach(id => {
|
||||
const newElement = newDocument.getElementById(id);
|
||||
document.getElementById(id).innerHTML = newDocument.getElementById(id).innerHTML;
|
||||
const targetElement = document.getElementById(id);
|
||||
|
||||
if (newElement == null)
|
||||
return;
|
||||
if (targetElement == null)
|
||||
return;
|
||||
|
||||
if (!newElement.isEqualNode(targetElement)) {
|
||||
targetElement.replaceWith(document.importNode(newElement, true))
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
|
Loading…
Reference in New Issue
Block a user