Compare commits

..

4 Commits
dev ... master

Author SHA1 Message Date
roffy3051
e614d279c1 Update README.md 2024-11-02 21:47:27 +08:00
roffy3051
1b4e98af4a feat: Improve performance
feat: Add `prefix` param
feat: Theme supports `_start` and `_end` as padding image
2024-11-02 21:44:48 +08:00
roffy3051
dbf98b4735 chore: Add themes 2024-11-02 21:39:14 +08:00
Jad
84b8111fd3
Update README.md 2024-11-01 01:05:05 +08:00
47 changed files with 54 additions and 9 deletions

View File

@ -4,7 +4,7 @@
<p align="center"> <p align="center">
<a href="https://count.getloli.com" target="_blank"> <a href="https://count.getloli.com" target="_blank">
<img alt="Moe Counter!" src="https://count.getloli.com/@Moe-counter.github?name=Moe-counter.github&theme=booru-lewd&padding=7&offset=0&align=top&scale=0.72&pixelated=0&darkmode=auto"> <img alt="Moe Counter!" src="https://count.getloli.com/@Moe-counter.github?name=Moe-counter.github&theme=booru-lewd&padding=7&offset=0&align=top&scale=1&pixelated=1&darkmode=auto">
</a> </a>
</p> </p>
@ -127,6 +127,14 @@
![booru-yuyuyui](https://count.getloli.com/@demo?theme=booru-yuyuyui) ![booru-yuyuyui](https://count.getloli.com/@demo?theme=booru-yuyuyui)
##### capoo-1
![capoo-1](https://count.getloli.com/@demo?theme=capoo-1)
##### capoo-2
![capoo-2](https://count.getloli.com/@demo?theme=capoo-2)
##### e621 ##### e621
![e621](https://count.getloli.com/@demo?theme=e621) ![e621](https://count.getloli.com/@demo?theme=e621)
@ -211,6 +219,14 @@
![shimmie2](https://count.getloli.com/@demo?theme=shimmie2) ![shimmie2](https://count.getloli.com/@demo?theme=shimmie2)
##### sketch-1
![sketch-1](https://count.getloli.com/@demo?theme=sketch-1)
##### sketch-2
![sketch-2](https://count.getloli.com/@demo?theme=sketch-2)
</details> </details>
## Demo ## Demo
@ -282,6 +298,10 @@ LOG_LEVEL=debug
--- ---
<p> <a href="https://star-history.com/?repos=journey-ad/Moe-Counter&type=Date#journey-ad/Moe-Counter&Date">
<img src="https://api.star-history.com/svg?repos=journey-ad/Moe-Counter&type=Date" alt="Star History Chart" style="width: 600px; height: 400px;" width="600" height="400" /> <picture>
</p> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=journey-ad/Moe-Counter&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=journey-ad/Moe-Counter&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=journey-ad/Moe-Counter&type=Date" />
</picture>
</a>

View File

@ -12,7 +12,8 @@
scale: document.getElementById('scale'), scale: document.getElementById('scale'),
pixelated: document.getElementById('pixelated'), pixelated: document.getElementById('pixelated'),
darkmode: document.getElementById('darkmode'), darkmode: document.getElementById('darkmode'),
num: document.getElementById('num') num: document.getElementById('num'),
prefix: document.getElementById('prefix')
}; };
btn.addEventListener('click', throttle(handleButtonClick, 500)); btn.addEventListener('click', throttle(handleButtonClick, 500));
@ -48,6 +49,9 @@
if (num.value > 0) { if (num.value > 0) {
params.num = num.value; params.num = num.value;
} }
if (prefix.value !== '') {
params.prefix = prefix.value;
}
const query = new URLSearchParams(params).toString(); const query = new URLSearchParams(params).toString();
const imgSrc = `${__global_data.site}/@${nameValue}?${query}`; const imgSrc = `${__global_data.site}/@${nameValue}?${query}`;

BIN
assets/theme/capoo-1/0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
assets/theme/capoo-1/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
assets/theme/capoo-1/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
assets/theme/capoo-1/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
assets/theme/capoo-1/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
assets/theme/capoo-1/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

BIN
assets/theme/capoo-1/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
assets/theme/capoo-1/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
assets/theme/capoo-1/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
assets/theme/capoo-1/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

BIN
assets/theme/capoo-2/0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/theme/capoo-2/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/theme/capoo-2/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
assets/theme/capoo-2/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
assets/theme/sketch-1/0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
assets/theme/sketch-1/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

BIN
assets/theme/sketch-1/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
assets/theme/sketch-1/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
assets/theme/sketch-1/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
assets/theme/sketch-1/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
assets/theme/sketch-1/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
assets/theme/sketch-1/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

BIN
assets/theme/sketch-1/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
assets/theme/sketch-1/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
assets/theme/sketch-2/0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
assets/theme/sketch-2/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
assets/theme/sketch-2/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
assets/theme/sketch-2/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
assets/theme/sketch-2/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
assets/theme/sketch-2/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
assets/theme/sketch-2/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
assets/theme/sketch-2/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
assets/theme/sketch-2/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
assets/theme/sketch-2/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -35,13 +35,16 @@ app.get(["/@:name", "/get/@:name"],
}), }),
query: z.object({ query: z.object({
theme: z.string().default("moebooru"), theme: z.string().default("moebooru"),
num: z.coerce.number().int().min(0).max(1e15).default(0), // a carry-safe integer, less than `2^53-1`, and aesthetically pleasing in decimal.
padding: z.coerce.number().int().min(0).max(16).default(7), padding: z.coerce.number().int().min(0).max(16).default(7),
offset: z.coerce.number().min(-500).max(500).default(0), offset: z.coerce.number().min(-500).max(500).default(0),
align: z.enum(["top", "center", "bottom"]).default("top"), align: z.enum(["top", "center", "bottom"]).default("top"),
scale: z.coerce.number().min(0.1).max(2).default(1), scale: z.coerce.number().min(0.1).max(2).default(1),
pixelated: z.enum(["0", "1"]).default("1"), pixelated: z.enum(["0", "1"]).default("1"),
darkmode: z.enum(["0", "1", "auto"]).default("auto") darkmode: z.enum(["0", "1", "auto"]).default("auto"),
// Unusual Options
num: z.coerce.number().int().min(0).max(1e15).default(0), // a carry-safe integer, less than `2^53-1`, and aesthetically pleasing in decimal.
prefix: z.coerce.number().int().min(-1).max(999999).default(-1)
}) })
}), }),
async (req, res) => { async (req, res) => {

View File

@ -42,7 +42,7 @@ function convertToDatauri(path) {
} }
function getCountImage(params) { function getCountImage(params) {
let { count, theme = 'moebooru', padding = 7, offset = 0, align = 'top', scale = 1, pixelated = '1', darkmode = 'auto' } = params let { count, theme = 'moebooru', padding = 7, prefix = -1, offset = 0, align = 'top', scale = 1, pixelated = '1', darkmode = 'auto' } = params
if (!(theme in themeList)) theme = 'moebooru' if (!(theme in themeList)) theme = 'moebooru'
padding = parseInt(Number(padding), 10) padding = parseInt(Number(padding), 10)
@ -51,6 +51,20 @@ function getCountImage(params) {
// This is not the greatest way for generating an SVG but it'll do for now // This is not the greatest way for generating an SVG but it'll do for now
const countArray = count.toString().padStart(padding, '0').split('') const countArray = count.toString().padStart(padding, '0').split('')
// Add prefix if exist
if (prefix >= 0) {
countArray.unshift(...String(prefix).split(''))
}
// Add _start and _end if exist
if (themeList[theme]['_start']) {
countArray.unshift('_start')
}
if (themeList[theme]['_end']) {
countArray.push('_end')
}
const uniqueChar = [...new Set(countArray)] const uniqueChar = [...new Set(countArray)]
let x = 0, y = 0 let x = 0, y = 0

View File

@ -92,7 +92,7 @@ html
option(value=theme) #{theme} option(value=theme) #{theme}
tr tr
td: code padding td: code padding
td Set the minimum length, between 1-32, default is td Set the minimum length, between 1-16, default is
code 7 code 7
td: input#padding(type='number', value='7', min='1', max='32', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")') td: input#padding(type='number', value='7', min='1', max='32', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")')
tr tr
@ -136,6 +136,10 @@ html
td Set counter display number, 0 for disable, default is td Set counter display number, 0 for disable, default is
code 0 code 0
td: input#num(type='number', value='0', min='0', max='1e15', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")') td: input#num(type='number', value='0', min='0', max='1e15', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")')
tr
td: code prefix
td Set the prefix number, empty for disable
td: input#prefix(type='number', value='', min='0', max='999999', step='1', oninput='this.value = this.value.replace(/[^0-9]/g, "")')
button#get(onclick='_evt_push("click", "normal", "get_counter")') Generate button#get(onclick='_evt_push("click", "normal", "get_counter")') Generate