// ==UserScript==
// @name Smart CZOJ
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 让网站变得更加美观
// @author cyx2009
// @match *://47.103.114.172/*
// @grant GM_addStyle
// @license MIT
// ==/UserScript==
(function() {
'use strict';
/*点击特效*/
window.onload = (()=>{
//定义点击出现文字类
function ClickFrontShow() {
//定义所需文字和颜色
this.fron = ['高兴', '开心', '❤', '欢乐', '愉悦', '愉快', '快乐', '欢喜', '喜悦', '欢欣', '欢畅', '欢腾', '雀跃', '欢快'];
this.colo = ['#FF69B4', '#ff6651', 'orange', '#FF00FF', '#00FF7F', '#00BFFF', '#BA55D3'];
//获取body元素
this.elBody = document.getElementsByTagName("body")[0];
//初始化randomNum
this.randomNum = null;
//初始化字体inde
this.finde = 0;
//初始化className
this.cls = 0;
}
//定义初始化
ClickFrontShow.prototype.init = function(frontArray, colorArray) {
//自定义颜色和字体
this.fron = frontArray || this.fron;
this.colo = colorArray || this.colo;
this.listenMouse();
}
//创建文字
ClickFrontShow.prototype.createFront = function (classname) {
var self = this;
let ospan = document.createElement('span');
//设置样式
let cssText = "position:absolute; width: 40px; height: 20px; cursor: default; transform: translate(-50%,-50%); font-weight: bold; opacity: 1; z-index: 1000; transition: 1s;";
//随机字体和颜色
let randomFront = self.fron[self.finde];
let randomColor = self.colo[Math.round(Math.random()*(self.colo.length-1))];
//字体下标增1
self.finde = (self.finde+1) % self.fron.length;
//向body中添加元素
self.elBody.appendChild(ospan);
//绑定一个classname
ospan.className = String(classname);
//添加样式
ospan.style.cssText = cssText + "-moz-user-select: none;-webkit-user-select: none;-ms-user-select: none;user-select: none;"
ospan.style.color = randomColor;
ospan.innerHTML = randomFront;
}
//监听鼠标点击
ClickFrontShow.prototype.listenMouse = function() {
var self = this;
//鼠标点击事件
document.onclick = function(e) {
//避免classname值重复导致出现bug
if(self.cls === 20){
self.cls = 0;
}else{
self.cls += 1;
}
//创建文字
self.createFront(self.cls);
let el = document.getElementsByClassName(self.cls)[0];
//鼠标点击位置
el.style.left = e.clientX + 'px';
el.style.top = e.clientY + 'px';
//过时改变
setTimeout(function() {
el.style.opacity = 0;
el.style.top = el.offsetTop - 100 + 'px';
}, 100);
//过时清除
setTimeout(function() {
self.elBody.removeChild(el);
}, 2000);
}
}
//实例化
var frontShow = new ClickFrontShow();
//用户可在此传递参数,默认第一个参数是字体数组;
//第二个参数是颜色数组,必须是数组类型!
frontShow.init();
})();
/*背景线条*/
(() =>
{
function e(e, n, t)
{
return e.getAttribute(n) || t
}
function n()
{
l = i.width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth, u = i.height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
}
function c()
{
var t, o, i, a, m;
r.clearRect(0, 0, l, u), s.forEach(function(e, n)
{
for (e.x += e.xa, e.y += e.ya, e.xa *= e.x > l || e.x < 0 ? -1 : 1, e.ya *= e.y > u || e.y < 0 ? -1 : 1, r.fillRect(e.x - .5, e.y - .5, 1, 1), o = n + 1; o < d.length; o++) null !== (t = d[o]).x && null !== t.y && (i = e.x - t.x, a = e.y - t.y, (m = i * i + a * a) < t.max && (t === y && m >= t.max / 2 && (e.x -= .03 * i, e.y -= .03 * a), m = (t.max - m) / t.max, r.beginPath(), r.lineWidth = m / 2, r.strokeStyle = "rgba(" + x.c + "," + (.2 + m) + ")", r.moveTo(e.x, e.y), r.lineTo(t.x, t.y), r.stroke()))
}), w(c)
}
var l, u, d, t, o, i = document.createElement("canvas"),
x = (t = (o = document.getElementsByTagName("script")).length, o = o[t - 1],
{
l: t,
z: e(o, "zIndex", -1),
o: e(o, "opacity", .5),
c: e(o, "color", "0,0,0"),
n: e(o, "count", 99)
}),
a = "c_n" + x.l,
r = i.getContext("2d"),
w = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(e)
{
window.setTimeout(e, 1e3 / 45)
},
m = Math.random,
y = {
x: null,
y: null,
max: 2e4
};
i.id = a, i.style.cssText = "position:fixed;top:0;left:0;z-index:" + x.z + ";opacity:" + x.o, document.getElementsByClassName("main")[0].appendChild(i), n(), window.onresize = n, window.onmousemove = function(e)
{
e = e || window.event, y.x = e.clientX, y.y = e.clientY
}, window.onmouseout = function()
{
y.x = null, y.y = null
};
for (var s = [], h = 0; x.n > h; h++)
{
var f = m() * l,
g = m() * u,
p = 2 * m() - 1,
v = 2 * m() - 1;
s.push(
{
x: f,
y: g,
xa: p,
ya: v,
max: 6e3
})
}
d = s.concat([y]), setTimeout(function()
{
c()
}, 100)
})();
/*卡片圆角*/
const a = document.createElement('style');
a.innerHTML = `.section{border-radius:30px}`;
document.head.append(a);
})();