Greasy Fork

Greasy Fork is available in English.

爱心爱心~~

点击冒出心心

目前为 2019-09-05 提交的版本。查看 最新版本

// ==UserScript==
// @name         爱心爱心~~
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  点击冒出心心
// @author       You
// @match        *://*/*
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function () {
  'use strict';
  var style = document.createElement("style");
  style.type = "text/css";
  style.innerHTML = `
  .heart {
    color: rgb(223, 62, 62);
    opacity: 0;
    font-size: 14px;
    position: absolute;
    z-index:9999999;
  }
  .heartShowToHide {
    animation: 1.5s heart;
  }
  @keyframes heart {
    0% {transform: translateY(0);opacity: 1;}
    100% {transform: translateY(-150px);opacity: 0;}
  }
  `
  $(document.head).append(style)
  var timeId;
  var heartShow = function (e) {
    e = e || window.event;
    clearInterval(timeId)
    let x = e.pageX - 20;
    let y = e.pageY - 30;
    let heart = $(`<div class="heart heartShowToHide">么么哒❤</div>`)
    heart.css({
      'top': `${y}px`,
      'left': `${x}px`
    })
    $(document.body).append(heart)
    timeId = setInterval(() => {
      $('.heart').remove();
    }, 1000);
  }
  $(window).click(function () {
    heartShow()
  })
  // 如果想要更多更多更多心就把下面注释打开 把上面的注释掉
  // $(window).mousemove(function(){
  //   heartShow()
  // })
  // Your code here...
})();