1
- ! function ( ) {
1
+ ! function ( ) {
2
2
"use strict" ;
3
3
var scriptElement = document . currentScript ;
4
4
var days = scriptElement . getAttribute ( "days" ) . split ( ',' ) ;
5
5
var customText = scriptElement . getAttribute ( "text" ) ;
6
6
var duration = parseInt ( scriptElement . getAttribute ( "duration" ) ) ;
7
7
var nolog = scriptElement . getAttribute ( "nolog" ) ;
8
-
8
+
9
9
/* 哀悼日网站变灰 */
10
10
document . addEventListener ( "DOMContentLoaded" , function ( ) {
11
11
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
+ }
21
25
}
22
26
// 判断日期
23
27
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
+ }
43
47
}
44
48
// 创建蜡烛文字的函数
45
49
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 ) ;
62
64
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 ) ;
74
73
}
75
74
} )
76
75
} ( )
0 commit comments