butterfly加入国家公祭日自动变灰
前言
前言
今天——2022年12月13日,是第九个`国家公祭日`。
在此,先向三十万罹胞致哀🙏。铭记历史 勿忘国耻!!!
在看Akilarの糖果屋的时候发现Akilarの糖果屋变灰了。
找了找,发现了Akilar记录的教程👍。
变灰的纪念日有:
- 2020年4月4日 新冠肺炎哀悼日,清明节
- 2010年4月14日,青海玉树地震
- 2008年5月12日,四川汶川地震
- 1937年7月7日,七七事变(卢沟桥事变)
- 2010年8月7日,甘肃舟曲特大泥石流
- 8月14日,世界慰安妇纪念日
- 1976年9月9日,毛主席逝世
- 1931年9月18日,九一八事变
- 9月30日,烈士纪念日
- 1950年10月25日,抗美援朝纪念日
- 1937年12月13日,南京大屠杀
教程
站点公祭日自动变灰判定是通过js监测当前日期是否为公祭日,从而调整html的filter属性使站点变灰。
在
[Blogroot]\themes\butterfly\source\js\
目录(没有就创建)下新建grayscale.js
js1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36if(PublicSacrificeDay()){
document.getElementsByTagName("html")[0].setAttribute("style","filter:gray !important;filter:grayscale(100%);-webkit-filter:grayscale(100%);-moz-filter:grayscale(100%);-ms-filter:grayscale(100%);-o-filter:grayscale(100%);");
}
function PublicSacrificeDay(){
var PSFarr=new Array("0403","0404","0405","0406","0414","0512","0707","0807","0814","0909","0918","0930","1025","1213");
//2020年4月4日 新冠肺炎哀悼日,清明节
//2010年4月14日,青海玉树地震
//2008年5月12日,四川汶川地震
//1937年7月7日,七七事变 又称卢沟桥事变
//2010年8月7日,甘肃舟曲特大泥石流
//8月14日,世界慰安妇纪念日
//1976年9月9日,毛主席逝世
//1931年9月18日,九一八事变
//烈士纪念日为每年9月30日
//1950年10月25日,抗美援朝纪念日
//1937年12月13日,南京大屠杀
var currentdate = new Date();
var str = "";
var mm = currentdate.getMonth()+1;
if(currentdate.getMonth()>9){
str += mm;
}else{
str += "0" + mm;
}
if(currentdate.getDate()>9){
str += currentdate.getDate();
}else{
str += "0" + currentdate.getDate();
}
if(PSFarr.indexOf(str)>-1){
return 1;
}else{
return 0;
}
}Array("0403","0404","0405","0406","0414","0512","0707","0807","0814","0909","0918","0930","1025","1213")
即为需要变灰的日期的列表在
[Blogroot]\_config.butterfly.yml
的inject
配置项添加引入,此处因为这是个独立的js,而且体量极小,所以可以添加async
异步加载标签:yml1
2
3inject:
bottom:
- <script async src="/js/grayscale.js"></script>可以先在js的列表中加入今天,重启项目查看是否变灰:
bash1
hexo cl; hexo s
变灰成功就可以在列表中删掉你加入的啦!
评论