Page Visit Counter

Show a counter of page visit on bottom right of page./网页访问计数器,在网页右下角显示页面的访问次数

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Page Visit Counter
// @namespace    http://user-script.yunser.com/
// @version      0.1
// @description  Show a counter of page visit on bottom right of page./网页访问计数器,在网页右下角显示页面的访问次数
// @author       Yunser
// @match        */*
// @icon
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        window.location
// ==/UserScript==

(function () {
    'use strict';

    const sValue = GM_getValue('__counter-' + window.location.href)
    let count = sValue ? (parseInt(sValue) + 1) : 1
    GM_setValue('__counter-' + window.location.href, count)
    const root = document.createElement('DIV')
    root.innerHTML = '' + count
    root.style = `
    position: fixed;
    right: 0;
    bottom: 0;
    z-index: 100000000;
    background-color: #f00;
    color: #fff;
    padding: 8px;
`
    const body = document.querySelector('body')
    body.appendChild(root)
})();