Last active
November 30, 2022 03:41
-
-
Save benok/301f7a9667a598202f10111af054ae77 to your computer and use it in GitHub Desktop.
GitHub apply dark theme on private repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name GitHub apply dark theme on private repo | |
// @namespace https://github.com/benok/ | |
// @description Apply dark theme to your private repository pages on Github | |
// @match https://github.com/* | |
// @run-at document-idle | |
// @version 2022.11.30.0 | |
// @homepage https://gist.github.com/benok/301f7a9667a598202f10111af054ae77 | |
// @downloadURL https://gist.github.com/benok/301f7a9667a598202f10111af054ae77/raw/github-apply-dark-theme-on-private-repos.user.js | |
// @updateURL https://gist.github.com/benok/301f7a9667a598202f10111af054ae77/raw/github-apply-dark-theme-on-private-repos.user.js | |
// @author benok | |
// @grant none | |
// @license MIT | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
if (document.querySelector('span.Label.Label--secondary').textContent == "Private") { | |
console.log('private repo. set data-color-mode to dark'); | |
document.querySelector('html').setAttribute('data-color-mode', 'dark'); | |
} else { | |
console.log('public repo. set data-color-mode to light'); | |
document.querySelector('html').setAttribute('data-color-mode', 'light'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Having trouble now.
Setting html's data-color-mode doesn't update the actual page theme. :-(
(Setting the default theme to dark, it works partially, but unstable. May be needed to change apply timing.)