Greasy Fork

Greasy Fork is available in English.

自用价值观 - 点击时刻提醒(优化点击性能)

价值观 在你每次点击时飘出并提示!

当前为 2020-08-13 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         自用价值观 - 点击时刻提醒(优化点击性能)
// @namespace    http://tampermonkey.net/
// @version      1.1.5
// @description  价值观 在你每次点击时飘出并提示!
// @author       Cody
// @include      http://*
// @include      https://*
// @exclude      *mail.qq.com*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
  'use strict';
  var animateInterval = 2;
  var coreSocialistValues = ["文明", "自由", "民主", "平等", "公正", "法制", "和谐", "敬业", "友善", '狗头保命', '爱学习', '埋头苦干', '加油干', '别走神', '去学习', '去工作', '别划水', '别吵我','别逼逼','思考中'],
    index;
  window.addEventListener('click', function (e) {
    index = Math.floor(Math.random() * coreSocialistValues.length)
    //if (e.target.tagName == 'A') {
    //return;
    //}
    var x = e.pageX,
      y = e.pageY,
      el;
    var bubble = document.querySelectorAll('.bubble')
    try {
      [].forEach.call(bubble, ((element, index) => {
        if (element.style.content == 'none') {
          el = element;
          throw "优化点击,DOM复用中";
        }
      }));
    }
     catch(error){
      //console.log(error)
      }
      finally {
      if (!el) {
        el = document.createElement('span');
        el.classList.add('bubble');
        document.body.appendChild(el);
      }
      el.style.cssText = ['z-index: 9999; position: absolute; font-size: 14px; font-weight: bold; color: #dd2222;opacity:1;content:"animateing"; top: ', y - 20, 'px; left: ', x, 'px;'].join('');
      el.textContent = coreSocialistValues[index];
      setTimeout(function () {
        animate(el);
      })
    }
  });

  function animate(el) {
    var top = parseInt(el.style.top);
    el.style.transition = 'all ' + animateInterval + 's'
    el.style.top = top - 200 + 'px';
    el.style.opacity = 0;
    setTimeout(function () {
      el.style.content = 'none'
      /*setTimeout(function () {
        if (el.style.content = 'none') {
          el.parentNode.removeChild(el);
        }
      }, 1000 * animateInterval)*/
    }, 1000 * animateInterval)
  }
})();