From 988e7cf1dc83e69e703ff9d69a4b2ebfae263f5f Mon Sep 17 00:00:00 2001 From: orenom Date: Mon, 13 Dec 2021 00:07:28 +0100 Subject: [PATCH] fix the stylesheets if the user has chosen a theme via preferences --- src/utils.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/utils.js b/src/utils.js index 7ac78f8..dc2d1c9 100644 --- a/src/utils.js +++ b/src/utils.js @@ -72,10 +72,20 @@ module.exports = function(redis) { * cookie specific modifications to it yet. Let's do it. */ - // add dark style theme file if needed - if(user_preferences.theme == 'dark') { - data = data.replace('', ``) + if(user_preferences.theme === 'white') { + // if the user has chosen the white theme from the preferences + data = data.replace('', ``) } + if(user_preferences.theme === 'dark') { + // if the user has chosen the dark theme from the preferences + data = data.replace('', ` + `) + } + if(user_preferences.theme !== 'dark' && user_preferences.theme !== 'white') { + // default, auto theme + data = data.replace('', ``) + } + return data } @@ -89,13 +99,6 @@ module.exports = function(redis) { data.html = parser.parse(data.html) - // insert wikiless styles - let head = data.html.querySelector('head') - if(head) { - let head_html = `` - head.insertAdjacentHTML('beforeend', head_html) - } - // replace default wikipedia top right nav bar links let nav = data.html.querySelector('nav#p-personal .vector-menu-content-list') if(nav) { @@ -490,7 +493,8 @@ module.exports = function(redis) {