<input type="submit" id="aa" value="灰色滤镜" >

<script>
     var ppp = true;
    var aa = document.getElementById("aa");
    aa.onclick = function () {
                        
                       const body = document.querySelector('body');
                      
                    
    
      if(ppp){
    
                       body.style.filter =  "grayscale(100%)";
                 ppp = false;
    
            }else{
                
                body.removeAttribute("style");
                ppp = true;
                
            }};

</script>

<input type="submit" id="aa" value="灰色滤镜">
<script>
  document.getElementById('aa').onclick = function () {
    'use strict';
    const body = document.querySelector('body');
    const filterValue = "grayscale(100%)";

    if (body.style.filter.includes(filterValue)) {
      body.style.filter = body.style.filter.replace(filterValue, "");
    } else {
      body.style.filter += filterValue;
    }
  };
</script>