Skip to content

Commit

Permalink
Update to version 1.41
Browse files Browse the repository at this point in the history
- Fixed a bug where when user dismissed settings modal, settings not revert back
  • Loading branch information
maxsrli committed Jul 4, 2021
1 parent 2d0c216 commit 8b60de0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 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.40
// @version 1.41
// @match *://*.wikipedia.org/*
// @match *://*.mediawiki.org/*
// @match *://*.wikimedia.org/*
Expand Down Expand Up @@ -576,30 +576,34 @@ function updateColorPreferences() {
document.getElementById("contrastValue").value = GM_getValue("contrastValue");
}

function dismissSettingsModal() {
const settingsModal = document.getElementById("settingsModal");
settingsModal.style.display = "none";
updateSettingsModal();
}

function addButtonListeners() {
const closeButtons = document.getElementsByClassName("close");
for (let i = 0; i < closeButtons.length; i++) {
closeButtons[i].onclick = function () {
document.getElementById("settingsModal").style.display = "none";
dismissSettingsModal();
}
}
window.onclick = function (event) {
const settingsModal = document.getElementById("settingsModal")
if (event.target === settingsModal) {
settingsModal.style.display = "none";
if (event.target === document.getElementById("settingsModal")) {
dismissSettingsModal();
}
}
const saveButton = document.getElementById("saveButton");
saveButton.onclick = function () {
setSettings();
updateThemePreferences();
document.getElementById("settingsModal").style.display = "none";
dismissSettingsModal();
location.reload();
}
const restoreButton = document.getElementById("restoreButton");
restoreButton.onclick = function () {
initGMStorage(true);
document.getElementById("settingsModal").style.display = "none";
dismissSettingsModal();
location.reload();
}
}
Expand Down

0 comments on commit 8b60de0

Please sign in to comment.