Readme

Retro Visit Counter

You are visitor number:

How special!

Want a retro visitor counter for your myspace page or geocities website? Fork this val and add the image link to your website:

<img src="https://maxm-retrovisitcounter.web.val.run/counter.png">
<!-- Make sure you swap this subdomain out with the subdomain of your forked val --> 
<img src="https://[CHANGE ME!].web.val.run/counter.png">
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { sqlite } from "https://esm.town/v/std/sqlite";
await sqlite.execute(`create table if not exists counter(
name text,
counter integer
)`);
async function getCurrentCount(): Promise<number> {
let counter = await sqlite.execute(`select counter from counter where name = 'retro'`);
if (counter.rows.length === 0) {
await sqlite.execute(`insert into counter (name, counter) values ('retro', 1)`);
}
let [currentCount] = (counter.rows[0] as unknown) as number[];
await sqlite.execute(`update counter set counter = counter + 1 where name = 'retro'`);
return currentCount;
}
export const retroVisitCounter = async (request: Request) => {
const count = await getCurrentCount();
const { encode } = await import("https://deno.land/x/pngs/mod.ts");
if (request.url.endsWith("favicon.ico"))
return new Response("not found", { status: 404 });
// Set up all of our configured constants.
const numberPixelHeight = 7;
const numberPixelWidth = 5;
const pixelMultiplier = 3;
const numberPlaces = 6;
const padding = 1;
const B = [0, 0, 0, 255]; // Black
const _ = [153, 153, 153, 255]; // Transparent
// dprint-ignore
const numbers = [
[
_, B, B, B, _,
B, _, _, _, B,
B, _, _, B, B,
B, _, B, _, B,
B, B, _, _, B,
B, _, _, _, B,
_, B, B, B, _,
],
[
_, _, B, _, _,
_, B, B, _, _,
_, _, B, _, _,
_, _, B, _, _,
_, _, B, _, _,
_, _, B, _, _,
B, B, B, B, B,
],
[
_, B, B, B, _,
B, _, _, _, B,
_, _, _, _, B,
_, _, B, B, _,
_, B, _, _, _,
B, _, _, _, _,
B, B, B, B, B,
],
[
_, B, B, B, _,
B, _, _, _, B,
_, _, _, _, B,
_, _, B, B, _,
_, _, _, _, B,
B, _, _, _, B,
_, B, B, B, _,
],
[
_, _, _, B, B,
_, _, B, _, B,
_, B, _, _, B,
B, _, _, _, B,
B, B, B, B, B,
_, _, _, _, B,
_, _, _, _, B,
],
[
B, B, B, B, B,
B, _, _, _, _,
B, B, B, B, _,
_, _, _, _, B,
_, _, _, _, B,
B, _, _, _, B,
_, B, B, B, _,
],
[
_, _, B, B, _,
_, B, _, _, _,
B, _, _, _, _,
B, B, B, B, _,
B, _, _, _, B,
B, _, _, _, B,
_, B, B, B, _,
],
[
B, B, B, B, B,
B, _, _, _, B,
_, _, _, _, B,
_, _, _, B, _,
_, _, B, _, _,
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.