1
0
Fork 0
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:
Mikołaj KwiatekMiki 2024-12-02 22:55:46 +01:00
parent 4300731759
commit 8a417ca692
No known key found for this signature in database
GPG key ID: FA929409FF1ED9AD

13
main.js
View file

@ -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);
}
})