MoeCounter.js is a JavaScript library that allows for easy integration of attractive visual counters into your web projects or profiles, such as GitHub. With a variety of appearances and customization options, you can add a unique style to your website or application. MoeCounter is perfectly suited for use as a view counter, visit counter, online user counter, subscriber counter, follower counter, etc. It can be seamlessly used on any website or in applications that utilize WebView2.
npm install moecounter.js
<script src="https://cdn.jsdelivr.net/npm/moecounter.js@1/dist/browser/moecounter.min.js"></script>
https://sefinek.net/npm/moecounter.js/demo
https://api.sefinek.net/api/v2/moecounter?number=1234567890&length=10&theme=default&pixelated=true
https://api.sefinek.net/api/v2/moecounter?number=1234567890&length=10&theme=asoul&pixelated=true
https://api.sefinek.net/api/v2/moecounter?number=1234567890&length=10&theme=moebooru&pixelated=true
https://api.sefinek.net/api/v2/moecounter?number=1234567890&length=10&theme=gelbooru&pixelated=true
Generates a visual counter based on the provided options. Using the local function, developers have the ability to specify the exact value they want to display on the counter. In such cases, using your own database is recommended. It's important to note that this function has more lenient query limit restrictions (rate limits). For the purposes of displaying any kind of statistics, the BELOW method is preferred.
-
number
-(default 0)
: The value you want to display on the counter. -
length
-(default 10)
: The length of the counter. -
theme
-(default default)
: The appearance of the counter. -
pixelated
-(default true; recommended true)
: Should the counter be pixelated? -
svg
-(default false; recommended false)
: Should the module provide SVG data?
In this setup, the API server manages the counter. Developers do not have the capability to modify the counter value. When a user visits a webpage containing the counter (with a link to api.sefinek.net), the counter value will be incremented by 1. An increment is allowed once every 20 minutes from the same IP address. If this limit is exceeded, the server will NOT return any HTTP error, but simply will not increase the counter value.
-
name
-(required)
: A unique counter name. It is best to choose a unique name that reflects the purpose of the counter. It's also a good idea to add random characters at the end, e.g.,mywebsiteviews-sM7JJb2trEr9
. -
length
-(default 10)
: The length of the counter. -
theme
-(default default)
: The appearance of the counter. -
pixelated
-(default true; recommended true)
: Should the counter be pixelated? -
svg
-(default false; recommended false)
: Should the module provide SVG data?
[!IMPORTANT]
Remember to inform users that their IP addresses are collected on an external server (api.sefinek.net)! If you use the counter exclusively on GitHub (in repositories, etc.), you do not need to do this.
const moecounter = require('moecounter.js');
const showMoeCounter = async () => {
const data = await moecounter.local({
number: 1234567890,
length: 10,
theme: 'default',
pixelated: true,
svg: false
});
console.log(data);
// Output:
// {
// url: 'https://api.sefinek.net/api/v2/moecounter?number=1234567890&length=10&theme=default&pixelated=true&svg=false'
// }
}
showMoeCounter();
[!NOTE]
If you want to see a sample counter in action, please visit this page.
This project is an enhanced fork of journey-ad/Moe-Counter. It features improved rate limit handling and enhanced server-side code quality.
If you like this module, please star ⭐ the repository. If you have any questions or need help, feel free to reach out to me via email or open a new Issue.
This module is provided under the MIT License
. See the LICENSE file for more details.
Copyright 2024 © by Sefinek. All Rights Reserved.