How often do you read Medium posts into the night? Whether you’ve just found an excellent technical blog, or happen to bump into something fascinating, the answer for me is pretty often.

Spending long hours staring at a computer screen isn’t healthy. Personally, I feel this gets even worse when the screen is mostly white. For example, Medium (web clients) default background color.

That is why I built an open source dark mode chrome extension for Medium.

Here is a screenshot of what it looks like.

Bạn đang xem:

First of all the code is open source, so feel free to

check out the complete repository here

.

Other than that, the chrome extension implementation is fairly straight forward. Let’s quickly walk through the different files in the repository.

Xem thêm: Apple TV+-Apple

Every chrome extension requires a

manifest.json

file. This is a general file that has config values for the extension.

Xem thêm: Chuyển Chữ Thường Thành Chữ Hoa Trong Excel 365, Excel 2019, Excel 2016, Excel 2013, Excel 2010, Excel 2007, Excel 2003 Và Google Sheets

let state = false;chrome.browserAction.onClicked.addListener(function(tab) {
if (!state) {
chrome.tabs.insertCSS(null, { file: "dark_mode.css" });
state = !state;
return;
}
chrome.tabs.insertCSS(null, { file: "light_mode.css" });
state = !state;
});

Background scripts run JavaScript code that controls the behavior of the extension.

Specifically here we want to toggle (inject) the different stylesheets when the user clicks on the extension icon.

Xem thêm: [Bật mí] Cách mở bàn phím ảo trên máy tính trong tích tắc

css files that overwrite default styling.

Feel free to get more selective with the classes and make a pull request ????????.

If you’d like to see a different color theme let me know in the comments 🙂 Otherwise, feel free to make a pull a request 🙂

If you like tech tutorials and startup related content feel free to follow me on

Medium

,

Github

and

Linkedin

.

Chuyên mục: Hỏi đáp

admin