Narou Counter

Count how many times you visit Narou today.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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();
})();