GithubHelp home page GithubHelp logo

toggle-darkmode-js's Introduction

Toggle DarkMode JS

paypal

Easily toggle dark mode and auto detect if user device prefers dark mode. Auto detects the brightness of each color, and decides wether or not it should be inverted. Auto detects DOM updates and converts new elements to dark mode as needed. Can also convert already dark sites to light mode. Avoids changing colors with a center brightness. Reverses filters on images, iframes, videos, embeds, ect.

Installation

<!-- Depends On jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- or alternatively jqAlt (by AspieSoft) - v0.0.16 (alpha) or later -->
<script src="https://cdn.jsdelivr.net/gh/AspieSoft/[email protected]/jqalt/index.js" type="module"></script>

<script src="https://cdn.jsdelivr.net/gh/AspieSoft/[email protected]/script.min.js"></script>

Usage

// this function runs automatically, so usage is optional

DarkMode.toggle(); // toggles dark mode on or off
DarkMode.toggle('dark'); // toggles darkmode on
DarkMode.toggle('light'); // toggles darkmode off

DarkMode.ignore(['script', 'style', 'br']); // add to the list of element tags to ignore (for hidden elements)
DarkMode.invert(['img', 'iframe', 'embed']); // add to the list of element tags to invert (to reverse and undo filters)
<input type="button" value="Toggle Dark Mode" onclick="DarkMode.toggle()">

toggle-darkmode-js's People

Contributors

aspiesoft avatar

Stargazers

 avatar Thomas Coats avatar Pedro (結太) avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.