Skip to content

Instantly share code, notes, and snippets.

@Flashwalker
Last active April 2, 2023 06:47
Show Gist options
  • Save Flashwalker/5fa8aba5941167119c729617916b56fd to your computer and use it in GitHub Desktop.
Save Flashwalker/5fa8aba5941167119c729617916b56fd to your computer and use it in GitHub Desktop.
Set the dark theme on Yandex dzen
// ==UserScript==
// @name Yandex dzen dark theme
// @namespace http://tampermonkey.net/
// @version 0.0.3
// @description Set the dark theme on Yandex dzen
// @author You
// @match http*://dzen.ru/*
// @match http*://*.dzen.ru/*
// @match http*://*.*.dzen.ru/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=dzen.ru
// @updateURL https://gist.githubusercontent.com/Flashwalker/5fa8aba5941167119c729617916b56fd/raw/yandex-dzen-dark-theme.user.js
// @downloadURL https://gist.githubusercontent.com/Flashwalker/5fa8aba5941167119c729617916b56fd/raw/yandex-dzen-dark-theme.user.js
// @homepage https://gist.github.com/Flashwalker/5fa8aba5941167119c729617916b56fd
// @grant none
// @run-at document-end
// ==/UserScript==
(function(){
'use strict'
let styles = `
body {
background: var(--zenColorBackgroundOverflow, #080808);
}
form.mini-suggest,
[class*="_color_white"],
[class*="_color_white"],{
filter: invert(1) !important;
}
.article__content_theme_black .zen-comments,
.article__content_theme_black .comment-footer__reply-button,
.article__content_theme_black .comment-more-button,
.article__content_theme_black .comment-more-button:hover {
color: var(--zenColorTextAndIconsPrimary) !important;
}
.article__content_theme_black .comment-more-button__icon {
stroke: var(--zenColorTextAndIconsPrimary) !important;
}
.Theme_color_dark .ui-lib-header-container2._is-publishers-header {
background: var(--zenColorBackgroundOverflow) !important;
}
`
let styleSheet = document.createElement("style")
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
window.addEventListener('load', function () {
let elms, class_mut, class_mut2
function make_dark() {
elms = document.querySelectorAll('html, body')
for(let i of elms) {
i.classList.add('document_dark_yes')
}
elms=document.querySelectorAll('._theme_white')
for(let i of elms) {
i.classList.remove('_theme_white')
i.classList.add('_theme_black')
}
elms=document.querySelectorAll('.Theme_color_light')
for(let i of elms) {
i.classList.remove('Theme_color_light')
i.classList.add('Theme_color_dark')
}
elms=document.querySelectorAll('.Theme_root_light')
for(let i of elms) {
i.classList.remove('Theme_root_light')
i.classList.add('Theme_root_dark')
}
elms=document.querySelectorAll('.article_theme_white')
for(let i of elms) {
i.classList.remove('article_theme_white')
i.classList.remove('article-stats-view_theme_white')
i.classList.add('article_theme_black')
i.classList.add('article_transparent')
// i.classList.add('article-stats-view_theme_black')
}
elms=document.querySelectorAll('.article__content_theme_white')
for(let i of elms) {
i.classList.remove('article__content_theme_white')
i.classList.add('article__content_theme_black')
}
elms=document.querySelectorAll('.article-recommender_theme_white')
for(let i of elms) {
i.classList.remove('article-recommender_theme_white')
i.classList.add('article-recommender_theme_black')
}
elms=document.querySelectorAll('.article-stats-view_theme_white')
for(let i of elms) {
i.classList.remove('article-stats-view_theme_white')
i.classList.add('article-stats-view_theme_black')
}
elms=document.querySelectorAll('.article-comments_theme_white')
for(let i of elms) {
i.classList.remove('article-comments_theme_white')
i.classList.add('article-comments_theme_black')
}
}
function init() {
make_dark()
class_mut = document.querySelector('.feed')
// class_mut.addEventListener('DOMSubtreeModified', make_dark())
// class_mut.onChange = function(){ make_dark() }
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
let observer = new MutationObserver(make_dark)
observer.observe(class_mut, {
childList: true
});
// class_mut2 = document.querySelector('.zen-comments')
// observer.observe(class_mut2, {
// childList: true
// });
}
init()
let p = document.createElement('p')
setTimeout(() => {
class_mut.appendChild(p)
}, 555)
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment