css样式加载head里面:
<style type="text/css">
html{
filter: grayscale(100%);
-webkit-filter: grayscale(100%); /* webkit */
-moz-filter: grayscale(100%); /*firefox*/
-ms-filter: grayscale(100%); /*ie9*/
-o-filter: grayscale(100%); /*opera*/
filter: url("data:image/svg+xml;utf8,#grayscale");
filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
-webkit-filter: grayscale(1);
}
</style>
操作最简单的:
<html lang="zh-CN" xml:lang="zh-CN" style="filter: grayscale(100%);">
JS定时:
<script>
function isDateBetween(start, end) {
var startDate = new Date(start)
var endDate = new Date(end)
var current = new Date()
return current >= startDate && current < endDate
}
(function() {
var inGrayRange = isDateBetween('2022-05-11 00:00:00', '2022-05-12 00:00:00');
//var inGrayRange = true
var grayCss = document.getElementById('J-gary-bg');
var ieGuessULile = document.getElementsByClassName('J-ie-guess-u-like');
window.inGrayRange = inGrayRange;
if (!inGrayRange && grayCss) {
grayCss.remove();
}
if (inGrayRange && ieGuessULile && ieGuessULile.length) {
for (var i = 0; i< ieGuessULile.length; i++) {
ieGuessULile[i].style.display = "none";
}
}
})()
</script>
PS:以上几种方法,喜欢哪种就自己挖去吧!
评论