Skip to content

Commit c216f6f

Browse files
authored
0.0.2
1 parent 32b94ca commit c216f6f

File tree

1 file changed

+56
-57
lines changed

1 file changed

+56
-57
lines changed

mourning.js

+56-57
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,75 @@
1-
!function() {
1+
!function () {
22
"use strict";
33
var scriptElement = document.currentScript;
44
var days = scriptElement.getAttribute("days").split(',');
55
var customText = scriptElement.getAttribute("text");
66
var duration = parseInt(scriptElement.getAttribute("duration"));
77
var nolog = scriptElement.getAttribute("nolog");
8-
8+
99
/* 哀悼日网站变灰 */
1010
document.addEventListener("DOMContentLoaded", function () {
1111
if (aidaori()) {
12-
var htmlElement = document.querySelector("html");
13-
htmlElement.style.filter = "gray !important";
14-
htmlElement.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
15-
htmlElement.style.filter = "grayscale(100%)";
16-
htmlElement.style.webkitFilter = "grayscale(100%)";
17-
htmlElement.style.MozFilter = "grayscale(100%)";
18-
htmlElement.style.msFilter = "grayscale(100%)";
19-
htmlElement.style.oFilter = "grayscale(100%)";
20-
createCandleText(customText);
12+
var htmlElement = document.querySelector("html");
13+
htmlElement.style.filter = "gray !important";
14+
htmlElement.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
15+
htmlElement.style.filter = "grayscale(100%)";
16+
htmlElement.style.webkitFilter = "grayscale(100%)";
17+
htmlElement.style.MozFilter = "grayscale(100%)";
18+
htmlElement.style.msFilter = "grayscale(100%)";
19+
htmlElement.style.oFilter = "grayscale(100%)";
20+
createCandleText(customText);
21+
// 打印仓库地址
22+
if (nolog !== "true") {
23+
console.log(customText + " mourning哀悼日 Github仓库: https://github.com/byteforgecn/mourning");
24+
}
2125
}
2226
// 判断日期
2327
function aidaori() {
24-
var aidaoriarr = days;
25-
var mydate = new Date();
26-
var str = "";
27-
var mm = mydate.getMonth() + 1;
28-
if (mydate.getMonth() > 8) {
29-
str += mm;
30-
} else {
31-
str += "0" + mm;
32-
}
33-
if (mydate.getDate() > 9) {
34-
str += mydate.getDate();
35-
} else {
36-
str += "0" + mydate.getDate();
37-
}
38-
if (aidaoriarr.indexOf(str) > -1) {
39-
return 1;
40-
} else {
41-
return 0;
42-
}
28+
var aidaoriarr = days;
29+
var mydate = new Date();
30+
var str = "";
31+
var mm = mydate.getMonth() + 1;
32+
if (mydate.getMonth() > 8) {
33+
str += mm;
34+
} else {
35+
str += "0" + mm;
36+
}
37+
if (mydate.getDate() > 9) {
38+
str += mydate.getDate();
39+
} else {
40+
str += "0" + mydate.getDate();
41+
}
42+
if (aidaoriarr.indexOf(str) > -1) {
43+
return 1;
44+
} else {
45+
return 0;
46+
}
4347
}
4448
// 创建蜡烛文字的函数
4549
function createCandleText(text) {
46-
var candleTextElement = document.createElement("div");
47-
candleTextElement.id = "candleText";
48-
candleTextElement.textContent = text;
49-
var style = candleTextElement.style;
50-
style.position = "fixed";
51-
style.top = "50%";
52-
style.left = "50%";
53-
style.transform = "translate(-50%, -50%)";
54-
style.fontSize = "24px";
55-
style.fontWeight = "bold";
56-
style.color = "#000";
57-
style.opacity = 0;
58-
style.transition = "opacity 1s";
59-
document.body.appendChild(candleTextElement);
60-
setTimeout(function () {
61-
candleTextElement.style.opacity = 1;
50+
var candleTextElement = document.createElement("div");
51+
candleTextElement.id = "candleText";
52+
candleTextElement.textContent = text;
53+
var style = candleTextElement.style;
54+
style.position = "fixed";
55+
style.top = "50%";
56+
style.left = "50%";
57+
style.transform = "translate(-50%, -50%)";
58+
style.fontSize = "24px";
59+
style.fontWeight = "bold";
60+
style.color = "#000";
61+
style.opacity = 0;
62+
style.transition = "opacity 1s";
63+
document.body.appendChild(candleTextElement);
6264
setTimeout(function () {
63-
candleTextElement.style.opacity = 0;
64-
setTimeout(function () {
65-
document.body.removeChild(candleTextElement);
66-
}, 1000);
67-
}, duration);
68-
}, 100);
69-
}
70-
71-
// 打印仓库地址
72-
if (nolog !== "true") {
73-
console.log(customText+ " mourning哀悼日 Github仓库: https://github.com/byteforgecn/mourning");
65+
candleTextElement.style.opacity = 1;
66+
setTimeout(function () {
67+
candleTextElement.style.opacity = 0;
68+
setTimeout(function () {
69+
document.body.removeChild(candleTextElement);
70+
}, 1000);
71+
}, duration);
72+
}, 100);
7473
}
7574
})
7675
}()

0 commit comments

Comments
 (0)