Skip to content

Commit f9b64f2

Browse files
committed
April Fool's Day
1 parent 447ac5b commit f9b64f2

File tree

10 files changed

+513
-1
lines changed

10 files changed

+513
-1
lines changed

api/april/clap/script.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export default function () {
2+
ScratchTools.waitForElements(".flex-row.stats", function (row) {
3+
if (row.querySelector(".ste-clap")) return;
4+
5+
let div = document.createElement("div");
6+
div.className = "project-claps";
7+
div.textContent = Math.ceil(
8+
Number(row.querySelector(".project-views").textContent) / 3
9+
).toString();
10+
div.addEventListener("click", function() {
11+
var snd = new Audio("https://assets.scratch.mit.edu/83c36d806dc92327b9e7049a565c6bff.wav");
12+
snd.play();
13+
})
14+
15+
row.insertBefore(div, row.querySelector(".project-remixes"));
16+
17+
insertStyles();
18+
});
19+
20+
function insertStyles() {
21+
let text =
22+
'.project-claps {cursor: pointer;display: flex;padding-right: 2rem;font-size: 1rem;font-weight: bold;align-items: center;}.project-claps:before {display: inline-block;margin-right: .5rem;background-repeat: no-repeat;background-position: center center;background-size: contain;width: 1.75rem;height: 1.75rem;content: "";filter: grayscale(1);background-image: url(https://assets.scratch.mit.edu/get_image/.%2E/f2a6327725fe174fae9f40bad1439b67.png);}';
23+
let style = document.createElement("style");
24+
style.textContent = text;
25+
document.body.appendChild(style);
26+
}
27+
}

api/april/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default async function () {
2+
if (!(new Date().getMonth() === 3 && new Date().getDate() === 1));
3+
4+
if (window.location.pathname.toLowerCase().startsWith("/users/")) {
5+
let pong = await import("./pong/profile.js")
6+
pong.default()
7+
}
8+
9+
if (window.location.pathname.toLowerCase().startsWith("/explore/") || window.location.pathname.toLowerCase().startsWith("/search/")) {
10+
let jokes = await import("./jokes/script.js")
11+
jokes.default()
12+
}
13+
14+
if (window.location.pathname.toLowerCase().startsWith("/projects/")) {
15+
let clap = await import("./clap/script.js")
16+
clap.default()
17+
}
18+
}

api/april/jokes/data.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
export default function () {
2+
return [
3+
"Why couldn't the bicycle stand up by itself? It was two-tired.",
4+
"What do you call fake spaghetti? An impasta.",
5+
"Why did the tomato turn red? Because it saw the salad dressing!",
6+
"What do you call cheese that isn't yours? Nacho cheese!",
7+
"Why did the scarecrow win an award? Because he was outstanding in his field.",
8+
"What did one plate say to the other plate? Dinner's on me!",
9+
"Why don't skeletons fight each other? They don't have the guts.",
10+
"Why did the golfer bring two pairs of pants? In case he got a hole in one!",
11+
"What did the janitor say when he jumped out of the closet? Supplies!",
12+
"Why don't scientists trust atoms? Because they make up everything!",
13+
"What did one ocean say to the other ocean? Nothing, they just waved.",
14+
"Why did the math book look sad? Because it had too many problems.",
15+
"What did one hat say to the other hat? You stay here, I'll go on ahead.",
16+
"Why don't eggs tell jokes? Because they might crack up!",
17+
"What did one wall say to the other wall? I'll meet you at the corner!",
18+
"Why did the cookie go to the doctor? Because it was feeling crumbly.",
19+
"What do you get when you cross a snowman and a vampire? Frostbite!",
20+
"Why was the belt arrested? For holding up a pair of pants!",
21+
"What do you call a bear with no teeth? A gummy bear!",
22+
"What do you call an alligator in a vest? An investigator!",
23+
"Why did the banana go to the doctor? It wasn't peeling well.",
24+
"What's orange and sounds like a parrot? A carrot!",
25+
"Why did the picture go to jail? Because it was framed!",
26+
"What do you call a fake noodle? An impasta!",
27+
"Why was the math book sad? It had too many problems.",
28+
"What did one strawberry say to the other strawberry? If you weren't so sweet, we wouldn't be in this jam!",
29+
"Why couldn't the leopard play hide and seek? Because he was always spotted!",
30+
"Why was the broom late? It swept in!",
31+
"What do you call a bear with no ears? B!",
32+
"Why did the tomato turn red? Because it saw the salad dressing!",
33+
"What do you get when you cross a snowman and a dog? Frostbite!",
34+
"What do you get when you cross a snowman and a vampire? Frostbite!",
35+
"What's brown and sticky? A stick!",
36+
"What do you call cheese that isn't yours? Nacho cheese!",
37+
"Why did the golfer bring two pairs of pants? In case he got a hole in one!",
38+
"What did one hat say to the other hat? You stay here, I'll go on ahead!",
39+
"Why don't skeletons fight each other? They don't have the guts!",
40+
"What do you call a cow with no legs? Ground beef!",
41+
"Why don't eggs tell jokes? They might crack up!",
42+
"Why was the computer cold? It left its Windows open!",
43+
"What do you call a sleeping bull? A bulldozer!",
44+
"Why did the bicycle fall over? Because it was two-tired!",
45+
"Why was the belt arrested? For holding up a pair of pants!",
46+
"What did one plate say to the other plate? Dinner's on me!",
47+
"What's red and smells like blue paint? Red paint!",
48+
"What do you call a fish with no eyes? Fsh!",
49+
"Why couldn't the bicycle stand up by itself? It was two-tired!",
50+
"What do you call a bear with no teeth? A gummy bear!",
51+
"Why did the scarecrow win an award? Because he was outstanding in his field!",
52+
"What did the janitor say when he jumped out of the closet? Supplies!",
53+
"What do you get when you cross a snowman and a dog? Frostbite!",
54+
"Why did the tomato turn red? Because it saw the salad dressing!",
55+
"Why did the golfer bring two pairs of pants? In case he got a hole in one!",
56+
"Why did the scarecrow win an award? Because he was outstanding in his field!",
57+
"Why don't skeletons fight each other? They don't have the guts!",
58+
"What did one hat say to the other hat? You stay here, I'll go on ahead!",
59+
"Why was the broom late? It swept in!",
60+
"What do you call a bear with no ears? B!",
61+
"Why did the tomato turn red? Because it saw the salad dressing!",
62+
"What do you get when you cross a snowman and a dog? Frostbite!",
63+
"What's brown and sticky? A stick!",
64+
"What do you call cheese that isn't yours? Nacho cheese!",
65+
"Why did the golfer bring two pairs of pants? In case he got a hole in one!",
66+
"What did one hat say to the other hat? You stay here, I'll go on ahead!",
67+
"Why don't skeletons fight each other? They don't have the guts!",
68+
"What do you call a cow with no legs? Ground beef!",
69+
"Why don't eggs tell jokes? They might crack up!",
70+
"Why was the computer cold? It left its Windows open!",
71+
"What do you call a sleeping bull? A bulldozer!",
72+
"Why did the bicycle fall over? Because it was two-tired!",
73+
"Why was the belt arrested? For holding up a pair of pants!",
74+
"What did one plate say to the other plate? Dinner's on me!",
75+
"What's red and smells like blue paint? Red paint!",
76+
"What do you call a fish with no eyes? Fsh!",
77+
"Why couldn't the bicycle stand up by itself? It was two-tired!",
78+
"What do you call a bear with no teeth? A gummy bear!",
79+
"Why did the scarecrow win an award? Because he was outstanding in his field!",
80+
"What did the janitor say when he jumped out of the closet? Supplies!",
81+
"What do you get when you cross a snowman and a dog? Frostbite!",
82+
];
83+
}

api/april/jokes/script.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default async function () {
2+
let jokes = (await import("./data.js")).default();
3+
let outer = await ScratchTools.waitForElement(".outer")
4+
5+
let joke = jokes[Math.floor(Math.random() * jokes.length)];
6+
7+
let div = document.createElement("div");
8+
div.textContent = joke;
9+
div.classList.add("ste-joke-banner");
10+
outer.prepend(div);
11+
12+
div.style.backgroundColor = "#eb506a"
13+
div.style.color = "white"
14+
div.style.fontSize = "1.2rem"
15+
div.style.fontWeight = "500"
16+
div.style.textAlign = "center"
17+
div.style.padding = "1rem"
18+
}

api/april/pong/index.html

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Pong | ScratchTools</title>
7+
<style>
8+
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");
9+
10+
body {
11+
margin: 0em;
12+
font-family: "Inter", sans-serif;
13+
background-color: var(--background);
14+
}
15+
16+
body,
17+
html {
18+
margin: 0;
19+
padding: 0;
20+
height: 100%;
21+
overflow: hidden;
22+
}
23+
24+
#gameCanvas {
25+
width: 100%;
26+
height: 100%;
27+
display: block;
28+
}
29+
30+
#paddle {
31+
background-color: white;
32+
width: 8%;
33+
height: 1%;
34+
position: absolute;
35+
bottom: 0;
36+
left: 46%;
37+
border-radius: 0.5rem;
38+
}
39+
40+
#ball {
41+
display: none;
42+
}
43+
44+
h1.score {
45+
position: fixed;
46+
top: 50%;
47+
left: 50%;
48+
transform: translateX(-50%) translateY(-50%);
49+
font-size: 8rem;
50+
color: black;
51+
margin: 0px;
52+
opacity: 0.4;
53+
}
54+
55+
.hi-score {
56+
display: none;
57+
position: fixed;
58+
right: 2rem;
59+
top: 2rem;
60+
color: black;
61+
opacity: 0.8;
62+
margin: 0px;
63+
font-size: 1.4rem;
64+
}
65+
66+
.final-score {
67+
background-color: rgba(255, 255, 255, 0.7);
68+
width: 20rem;
69+
position: fixed;
70+
left: 50%;
71+
top: 50%;
72+
transform: translateX(-50%) translateY(-50%);
73+
border-radius: 1rem;
74+
text-align: center;
75+
padding: .5rem;
76+
}
77+
78+
.final-score h1 {
79+
font-size: 7rem;
80+
margin: 0px;
81+
}
82+
83+
.final-score h2 {
84+
font-size: 1.4rem;
85+
margin-top: .2rem;
86+
margin-bottom: 2rem;
87+
}
88+
89+
.final-score button {
90+
width: 100%;
91+
font-size: 1.1rem;
92+
padding: 0.8rem;
93+
background: black;
94+
color: #ffd663;
95+
font-family: "Inter", sans-serif;
96+
font-weight: 500 !important;
97+
border-radius: .75rem;
98+
border: 0px;
99+
cursor: pointer;
100+
transform: none;
101+
transition: transform .3s;
102+
}
103+
104+
.final-score button:hover {
105+
transform: scale(.9);
106+
}
107+
</style>
108+
</head>
109+
<body>
110+
<img class="avatar" style="display: none" />
111+
112+
<canvas id="gameCanvas"></canvas>
113+
<h1 class="score"></h1>
114+
<h2 class="hi-score">HI</h2>
115+
116+
<div class="final-score" style="display: none">
117+
<h1></h1>
118+
<h2>Final Score</h2>
119+
<button class="play-again">Play Again</button>
120+
</div>
121+
122+
<script src="./script.js"></script>
123+
</body>
124+
</html>

api/april/pong/profile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default async function () {
2+
let img = await ScratchTools.waitForElement("form#profile-avatar a img")
3+
4+
let user = Scratch.INIT_DATA?.LOGGED_IN_USER?.model?.username.toLowerCase()
5+
let username = window.location.pathname.split("/")[2].toLowerCase()
6+
7+
if (user === username) return;
8+
9+
img.parentNode.removeAttribute("href")
10+
11+
img.addEventListener("click", function() {
12+
chrome.runtime.sendMessage(ScratchTools.id, {
13+
msg: "openPong",
14+
username,
15+
id: Scratch.INIT_DATA.PROFILE.model.userId,
16+
});
17+
})
18+
}

0 commit comments

Comments
 (0)