Skip to content

Instantly share code, notes, and snippets.

@Odepax
Last active May 13, 2021 21:47
Show Gist options
  • Select an option

  • Save Odepax/d599626fac4941a85aebfa37b137a337 to your computer and use it in GitHub Desktop.

Select an option

Save Odepax/d599626fac4941a85aebfa37b137a337 to your computer and use it in GitHub Desktop.

Revisions

  1. Odepax revised this gist May 13, 2021. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions go-dark.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ((invertImages, invertCode, applyBlackBackground) => {
    document.body.style.filter = "invert()"
    if (applyBlackBackground) document.body.style.background = "black"
    if (invertCode) Array.from(document.querySelectorAll("pre")).map(pre => pre.style.filter = "invert()")
    if (invertImages) Array.from(document.querySelectorAll("img")).map(img => img.style.filter = "invert()")
    })(/* Invert Image | Invert Code | Dark BG */ 1, 1, 1)
    document.body.style.filter = "invert()"
    document.body.style.background = applyBlackBackground ? "black" : "white"
    Array.from(document.querySelectorAll("pre")).map(pre => pre.style.filter = invertCode ? "invert()" : null)
    Array.from(document.querySelectorAll("img")).map(img => img.style.filter = invertImages ? "invert()" : null)
    })(/* Invert Image | Invert Code | Dark BG */ 1, 0, 1)
  2. Odepax created this gist Mar 7, 2020.
    6 changes: 6 additions & 0 deletions go-dark.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    ((invertImages, invertCode, applyBlackBackground) => {
    document.body.style.filter = "invert()"
    if (applyBlackBackground) document.body.style.background = "black"
    if (invertCode) Array.from(document.querySelectorAll("pre")).map(pre => pre.style.filter = "invert()")
    if (invertImages) Array.from(document.querySelectorAll("img")).map(img => img.style.filter = "invert()")
    })(/* Invert Image | Invert Code | Dark BG */ 1, 1, 1)