grey.js 646 B

1234567891011121314151617181920212223242526
  1. var global_grey = {
  2. '-webkit-filter':'grayscale(1)',
  3. '-moz-filter':'grayscale(1)',
  4. '-ms-filter':'grayscale(1)',
  5. '-o-filter':'grayscale(1)',
  6. 'filter':'grayscale(1)',
  7. };
  8. function autoGreyByTime(){
  9. let now = new Date();
  10. let now_hours = now.getHours();
  11. // console.log(now_hours,typeof now_hours);
  12. if(now_hours >= 23 || now_hours < 8){
  13. $('html').css(global_grey);
  14. }
  15. }
  16. autoGreyByTime();
  17. function darkModeHandler() {
  18. const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
  19. if (mediaQuery.matches) {
  20. let color = '#1b1b1b';
  21. $('body').css({"background": color });
  22. }
  23. }
  24. darkModeHandler();