社会主义核心价值观 - 点击时提醒

社会主义核心价值观 在你每次点击时飘出并提示!

目前為 2020-05-18 提交的版本,檢視 最新版本

// ==UserScript==
// @name         社会主义核心价值观 - 点击时提醒
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  社会主义核心价值观 在你每次点击时飘出并提示!
// @author       Cody
// @include      http://*
// @include      https://*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
    'use strict';
    var words = ["\u5bcc\u5f3a", "\u6c11\u4e3b", "\u6587\u660e", "\u548c\u8c10", "\u81ea\u7531", "\u5e73\u7b49", "\u516c\u6b63", "\u6cd5\u6cbb", "\u7231\u56fd", "\u656c\u4e1a", "\u8bda\u4fe1", "\u53cb\u5584"],
        index = Math.floor(Math.random() * words.length);
    document.body.addEventListener('click', function (e) {
        if (e.target.tagName == 'A') {
            return;
        }
        var x = e.pageX,
            y = e.pageY,
            span = document.createElement('span');
        span.textContent = words[index];
        index = (index + 1) % words.length;
        span.style.cssText = ['z-index: 9999999; position: absolute; font-size: 14px; font-weight: bold; color: #dd2222; top: ', y - 20, 'px; left: ', x, 'px; transition: all 1.5s linear;'].join('');
        document.body.appendChild(span);
        setTimeout(function() {
            span.style.top = y - 200 + 'px';
            span.style.opacity = 0;
            setTimeout(function() {
                span.parentNode.removeChild(span);
            }, 1500);
        }, 0);
    });
})();