【网页插件】@消息提醒(更新)

@Ta 2018-08-15发布,2023-02-25修改 8217点击
被下沉
做这个得原因,因为@ ChatGPT 后每次都要刷新几次看下到底回复了没有,很麻烦。
更新:当有@消息时,网页会有呼吸灯效果,其实代码很简单,只是让这个呼吸灯更加好看费了点劲。

导入网页插件:@消息提醒(当前用户:22,总安装次数:51)
<script src="https://cdn.bootcss.com/jquery/2.1.0/jquery.min.js"> </script>
<script>
    var is_add = false;
    $(document).ready(function() {

        self.setInterval("checkNewMessage()", 1000);
    });

	showMessage();
    // function checkNewMessage() {
    //     $.getJSON("/q.php/index.index.json", function(result) {
    //         if (result['userInfo']['newAtInfo'] > 0 || result['userInfo']['newMsg'] > 0) {
    //             showMessage();
    //         }
    //     });
    // }

    function showMessage() {
        if (is_add) {

        } else {
            is_add = true;

            const colorBlock = document.createElement("div");
			colorBlock.id = "color-block";
			colorBlock.style.position = "fixed";
			colorBlock.style.top = 0;
			colorBlock.style.left = 0;
			colorBlock.style.width = "100%";
			colorBlock.style.height = "100%";
			colorBlock.style.transition = "background 1s ease-in-out";
			colorBlock.style.zIndex = -1;
			document.body.insertAdjacentElement("afterbegin", colorBlock);

			const containers = document.querySelectorAll(".container");
			containers.forEach((container) => {
			  container.style.backgroundColor = "#ffffff47";
			});


			const generateColors = () => {
			  const colors = [];

			  const hue = Math.floor(Math.random() * 360);
			  const saturation = Math.floor(Math.random() * 21) + 80;
			  const lightness = Math.floor(Math.random() * 11) + 70;

			  for (let i = 0; i < 20; i++) {
			    const h = hue;
			    const s = saturation;
			    const l = lightness + i * 2;

			    colors.push(`hsl(${h}, ${s}%, ${l}%)`);
			  }

			  return colors;
			};

            // const colorBlock = document.getElementById("color-block");
			const colors = generateColors();



			let currentColor = 0;
			let direction = 1;

		

			let currentIndex = 0;

			function changeBackground() {
			    const nextIndex = currentIndex + direction;
				if (nextIndex === colors.length || nextIndex === -1) {
				    direction = -direction;
				    currentIndex += direction;
				} else {
				    document.body.style.background = `linear-gradient(to bottom right, ${colors[currentIndex]}, ${colors[nextIndex]})`;
				    currentIndex = nextIndex;
				}
			}

			setInterval(changeBackground, 100);


			// setInterval(changeColor, 200);

        }
    }




</script>





回复列表(8|隐藏机器人聊天)
添加新回复
回复需要登录