Skip to content

Commit

Permalink
Updated to version 1.01
Browse files Browse the repository at this point in the history
Added Chinese and Japanese locale for toggleTheme button.
  • Loading branch information
maxsrli committed Apr 9, 2020
1 parent b4f4f12 commit dcb337e
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions Wikipedia Dark Theme.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Wikipedia Dark Theme
// @author Shangru Li
// @version 1.00
// @version 1.01
// @match *://*.wikipedia.org/*
// @namespace https://github.com/MaxsLi/WikipediaDarkTheme
// @icon https://www.wikipedia.org/favicon.ico
Expand Down Expand Up @@ -106,14 +106,41 @@

function updateToggleScriptElement() {
const toggleScriptElement = document.getElementById("toggleScriptElement");
if (GM_getValue("scriptEnabled")) {
toggleScriptElement.text = "Disable Dark Theme";
toggleScriptElement.title = "Click to disable Wikipedia Dark Theme."
toggleScriptElement.style.color = "white";
} else {
toggleScriptElement.text = "Enable Dark Theme";
toggleScriptElement.title = "Click to enable Wikipedia Dark Theme."
toggleScriptElement.style.color = "black";
const language = window.location.href.substring(0, window.location.href.indexOf(".wikipedia")).slice(-2);
switch (language) {
case "zh":
if (GM_getValue("scriptEnabled")) {
toggleScriptElement.text = "关闭黑色主题";
toggleScriptElement.title = "单击来关闭维基百科黑色主题。"
toggleScriptElement.style.color = "white";
} else {
toggleScriptElement.text = "打开黑色主题";
toggleScriptElement.title = "单击来打开维基百科黑色主题。"
toggleScriptElement.style.color = "black";
}
break;
case "ja":
if (GM_getValue("scriptEnabled")) {
toggleScriptElement.text = "ダークテーマを解除する";
toggleScriptElement.title = "ここをクリックしてダークテーマから切り替わる。"
toggleScriptElement.style.color = "white";
} else {
toggleScriptElement.text = "ダークテーマを設定する";
toggleScriptElement.title = "ここをクリックしてダークテーマに切り替わる。"
toggleScriptElement.style.color = "black";
}
break;
default:
if (GM_getValue("scriptEnabled")) {
toggleScriptElement.text = "Disable Dark Theme";
toggleScriptElement.title = "Click to disable Wikipedia Dark Theme."
toggleScriptElement.style.color = "white";
} else {
toggleScriptElement.text = "Enable Dark Theme";
toggleScriptElement.title = "Click to enable Wikipedia Dark Theme."
toggleScriptElement.style.color = "black";
}
break;
}
}

Expand Down Expand Up @@ -327,4 +354,4 @@
sheet.insertRule('.vectorTabs li a span { background: ' + default_backgroundColor + ' !important; }', sheet.cssRules.length);
sheet.insertRule('.vectorTabs li a span { color: ' + default_foregroundColor + ' !important; }', sheet.cssRules.length);
}
})();
})();

0 comments on commit dcb337e

Please sign in to comment.