Skip to content

Instantly share code, notes, and snippets.

@YCF
Last active February 8, 2020 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save YCF/437cb5c16fe3e83b952b0d04a2573d79 to your computer and use it in GitHub Desktop.
Save YCF/437cb5c16fe3e83b952b0d04a2573d79 to your computer and use it in GitHub Desktop.
<style>
body.grayDay {
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
-webkit-filter: grayscale(100%); }
</style>
<script>
window.onload = function() {
var grayDay = [108, 207, 219, 404, 420, 512, 815, 909, 918, 1213];
var today = new Date();
var d = (today.getMonth() + 1) * 100 + today.getDate();
grayDay.forEach(function(i) {
if (i == d) {
var classVal = document.getElementsByTagName('body')[0].getAttribute("class");
classVal = classVal.concat(" grayDay");
document.getElementsByTagName('body')[0].setAttribute("class", classVal);
}
});
}
</script>
@sincerefly
Copy link

/*
 *
 * 纪念那些平凡而伟大的小人物,死亡不是生命的终点,遗忘才是。
 *
 */

Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

let datelist = {
    "02-08": "2020-02-06 21:30分,李文亮医生的心脏停止了跳动,疫情的“吹哨人”,谢谢你曾尝试拯救地球。"
};

(() => {
    let nowday = (new Date()).format("MM-dd");
    if (nowday in datelist) {
        // 根据实际情况修改样式
        document.getElementById("idx-msg").innerHTML = datelist[nowday];
        document.getElementById("idx-emoji").innerHTML = "";
        document.getElementById("idx-img").src = "";
        document.getElementById("idx-img").style.filter = 'grayscale(100%)';
    }
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment