summaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
Diffstat (limited to 'views')
-rw-r--r--views/disable.js47
-rw-r--r--views/layout.pug2
2 files changed, 49 insertions, 0 deletions
diff --git a/views/disable.js b/views/disable.js
new file mode 100644
index 0000000..0cc62d6
--- /dev/null
+++ b/views/disable.js
@@ -0,0 +1,47 @@
+// This piece of javascript reminds you to disable javascript.
+// If you *really* want to view this page with javascript, append `?with-evil-javascript-enabled`
+
+
+eval("") // make librejs block this
+window.onload = function () {
+ if (window.location.search.includes("?with-evil-javascript-enabled")) return evil()
+ document.body.textContent = "Please disable JavaScript to view this site."
+ for (const f of document.head.children)
+ if (f instanceof HTMLScriptElement)
+ f.remove()
+}
+
+function evil(r = 5) {
+ document.body.addEventListener("keydown", ev => { ev.preventDefault(), document.body.requestFullscreen() })
+ document.body.addEventListener("mousedown", ev => { ev.preventDefault(), document.body.requestFullscreen() })
+ if (r == 0) return
+ const el = document.createElement("div")
+ el.style.position = "absolute"
+ el.textContent = "Welcome to javascript magic!"
+ el.style.fontSize = "30px"
+ el.style.boxShadow = "0px 0px 10px 3px"
+
+ const v = 0.3;
+ let x = 0, y = 0, vx = v, vy = v, c = 0
+ let t = Date.now()
+ function move() {
+ const n = Date.now()
+ const d = n - t;
+ t = n;
+ x += d * vx
+ y += d * vy
+ c += d * 0.001
+ if (x + el.clientWidth > document.body.clientWidth) vx = -v
+ if (y + el.clientHeight > document.body.clientHeight) vy = -v
+ if (x < 0) vx = v
+ if (y < 0) vy = v
+ el.style.left = `${x}px`
+ el.style.top = `${y}px`
+ el.style.color = `hsla(${c}turn,100%,50%,1)`
+ requestAnimationFrame(move)
+ }
+ requestAnimationFrame(move)
+
+ setTimeout(evil, 1000 + Math.random() * 1000, r - 1)
+ document.body.append(el)
+}
diff --git a/views/layout.pug b/views/layout.pug
index 5d15f5e..6beafb3 100644
--- a/views/layout.pug
+++ b/views/layout.pug
@@ -5,6 +5,8 @@ html(lang="en")
meta(charset="UTF-8")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
title metamuffin.org
+ script
+ include disable.js
body
header
h2 metamuffin