Greasy Fork

Greasy Fork is available in English.

Narou Counter

Count how many times you visit Narou today.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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