Apply a grayscale filter

Updated at:
Copy as MD

This topic shows you how to apply a grayscale filter to your website.

  1. For the entire site: In the Designer, go to the header and footer area, add a code control, copy the following code, and modify the deadline. Click Save and then Publish. The website automatically returns to its original colors after the deadline passes.

    In the left navigation pane, click Advanced. On the Code Embedding panel, select the HTML/CSS/JS control and add it to the header and footer area at the bottom of the preview area.

    <script>
        const deadline = new Date("2022-12-01 23:59:59").getTime();
        const now = new Date().getTime();
        console.log(deadline, now);
        if (now < deadline) {
            const style = document.createElement("style");
            style.innerHTML = `
                  html {
                      -webkit-filter: grayscale(1);
                      filter: grayscale(1);
                  }
              `;
            document.head.appendChild(style);
        }
    </script>
  2. To make a single page grayscale: In the Designer, select the page that you want to turn grayscale, copy the code above, and modify the grayscale deadline in the code. Click Save and then click Publish for the changes to take effect. After the deadline, the page automatically reverts to its normal colors.