Narou Counter

Count how many times you visit Narou today.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Narou Counter
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Count how many times you visit Narou today.
// @author       beet
// @match        https://syosetu.com/user/top/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // alert(document.cookie);
    var d = new Date();
    var today = d.getMonth() * 100 + d.getDate();
    var lastday = Math.max(...(document.cookie.split(';').map(x => x.split("=")[0].trim() == "narou_lastday" ? x.split("=")[1] * 1.0 : 0)));
    var count = Math.max(...(document.cookie.split(';').map(x => x.split("=")[0].trim() == "narou_count" ? x.split("=")[1] * 1.0 : 0))) + 1;
    if (lastday != today) count = 1;
    alert("You visit Narou " + count + " times today!");
    document.cookie = "narou_lastday=" + today;
    document.cookie = "narou_count=" + count;

    var tomorrow = new Date();
    tomorrow.setDate(tomorrow.getDate() + 3);
    document.cookie = "expires=" + tomorrow.toUTCString();
})();