From 7acd9efbbfe9a93842c5e3aa9b1926cd2dce6114 Mon Sep 17 00:00:00 2001 From: frianasoa Date: Tue, 1 Oct 2024 04:54:20 +0900 Subject: [PATCH] Added basic dark mode compatibility for Zotero 7 --- content/notes/notes-dark.css | 66 +++++++++++++++++++++++++++ content/notes/notes.css | 2 +- content/notes/notes.js | 22 +++++++-- content/notes/zotero.js | 2 - content/settings/generative-ai.xhtml | 2 + content/settings/preferences-dark.css | 17 +++++++ content/settings/preferences.js | 19 ++++++++ content/settings/zntable.js | 2 +- install.rdf | 2 +- manifest.json | 2 +- zenote-update.json | 6 +-- zenote-update.rdf | 6 +-- 12 files changed, 133 insertions(+), 15 deletions(-) create mode 100644 content/notes/notes-dark.css create mode 100644 content/settings/preferences-dark.css diff --git a/content/notes/notes-dark.css b/content/notes/notes-dark.css new file mode 100644 index 0000000..7fafb50 --- /dev/null +++ b/content/notes/notes-dark.css @@ -0,0 +1,66 @@ +html { + color: white; + background: black; +} + +a { + color: white; +} + +#notes-table tr:first-child td { + background-color: black!important; +} + +.rm-item-exists td +{ + background-color: rgb(25, 25, 55); +} + +.rm-id { + color: white; +} + +#notes-table td:first-child { + background-color: black; +} + +#zn-sep-1 { + background-color: black; + height: 1.3em; +} + +.zn-menubar { + background-color: black!important; +} + +.zn-menubar li { + background-color: black; + border: solid 1px black; + color: white; +} + +.context-menu-separator +{ + border: solid 1px black; +} + +.zn-status-bar { + background-color: black; + color: white; +} + +.context-menu-two { + background-color: black; + border: solid 1px black; +} + +.zn-menuitem { + border: solid 1px black; + background-color: black; + color: white; +} + +.zn-menuitem:hover { + background-color: black; + border-bottom: solid 1px white; +} \ No newline at end of file diff --git a/content/notes/notes.css b/content/notes/notes.css index 368a687..74affa5 100644 --- a/content/notes/notes.css +++ b/content/notes/notes.css @@ -131,7 +131,7 @@ body { .context-menu-separator { - border: solid 1px #dfdfff!important; + border: solid 1px #dfdfff; } .zn-menuitem:hover { diff --git a/content/notes/notes.js b/content/notes/notes.js index 5f49391..2385dd3 100644 --- a/content/notes/notes.js +++ b/content/notes/notes.js @@ -365,15 +365,30 @@ Notes = { Notes.body.style.fontSize = this.fontsize+"em"; let pxsize = parseFloat(getComputedStyle(Notes.body).fontSize); Zotero.ZeNotes.Prefs.set("font-size", pxsize); - } + }, + loaddark() + { + var isdark = Zotero.Prefs.get('general.theme')=="dark" || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; + + if(isdark) + { + var filename = "chrome://ze-notes/content/notes/notes-dark.css"; + const link = document.createElement("link"); + link.rel = "stylesheet"; + link.type = "text/css"; + link.href = filename; + document.head.appendChild(link); + } + } } window.addEventListener("load", function(){ Notes.init(); Notes.loaddata(); Notes.initscroll(); -}) + Notes.loaddark(); +}); document.addEventListener("wheel", function(e){ if(e.ctrlKey){ @@ -401,4 +416,5 @@ document.addEventListener("keyup", function(e){ Notes.zoom(sign); } } -}) \ No newline at end of file +}); + diff --git a/content/notes/zotero.js b/content/notes/zotero.js index c1fb077..c26b6bd 100644 --- a/content/notes/zotero.js +++ b/content/notes/zotero.js @@ -17,5 +17,3 @@ else { var Zotero = window.parent.Zotero; } - -// Zotero.Utilities.Internal.openPreferences('zotero-prefpane-advanced'); diff --git a/content/settings/generative-ai.xhtml b/content/settings/generative-ai.xhtml index a13bc61..6f89583 100644 --- a/content/settings/generative-ai.xhtml +++ b/content/settings/generative-ai.xhtml @@ -15,6 +15,8 @@ Model diff --git a/content/settings/preferences-dark.css b/content/settings/preferences-dark.css new file mode 100644 index 0000000..9187986 --- /dev/null +++ b/content/settings/preferences-dark.css @@ -0,0 +1,17 @@ +html, body { + color: white; + background-color: #303030; +} + +.zn-type-table { + background-color: #303030; +} + +.zn-type-table thead{ + color: white; + background-color: #303030; +} + +.zn-type-table tr:hover{ + background-color: #333d54; +} \ No newline at end of file diff --git a/content/settings/preferences.js b/content/settings/preferences.js index d935e5c..9c05299 100644 --- a/content/settings/preferences.js +++ b/content/settings/preferences.js @@ -386,6 +386,7 @@ Zotero_Preferences.ZeNotes = { loadtagmanager(box) { + Zotero_Preferences.ZeNotes.loaddark(); var table = box.querySelector("#table-manage-tags-body"); var buttonlist = ["up", "down", "first", "last", "visible"]; box.parentNode.querySelector(".collection-name").innerHTML = this.collection; @@ -521,9 +522,27 @@ Zotero_Preferences.ZeNotes = { } }) return s; + }, + loaddark() + { + var isdark = Zotero.Prefs.get('general.theme')=="dark" || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches; + + if (isdark) { + var filename = "chrome://ze-notes/content/settings/preferences-dark.css"; + var pi = document.createProcessingInstruction( + 'xml-stylesheet', + `type="text/css" href="${filename}"` + ); + document.insertBefore(pi, document.documentElement); + } } } + +this.addEventListener("load", function(){ + // Zotero_Preferences.ZeNotes.loaddark(); +}); + /** Refresh after losing focus */ diff --git a/content/settings/zntable.js b/content/settings/zntable.js index 59bb648..876d254 100644 --- a/content/settings/zntable.js +++ b/content/settings/zntable.js @@ -454,4 +454,4 @@ Zotero_Preferences.ZNTable = { } return html; } -} \ No newline at end of file +} diff --git a/install.rdf b/install.rdf index d50b768..a8007ee 100644 --- a/install.rdf +++ b/install.rdf @@ -5,7 +5,7 @@ zenotes@alefa.net ZeNotes - 0.8.4 + 0.8.5 true https://raw.githubusercontent.com/frianasoa/zenotes/main/zenote-update.json https://github.com/frianasoa/zenotes diff --git a/manifest.json b/manifest.json index 2a4e78c..1171dc4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Ze Notes", - "version": "0.8.4", + "version": "0.8.5", "description": "Advanced notes manager", "homepage_url": "https://github.com/frianasoa/zenotes", "author": "Fanantenana Rianasoa Andriariniaina", diff --git a/zenote-update.json b/zenote-update.json index f070f40..04cd8d9 100644 --- a/zenote-update.json +++ b/zenote-update.json @@ -3,9 +3,9 @@ "zenotes@alefa.net": { "updates": [ { - "version": "0.8.4", - "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.4/zenotes-v0.8.4.xpi", - "update_hash": "sha256:3808e0cde9efaddab594802acc24b01e918d12137c7469cff734734459faf8fc", + "version": "0.8.5", + "update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.5/zenotes-v0.8.5.xpi", + "update_hash": "sha256:b4ddddfba03f1cdea9660ebe785a3824d164657aaa0bbe01376c892b14325f9b", "applications": { "gecko": { "strict_min_version": "60.0" diff --git a/zenote-update.rdf b/zenote-update.rdf index 4640ada..fe6a7ef 100644 --- a/zenote-update.rdf +++ b/zenote-update.rdf @@ -5,13 +5,13 @@ - 0.8.4 + 0.8.5 zotero@chnm.gmu.edu 5.0.0 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.4/zenotes-v0.8.4.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.5/zenotes-v0.8.5.xpi @@ -20,7 +20,7 @@ juris-m@juris-m.github.io 4.999 6.* - https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.4/zenotes-v0.8.4.xpi + https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.5/zenotes-v0.8.5.xpi