mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-10 15:39:01 +00:00
31 lines
1013 B
JavaScript
31 lines
1013 B
JavaScript
/**
|
|
* notion-enhancer: titlebar
|
|
* (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
|
* (https://notion-enhancer.github.io/) under the MIT license
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
import { createWindowButtons } from "./buttons.mjs";
|
|
|
|
export default async (api, db) => {
|
|
const titlebarStyle = await db.get("titlebarStyle");
|
|
if (titlebarStyle === "Disabled") return;
|
|
|
|
const { onMessage, addMutationListener } = api,
|
|
$buttons = await createWindowButtons(),
|
|
topbarMore = ".notion-topbar-more-button",
|
|
addToTopbar = () => {
|
|
if (document.contains($buttons)) return;
|
|
document.querySelector(topbarMore)?.after($buttons)
|
|
},
|
|
showIfNoTabBar = async () => {
|
|
const { isShowingTabBar } = await __electronApi.electronAppFeatures.get();
|
|
$buttons.style.display = isShowingTabBar ? "none" : "";
|
|
};
|
|
__electronApi?.electronAppFeatures.addListener(showIfNoTabBar);
|
|
showIfNoTabBar();
|
|
addMutationListener(topbarMore, addToTopbar);
|
|
addToTopbar(topbarMore);
|
|
};
|