summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2024-01-03 12:59:25 +0100
committerGravatar Uko Kokņevičs2024-01-03 12:59:25 +0100
commitb69610285c11ec3251c78c31f60d8a9e92db6e0d (patch)
treea64fd8b91e9ba0a11b7e6d3ee983781f83e3d4d1
downloadfloating-cats-extension-b69610285c11ec3251c78c31f60d8a9e92db6e0d.tar.gz
floating-cats-extension-b69610285c11ec3251c78c31f60d8a9e92db6e0d.tar.xz
floating-cats-extension-b69610285c11ec3251c78c31f60d8a9e92db6e0d.zip
Floating Cats 0.1
-rw-r--r--.gitignore1
-rw-r--r--bg.js13
-rw-r--r--bobvibes.webpbin0 -> 514582 bytes
-rw-r--r--floating-cats.css48
-rw-r--r--floating-cats.js50
-rw-r--r--manifest.json55
-rw-r--r--marsey3d.webpbin0 -> 149632 bytes
-rwxr-xr-xoptions/MPLUS1Code.ttfbin0 -> 3912412 bytes
-rwxr-xr-xoptions/MPLUS2.ttfbin0 -> 4125024 bytes
-rw-r--r--options/normalize.css349
-rw-r--r--options/options.html42
-rw-r--r--options/options.js11
-rw-r--r--options/style.css231
13 files changed, 800 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..500aabb
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
web-ext-artifacts/ \ No newline at end of file
diff --git a/bg.js b/bg.js
new file mode 100644
index 0000000..38a68f5
--- /dev/null
+++ b/bg.js
@@ -0,0 +1,13 @@
1"use strict";
2
3if (typeof(browser) == "undefined") {
4 globalThis.browser = chrome;
5}
6
7browser.browserAction.onClicked.addListener(async () => {
8 browser.runtime.openOptionsPage();
9
10 const enabled = (await browser.storage.sync.get("enabled")).enabled;
11 console.log(enabled);
12 await browser.storage.sync.set({ enabled: !enabled });
13});
diff --git a/bobvibes.webp b/bobvibes.webp
new file mode 100644
index 0000000..1e59e0e
--- /dev/null
+++ b/bobvibes.webp
Binary files differ
diff --git a/floating-cats.css b/floating-cats.css
new file mode 100644
index 0000000..6380668
--- /dev/null
+++ b/floating-cats.css
@@ -0,0 +1,48 @@
1:root {
2 --floating-cats-floating-delay: 0s;
3 --floating-cats-floating-width: 8rem;
4 --floating-cats-floating-height: 8rem;
5
6 --floating-cats-top: 0;
7 --floating-cats-left: 0;
8}
9
10.floating-cats-clickthru {
11 pointer-events: none;
12}
13
14.floating-cats-floating {
15 position: fixed;
16 top: var(--floating-cats-top);
17 left: var(--floating-cats-left);
18 z-index: 10000;
19 width: min-content;
20 height: min-content;
21}
22
23.floating-cats-floating img {
24 max-width: var(--floating-cats-floating-width);
25 max-height: var(--floating-cats-floating-height);
26}
27
28.floating-cats-floating-x {
29 animation: floating-cats-floating-x 16s linear infinite alternate;
30 animation-delay: var(--floating-cats-floating-delay);
31}
32
33.floating-cats-floating-y {
34 animation: floating-cats-floating-y 9s linear infinite alternate;
35 animation-delay: var(--floating-cats-floating-delay);
36}
37
38@keyframes floating-cats-floating-x {
39 100% {
40 transform: translateX(calc(100vw - var(--floating-cats-floating-width)));
41 }
42}
43
44@keyframes floating-cats-floating-y {
45 100% {
46 transform: translateY(calc(100vh - var(--floating-cats-floating-height)));
47 }
48}
diff --git a/floating-cats.js b/floating-cats.js
new file mode 100644
index 0000000..74acea4
--- /dev/null
+++ b/floating-cats.js
@@ -0,0 +1,50 @@
1"use strict";
2
3if (typeof(browser) == "undefined") {
4 globalThis.browser = chrome;
5}
6
7const cats = [];
8
9function reflectChange(changes, name, proc) {
10 if (name in changes
11 && "newValue" in changes[name]
12 && !Object.is(changes[name].newValue, changes[name].oldValue)) {
13 proc(changes[name].newValue);
14 }
15}
16
17async function main() {
18 let enabled = (await browser.storage.sync.get("enabled")).enabled;
19
20 browser.storage.onChanged.addListener(changes => {
21 reflectChange(changes, "enabled", newEnabled => {
22 enabled = newEnabled;
23 cats.forEach(cat => cat.hidden = !enabled);
24 });
25 });
26
27 let counter = 0;
28 function addCat(alt, url) {
29 const floatingX = document.createElement("div");
30 floatingX.style.setProperty("--floating-cats-floating-delay", `-${50 * counter++}s`);
31 floatingX.classList.add("floating-cats-clickthru");
32 floatingX.classList.add("floating-cats-floating");
33 floatingX.classList.add("floating-cats-floating-x");
34 floatingX.hidden = !enabled;
35 cats.push(floatingX);
36 document.body.appendChild(floatingX);
37
38 const floatingY = document.createElement("img");
39 floatingY.classList.add("floating-cats-clickthru");
40 floatingY.classList.add("floating-cats-floating-y");
41 floatingY.alt = alt;
42 floatingY.src = browser.runtime.getURL(url);
43 floatingX.appendChild(floatingY);
44 }
45
46 addCat("Spinning Marsey", "/marsey3d.webp");
47 addCat("Spinning Bob", "/bobvibes.webp");
48}
49
50main();
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..f34ad91
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,55 @@
1{
2 "manifest_version": 2,
3 "name": "Floating cats",
4 "version": "0.1",
5
6 "author": "Uko Kokņevičs",
7 "description": "Adds floating cats to all websites",
8
9 "icons": {
10 "200": "/marsey3d.webp"
11 },
12
13 "background": {
14 "scripts": ["/bg.js"],
15 "service_worker": "/bg.js",
16 "persistent": false,
17 "type": "module"
18 },
19
20 "browser_action": {
21 "default_area": "navbar"
22 },
23
24 "browser_specific_settings": {
25 "gecko": {
26 "id": "floating-cats@enes.lv"
27 },
28 "gecko_android": {
29 "id": "floating-cats@enes.lv"
30 }
31 },
32
33 "content_scripts": [{
34 "css": ["/floating-cats.css"],
35 "matches": ["<all_urls>"],
36 "match_about_blank": true,
37 "js": ["/floating-cats.js"],
38 "run_at": "document_end"
39 }],
40
41 "options_ui": {
42 "browser_style": false,
43 "open_in_tab": true,
44 "page": "options/options.html"
45 },
46
47 "permissions": [
48 "storage"
49 ],
50
51 "web_accessible_resources": [
52 "bobvibes.webp",
53 "marsey3d.webp"
54 ]
55}
diff --git a/marsey3d.webp b/marsey3d.webp
new file mode 100644
index 0000000..22aed84
--- /dev/null
+++ b/marsey3d.webp
Binary files differ
diff --git a/options/MPLUS1Code.ttf b/options/MPLUS1Code.ttf
new file mode 100755
index 0000000..20505b4
--- /dev/null
+++ b/options/MPLUS1Code.ttf
Binary files differ
diff --git a/options/MPLUS2.ttf b/options/MPLUS2.ttf
new file mode 100755
index 0000000..c5ee434
--- /dev/null
+++ b/options/MPLUS2.ttf
Binary files differ
diff --git a/options/normalize.css b/options/normalize.css
new file mode 100644
index 0000000..192eb9c
--- /dev/null
+++ b/options/normalize.css
@@ -0,0 +1,349 @@
1/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
2
3/* Document
4 ========================================================================== */
5
6/**
7 * 1. Correct the line height in all browsers.
8 * 2. Prevent adjustments of font size after orientation changes in iOS.
9 */
10
11html {
12 line-height: 1.15; /* 1 */
13 -webkit-text-size-adjust: 100%; /* 2 */
14}
15
16/* Sections
17 ========================================================================== */
18
19/**
20 * Remove the margin in all browsers.
21 */
22
23body {
24 margin: 0;
25}
26
27/**
28 * Render the `main` element consistently in IE.
29 */
30
31main {
32 display: block;
33}
34
35/**
36 * Correct the font size and margin on `h1` elements within `section` and
37 * `article` contexts in Chrome, Firefox, and Safari.
38 */
39
40h1 {
41 font-size: 2em;
42 margin: 0.67em 0;
43}
44
45/* Grouping content
46 ========================================================================== */
47
48/**
49 * 1. Add the correct box sizing in Firefox.
50 * 2. Show the overflow in Edge and IE.
51 */
52
53hr {
54 box-sizing: content-box; /* 1 */
55 height: 0; /* 1 */
56 overflow: visible; /* 2 */
57}
58
59/**
60 * 1. Correct the inheritance and scaling of font size in all browsers.
61 * 2. Correct the odd `em` font sizing in all browsers.
62 */
63
64pre {
65 font-family: monospace, monospace; /* 1 */
66 font-size: 1em; /* 2 */
67}
68
69/* Text-level semantics
70 ========================================================================== */
71
72/**
73 * Remove the gray background on active links in IE 10.
74 */
75
76a {
77 background-color: transparent;
78}
79
80/**
81 * 1. Remove the bottom border in Chrome 57-
82 * 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
83 */
84
85abbr[title] {
86 border-bottom: none; /* 1 */
87 text-decoration: underline; /* 2 */
88 text-decoration: underline dotted; /* 2 */
89}
90
91/**
92 * Add the correct font weight in Chrome, Edge, and Safari.
93 */
94
95b,
96strong {
97 font-weight: bolder;
98}
99
100/**
101 * 1. Correct the inheritance and scaling of font size in all browsers.
102 * 2. Correct the odd `em` font sizing in all browsers.
103 */
104
105code,
106kbd,
107samp {
108 font-family: monospace, monospace; /* 1 */
109 font-size: 1em; /* 2 */
110}
111
112/**
113 * Add the correct font size in all browsers.
114 */
115
116small {
117 font-size: 80%;
118}
119
120/**
121 * Prevent `sub` and `sup` elements from affecting the line height in
122 * all browsers.
123 */
124
125sub,
126sup {
127 font-size: 75%;
128 line-height: 0;
129 position: relative;
130 vertical-align: baseline;
131}
132
133sub {
134 bottom: -0.25em;
135}
136
137sup {
138 top: -0.5em;
139}
140
141/* Embedded content
142 ========================================================================== */
143
144/**
145 * Remove the border on images inside links in IE 10.
146 */
147
148img {
149 border-style: none;
150}
151
152/* Forms
153 ========================================================================== */
154
155/**
156 * 1. Change the font styles in all browsers.
157 * 2. Remove the margin in Firefox and Safari.
158 */
159
160button,
161input,
162optgroup,
163select,
164textarea {
165 font-family: inherit; /* 1 */
166 font-size: 100%; /* 1 */
167 line-height: 1.15; /* 1 */
168 margin: 0; /* 2 */
169}
170
171/**
172 * Show the overflow in IE.
173 * 1. Show the overflow in Edge.
174 */
175
176button,
177input { /* 1 */
178 overflow: visible;
179}
180
181/**
182 * Remove the inheritance of text transform in Edge, Firefox, and IE.
183 * 1. Remove the inheritance of text transform in Firefox.
184 */
185
186button,
187select { /* 1 */
188 text-transform: none;
189}
190
191/**
192 * Correct the inability to style clickable types in iOS and Safari.
193 */
194
195button,
196[type="button"],
197[type="reset"],
198[type="submit"] {
199 -webkit-appearance: button;
200}
201
202/**
203 * Remove the inner border and padding in Firefox.
204 */
205
206button::-moz-focus-inner,
207[type="button"]::-moz-focus-inner,
208[type="reset"]::-moz-focus-inner,
209[type="submit"]::-moz-focus-inner {
210 border-style: none;
211 padding: 0;
212}
213
214/**
215 * Restore the focus styles unset by the previous rule.
216 */
217
218button:-moz-focusring,
219[type="button"]:-moz-focusring,
220[type="reset"]:-moz-focusring,
221[type="submit"]:-moz-focusring {
222 outline: 1px dotted ButtonText;
223}
224
225/**
226 * Correct the padding in Firefox.
227 */
228
229fieldset {
230 padding: 0.35em 0.75em 0.625em;
231}
232
233/**
234 * 1. Correct the text wrapping in Edge and IE.
235 * 2. Correct the color inheritance from `fieldset` elements in IE.
236 * 3. Remove the padding so developers are not caught out when they zero out
237 * `fieldset` elements in all browsers.
238 */
239
240legend {
241 box-sizing: border-box; /* 1 */
242 color: inherit; /* 2 */
243 display: table; /* 1 */
244 max-width: 100%; /* 1 */
245 padding: 0; /* 3 */
246 white-space: normal; /* 1 */
247}
248
249/**
250 * Add the correct vertical alignment in Chrome, Firefox, and Opera.
251 */
252
253progress {
254 vertical-align: baseline;
255}
256
257/**
258 * Remove the default vertical scrollbar in IE 10+.
259 */
260
261textarea {
262 overflow: auto;
263}
264
265/**
266 * 1. Add the correct box sizing in IE 10.
267 * 2. Remove the padding in IE 10.
268 */
269
270[type="checkbox"],
271[type="radio"] {
272 box-sizing: border-box; /* 1 */
273 padding: 0; /* 2 */
274}
275
276/**
277 * Correct the cursor style of increment and decrement buttons in Chrome.
278 */
279
280[type="number"]::-webkit-inner-spin-button,
281[type="number"]::-webkit-outer-spin-button {
282 height: auto;
283}
284
285/**
286 * 1. Correct the odd appearance in Chrome and Safari.
287 * 2. Correct the outline style in Safari.
288 */
289
290[type="search"] {
291 -webkit-appearance: textfield; /* 1 */
292 outline-offset: -2px; /* 2 */
293}
294
295/**
296 * Remove the inner padding in Chrome and Safari on macOS.
297 */
298
299[type="search"]::-webkit-search-decoration {
300 -webkit-appearance: none;
301}
302
303/**
304 * 1. Correct the inability to style clickable types in iOS and Safari.
305 * 2. Change font properties to `inherit` in Safari.
306 */
307
308::-webkit-file-upload-button {
309 -webkit-appearance: button; /* 1 */
310 font: inherit; /* 2 */
311}
312
313/* Interactive
314 ========================================================================== */
315
316/*
317 * Add the correct display in Edge, IE 10+, and Firefox.
318 */
319
320details {
321 display: block;
322}
323
324/*
325 * Add the correct display in all browsers.
326 */
327
328summary {
329 display: list-item;
330}
331
332/* Misc
333 ========================================================================== */
334
335/**
336 * Add the correct display in IE 10+.
337 */
338
339template {
340 display: none;
341}
342
343/**
344 * Add the correct display in IE 10.
345 */
346
347[hidden] {
348 display: none;
349}
diff --git a/options/options.html b/options/options.html
new file mode 100644
index 0000000..a45c527
--- /dev/null
+++ b/options/options.html
@@ -0,0 +1,42 @@
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>Floating Cats Settings</title>
6
7 <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
9 <link rel="icon" href="/marsey3d.webp" type="image/webp">
10
11 <link rel="stylesheet" href="normalize.css">
12 <link rel="stylesheet" href="style.css">
13 <link rel="stylesheet" href="/floating-cats.css">
14
15 <script defer src="options.js" type="module"></script>
16 <script defer src="/floating-cats.js" type="module"></script>
17 </head>
18 <body>
19 <header>
20 <span class="fill left"></span>
21 <h1>Floating Cats Settings</h1>
22 <span class="fill right"></span>
23 </header>
24 <main>
25 <p>
26 Hello, these are the settings for Floating Cats :3
27 </p>
28 <fieldset>
29 <div class="field-row">
30 <label for="enable">Enable:</label>
31 <input type="checkbox" id="enable" name="enable">
32 </div>
33 <div class="field-row">
34 Yeah that's it for now lol
35 </div>
36 </fieldset>
37 </main>
38 <footer>
39 <p>Copyright © 2024 Eris</p>
40 </footer>
41 </body>
42</html>
diff --git a/options/options.js b/options/options.js
new file mode 100644
index 0000000..c2bacd5
--- /dev/null
+++ b/options/options.js
@@ -0,0 +1,11 @@
1if (typeof(browser) == "undefined") {
2 globalThis.browser = chrome;
3}
4
5const enableCheckbox = document.getElementById("enable");
6enableCheckbox.checked = (await browser.storage.sync.get("enabled")).enabled;
7enableCheckbox.addEventListener("change", async () => {
8 await browser.storage.sync.set({
9 enabled: enableCheckbox.checked,
10 });
11});
diff --git a/options/style.css b/options/style.css
new file mode 100644
index 0000000..90ad300
--- /dev/null
+++ b/options/style.css
@@ -0,0 +1,231 @@
1:root {
2 color-scheme: dark light;
3
4 --primary-hue: 192;
5 --secondary-hue: 41;
6 --saturation: 100%;
7 --lightness: 25%;
8
9 --primary: hsl(var(--primary-hue), var(--saturation), var(--lightness));
10 --secondary: hsl(var(--secondary-hue), var(--saturation), var(--lightness));
11}
12
13@font-face {
14 font-family: "M PLUS 2";
15 font-display: swap;
16 src: url("MPLUS2.ttf"), local("M PLUS 2");
17}
18
19@font-face {
20 font-family: "M PLUS 1 Code";
21 font-display: swap;
22 src: url("MPLUS1Code.ttf"), local("M PLUS 1 Code");
23}
24
25html {
26 height: 100%;
27 width: 100%;
28 font-family: "M PLUS 2", sans-serif;
29 line-height: 120%;
30 text-rendering: optimizeLegibility;
31}
32
33h1 {
34 font-size: 150%;
35 line-height: 110%;
36}
37
38h2 {
39 font-size: 115%;
40}
41
42h3 {
43 font-size: 100%;
44}
45
46b {
47 color: hsl(var(--secondary-hue), var(--saturation), 30%);
48}
49
50u {
51 text-decoration-color: var(--secondary);
52}
53
54pre, code {
55 font-family: "M PLUS 1 Code", monospace;
56 color: var(--secondary);
57 background-color: #eee;
58 border-radius: 4px;
59}
60
61body {
62 background: hsl(var(--primary-hue), 10%, 99%);
63 display: grid;
64 grid-template-rows: auto 1fr auto;
65 height: 100%;
66 width: 100%;
67}
68
69header {
70 display: flex;
71 flex-direction: row;
72 align-items: center; /* Vertical align */
73 background: hsl(var(--secondary-hue), 10%, 74%);
74 margin-bottom: 1rem;
75 border-bottom: 1px solid black;
76 padding: 0.5rem 0;
77
78 font-size: 125%;
79 line-height: 150%;
80
81 white-space: nowrap;
82 overflow: hidden;
83 text-overflow: ellipsis;
84}
85
86header * {
87 margin: 0.1rem 0.25rem auto;
88}
89
90header > * {
91 display: flex;
92 align-items: center;
93}
94
95header > .left {
96 justify-content: left;
97}
98
99header > .fill {
100 flex: 1;
101}
102
103header > .right {
104 justify-content: right;
105}
106
107header p {
108 margin: 0;
109}
110
111body > header svg,
112body > header img {
113 margin: 0.1rem;
114 height: 2.5rem;
115 width: 2.5rem;
116}
117
118footer {
119 display: flex;
120 background: hsl(var(--primary-hue), 10%, 94%);
121 flex-direction: column;
122 justify-content: center;
123 text-align: center;
124 font-height: 80%;
125 padding: 0.5rem;
126 border-top: 1px solid black;
127}
128
129#banners img {
130 height: 1.5rem;
131}
132
133a {
134 color: var(--secondary);
135 text-decoration: none;
136}
137
138a:hover {
139 color: var(--primary);
140 background-color: #eee;
141 border-radius: 4px;
142}
143
144a:visited {
145 color: var(--primary);
146}
147
148#banners a,
149header a,
150header a:visited {
151 color: currentcolor;
152}
153
154#banners a:hover,
155header a:hover {
156 background-color: transparent;
157 border-radius: 0;
158}
159
160fieldset {
161 background: hsl(var(--primary-hue), 10%, 90%);
162 display: flex;
163 flex-direction: row;
164 flex-wrap: wrap;
165}
166
167fieldset > * {
168 padding-right: 0.5rem;
169 border-right: 1px solid gray;
170 margin-right: 0.5rem;
171}
172
173fieldset > :last-child {
174 padding-right: initial;
175 border-right: initial;
176 margin-right: initial;
177}
178
179.field-row {
180 display: flex;
181 flex-direction: row;
182}
183
184.field-row label {
185 margin-right: 1rem;
186}
187
188@media (min-width: 1140px) {
189 body > main {
190 margin-left: 14rem;
191 margin-right: 4rem;
192 max-width: 52rem;
193 }
194}
195
196@media (min-width: 800px) and (max-width: 1140px) {
197 body > main {
198 margin-left: 6rem;
199 margin-right: 4rem;
200 max-width: 52rem;
201 }
202}
203
204@media (max-width: 800px) {
205 body > main {
206 margin-left: 1rem;
207 margin-right: 1rem;
208 }
209}
210
211@media (prefers-color-scheme: dark) {
212 body {
213 background: hsl(var(--primary-hue), 10%, 17%);
214 }
215
216 fieldset {
217 background: hsl(var(--primary-hue), 10%, 17%);
218 }
219
220 header {
221 background: hsl(var(--secondary-hue), 10%, 12%);
222 }
223
224 footer {
225 background: hsl(var(--primary-hue), 10%, 15%);
226 }
227
228 b {
229 color: hsl(var(--secondary-hue), var(--saturation), 75%);
230 }
231}