fix: removing node with background image

This commit is contained in:
Hongbo Wu
2023-06-26 16:40:14 +08:00
parent 43dcb8d5d7
commit 244fb4ccb5
6 changed files with 1327 additions and 4 deletions

View File

@ -186,10 +186,10 @@ async function fetchSource(url, callbackFn) {
// Replacing element only of there are no content inside, b/c might remove important div with content.
// Article example: http://www.josiahzayner.com/2017/01/genetic-designer-part-i.html
// DIV with class "content-inner" has `url("https://resources.blogblog.com/blogblog/data/1kt/travel/bg_container.png")` background image.
if (el.innerHTML.length < 25) {
if (!el.textContent) {
const img = document.createElement('img');
img.src = matchedSRC[1];
el && el.parentNode && el.parentNode.removeChild(el);
el && el.parentNode && el.parentNode.replaceChild(img, el);
}
}
}