Skip to content

Instantly share code, notes, and snippets.

@Omair-Waheed
Last active September 12, 2025 05:13
Show Gist options
  • Select an option

  • Save Omair-Waheed/105c397648d41ec0b07a90808ea96aa0 to your computer and use it in GitHub Desktop.

Select an option

Save Omair-Waheed/105c397648d41ec0b07a90808ea96aa0 to your computer and use it in GitHub Desktop.
Dark Mode for PDFs on Firefox
From: https://stackoverflow.com/a/74557483
Copying to keep track.
This is how to make the full page dark
Tutorial
Add a new Bookmark
Copy the following snippet:
javascript:(function(){document.body.parentElement.style = 'filter: grayscale(1) invert(1)';})()
Paste it into the bookmark's address
Save the bookmark
Whenever you're on a PDF, click on the bookmark
Explanation
This is a bookmark that executes Javascript (this is why it starts with javascript and not with http or https). In the Javascript code we get the root html tag (document.body.parentElement) and change it's style .style = 'filter: grayscale(1) invert(1) contrast(0.8)';.
That's literally everything :)
Edit:
Removed "contrast(0.8)" from code
To revert:
Add another bookmark that has the following URL:
javascript:(function(){document.body.parentElement.style = 'filter: grayscale(0) invert(0)';})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment