1
0
Fork 0
mirror of https://codeberg.org/kwiat/meowad.git synced 2025-04-20 08:04:08 +02:00

feat: make the code easier to modify by people that can't code

This commit is contained in:
Mikołaj KwiatekMiki 2024-12-02 22:29:25 +01:00
parent 05e22367bb
commit b737ded666
No known key found for this signature in database
GPG key ID: FA929409FF1ED9AD

55
main.js
View file

@ -1,5 +1,23 @@
const profilePicture = "https://lh3.googleusercontent.com/uKLDTLmDr98dhxSjpNa3X4BuLLcPRLncbY9KCvPodXuIg4-Hj0hYfZWcRc29td0Aksm1EoQgHqYA3lf8wlzvugXnAs0" const advertiser = {
const imageLink = "https://pbs.twimg.com/media/GMLPkawXcAAvWiQ?format=jpg&name=small" displayName: ":3",
handle: "@twitter",
profilePicture: "https://lh3.googleusercontent.com/uKLDTLmDr98dhxSjpNa3X4BuLLcPRLncbY9KCvPodXuIg4-Hj0hYfZWcRc29td0Aksm1EoQgHqYA3lf8wlzvugXnAs0",
}
const ad = {
content: `meow meow mrrow meow mprrr :3 mrow meow :3 mrowww mrrrow :3
mrow meow purrrrr :3 mrow meow mrrrow mrowwww meow meow mrrrrrr mrowww mrow meow purrrrr :3 mrow meow purrrrr meow purrrrr meow
meoww mrrow :3 purrrrr meow :3 meow mrow meowww mrrrow :3`,
image: "https://pbs.twimg.com/media/GMLPkawXcAAvWiQ?format=jpg&name=small",
videoPoster: "https://pbs.twimg.com/media/GMLPkawXcAAvWiQ?format=jpg&name=small",
card: {
from: "twitter.com",
text: ":3"
}
}
function getAds() { function getAds() {
const ads = []; const ads = [];
@ -29,43 +47,36 @@ function replaceAds() {
tweet.querySelectorAll("div:has(> img)").forEach((imagediv) => { tweet.querySelectorAll("div:has(> img)").forEach((imagediv) => {
const image = imagediv.querySelector("div[style*=twimg]:not([style*=profile_images])"); const image = imagediv.querySelector("div[style*=twimg]:not([style*=profile_images])");
if (image) { if (image) {
image.style.backgroundImage = `url(${imageLink})`; image.style.backgroundImage = `url(${ad.image})`;
image.style.backgroundSize = "100% 100%"; image.style.backgroundSize = "100% 100%";
} }
}) })
tweet.querySelectorAll(":has(> video > source)").forEach((videocontainer) => { tweet.querySelectorAll(":has(> video > source)").forEach((videoContainer) => {
const video = videocontainer.querySelector("video"); const video = videoContainer.querySelector("video");
video.setAttribute("poster", imageLink); video.setAttribute("poster", ad.videoPoster);
document.querySelectorAll("source").forEach((source) => { document.querySelectorAll("source").forEach((source) => {
source.removeAttribute("src"); source.removeAttribute("src");
}); });
const videocontainerHTML = videocontainer.innerHTML; const _videocontainer = videoContainer.innerHTML;
videocontainer.innerHTML = ""; videoContainer.innerHTML = "";
videocontainer.innerHTML = videocontainerHTML; videoContainer.innerHTML = _videocontainer;
}) })
if (pfp) { pfp.style.backgroundImage = `url(${profilePicture})`; } if (pfp) { pfp.style.backgroundImage = `url(${advertiser.profilePicture})` }
if (displayname) { displayname.innerText = ":3"; } if (displayname) { displayname.innerText = advertiser.displayName }
if (handle) { handle.innerText = "@twitter"; } if (handle) { handle.innerText = advertiser.handle }
if (tweetText) { tweetText.innerText = ad.content }
if (tweetText) {
tweetText.innerText = `meow meow mrrow meow mprrr :3 mrow meow :3 mrowww mrrrow :3
mrow meow purrrrr :3 mrow meow mrrrow mrowwww meow meow mrrrrrr mrowww mrow meow purrrrr :3 mrow meow purrrrr meow purrrrr meow
meoww mrrow :3 purrrrr meow :3 meow mrow meowww mrrrow :3`;
}
if (cardcontainer && card) { if (cardcontainer && card) {
const cardlink = cardcontainer.querySelector("a[dir=ltr]"); const cardlink = cardcontainer.querySelector("a[dir=ltr]");
if (cardlink) { if (cardlink) {
cardlink.innerText = "From twitter.com"; cardlink.innerText = `From ${ad.card.from}`;
} }
card.querySelectorAll("div[dir=ltr] > span").forEach((cardTitle) => { card.querySelectorAll("div[dir=ltr] > span").forEach((cardTitle) => {
cardTitle.innerHTML = ":3"; cardTitle.innerHTML = ad.card.text;
}); });
} }
}) })