浮动的字脚本

浮动的字

当前为 2021-06-20 提交的版本,查看 最新版本

// ==UserScript==
// @name        浮动的字脚本
// @namespace     http://blog.csdn.net/
// @version      1.2
// @description  浮动的字
// @author       吴玉配
// @match       https://*/*
 // @grant    GM_addStyle
// ==/UserScript==

(function() {
 var mytext = ['富强','民主','和谐','文明','民主','爱国','奉献','无私','公正']

        var mydiv = document.createElement('div')

        var mytimer = null

        document.addEventListener('click',function(e) { 

            clearInterval(mytimer)
            var opacity = 1
            let top = e.clientY
            let left = e.clientX
            var thetop = top
            // 设置mydiv样式
            mydiv.style.position = "fixed"
            mydiv.style.top = top - 15 + 'px'
            mydiv.style.left = left - 15 + 'px'
            mydiv.style.width = "50px"
            mydiv.style.textAlign = "center"
            mydiv.style.letterSpacing = 3 + 'px'
            mydiv.style.fontSize = 16 + 'px'
            mydiv.style.cursor = "default"
            mydiv.style.color = getColor()
            mydiv.style.fontFamily = "FZShuTi"
            mydiv.innerText = mytext[Math.floor( Math.random() * mytext.length)]
            mydiv.style.opacity = 1
            mydiv.style.zIndex = 100000000000
            document.body.appendChild(mydiv)
            mytimer = setInterval(() => {
                if(opacity > 0) {
                    mydiv.style.opacity = opacity -= 0.005
                }
                mydiv.style.top = (top--) - 15 + 'px'
                if (thetop - top > 100) {
                    document.body.removeChild(mydiv)
                    clearInterval(mytimer)
                }
            },5)
        })

        function getColor() {
            var colorarr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f']
            var color = "#"
            for (var i = 0; i < 6; i++) {
                color += colorarr[Math.floor(Math.random() * colorarr.length)]
            }
            return color
        }
})(document);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址