mirror of
https://codeberg.org/kwiat/meowad.git
synced 2025-04-20 05:44:08 +02:00
fix: images not being replaced until hovered
idk why this works closes #2
This commit is contained in:
parent
4300731759
commit
8a417ca692
1 changed files with 9 additions and 4 deletions
13
main.js
13
main.js
|
@ -52,11 +52,16 @@ function replaceAds() {
|
|||
const handleText = handle.innerText.toLowerCase().replace("@", "");
|
||||
if (ignoredAdvertisers.includes(handleText)) { return }
|
||||
|
||||
tweet.querySelectorAll("div:has(> img)").forEach((imagediv) => {
|
||||
const image = imagediv.querySelector("div[style*=twimg]:not([style*=profile_images])");
|
||||
tweet.querySelectorAll("div:has(> img)").forEach((imageContainer) => {
|
||||
const imageDiv = imageContainer.querySelector("div[style*=twimg]:not([style*=profile_images])");
|
||||
if (imageDiv) {
|
||||
imageDiv.style.backgroundImage = `url(${ad.image})`;
|
||||
imageDiv.style.backgroundSize = "100% 100%";
|
||||
}
|
||||
|
||||
const image = imageContainer.querySelector("div[style*=twimg]:not([style*=profile_images])");
|
||||
if (image) {
|
||||
image.style.backgroundImage = `url(${ad.image})`;
|
||||
image.style.backgroundSize = "100% 100%";
|
||||
image.setAttribute("src", ad.image);
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue