diff --git a/mods/core/client.js b/mods/core/client.js
index 0ddafe2..f31ab8c 100644
--- a/mods/core/client.js
+++ b/mods/core/client.js
@@ -217,7 +217,7 @@ module.exports = (store, __exports) => {
electron.ipcRenderer.on('enhancer:get-menu-theme', setThemeVars);
if (tabsEnabled) {
- let tab_title = '';
+ let tab_title = { img: '', emoji: '', text: '' };
if (process.platform === 'darwin')
document
.querySelector('.notion-sidebar [style*="37px"]:empty')
@@ -227,30 +227,27 @@ module.exports = (store, __exports) => {
);
__electronApi.setWindowTitle = (title) => {
const $container =
- document.querySelector(
- '.notion-peek-renderer [style="padding-left: calc(126px + env(safe-area-inset-left)); padding-right: calc(126px + env(safe-area-inset-right)); max-width: 100%; width: 100%;"]'
- ) ||
- document.querySelector(
- '.notion-frame [style="padding-left: calc(96px + env(safe-area-inset-left)); padding-right: calc(96px + env(safe-area-inset-right)); max-width: 100%; margin-bottom: 8px; width: 100%;"]'
- ) ||
document.querySelector('.notion-peak-renderer') ||
document.querySelector('.notion-frame'),
icon = $container.querySelector(
- '.notion-record-icon [aria-label]:not([src^="data:"])'
+ '[style*="env(safe-area-inset-left)"] > .notion-record-icon img:not([src^="data:"])'
),
- text = $container.querySelector('[placeholder="Untitled"]');
- title =
- (icon
- ? icon.getAttribute('src')
- ? `
`
- : `${icon.getAttribute('aria-label')} `
- : '') +
- (text
- ? text.innerText || 'Untitled'
- : [
- setTimeout(() => __electronApi.setWindowTitle(title), 250),
- title,
- ][1]);
+ img =
+ icon && icon.getAttribute('src')
+ ? `
`
+ : '',
+ emoji = icon ? icon.getAttribute('aria-label') : '';
+ let text = $container.querySelector('[placeholder="Untitled"]');
+ text = text
+ ? text.innerText || 'Untitled'
+ : [
+ setTimeout(() => __electronApi.setWindowTitle(title), 250),
+ title,
+ ][1];
TITLE_OBSERVER.disconnect();
TITLE_OBSERVER.observe($container, {
childList: true,
@@ -258,9 +255,17 @@ module.exports = (store, __exports) => {
characterData: true,
attributes: true,
});
- if (tab_title !== title) {
- tab_title = title;
- electron.ipcRenderer.sendToHost('enhancer:set-tab-title', title);
+ if (
+ tab_title.img !== img ||
+ tab_title.emoji !== emoji ||
+ tab_title.text !== text
+ ) {
+ tab_title = {
+ img,
+ emoji,
+ text,
+ };
+ electron.ipcRenderer.sendToHost('enhancer:set-tab-title', tab_title);
}
};
__electronApi.openInNewWindow = (urlPath) => {
diff --git a/mods/core/css/tabs.css b/mods/core/css/tabs.css
index cbde34a..be0633e 100644
--- a/mods/core/css/tabs.css
+++ b/mods/core/css/tabs.css
@@ -131,7 +131,10 @@ body,
opacity: 0.8;
}
#tabs .tab img {
+ object-fit: cover;
+ height: 1em;
width: 1em;
+ border-radius: 3px;
margin: 0 0.5em -3px 0.1em;
}
#tabs .tab:first-child {
diff --git a/mods/core/render.js b/mods/core/render.js
index 12252a1..222f1b3 100644
--- a/mods/core/render.js
+++ b/mods/core/render.js
@@ -383,13 +383,13 @@ module.exports = (store, __exports) => {
if (selected) {
this.views.active = +id;
this.views.loaded[id].focus();
- const electronWindow = electron.remote.getCurrentWindow();
- if (
- electronWindow &&
- electronWindow.getTitle() !== this.state.tabs.get(+id).title
- ) {
- electronWindow.setTitle(this.state.tabs.get(+id).title);
- }
+ const electronWindow = electron.remote.getCurrentWindow(),
+ title =
+ (this.state.tabs.get(+id).emoji
+ ? `${this.state.tabs.get(+id).emoji} `
+ : '') + this.state.tabs.get(+id).text;
+ if (electronWindow && electronWindow.getTitle() !== title)
+ electronWindow.setTitle(title);
}
}
}
@@ -427,6 +427,7 @@ module.exports = (store, __exports) => {
document.body.style.setProperty(style[0], style[1]);
break;
case 'enhancer:set-tab-title':
+ console.log(event.args[0]);
if (this.state.tabs.get(+event.target.id)) {
this.setState({
tabs: new Map(
@@ -436,12 +437,15 @@ module.exports = (store, __exports) => {
})
),
});
- const electronWindow = electron.remote.getCurrentWindow();
+ const electronWindow = electron.remote.getCurrentWindow(),
+ title =
+ (event.args[0].emoji ? `${event.args[0].emoji} ` : '') +
+ event.args[0].text;
if (
event.target.id == this.views.current.id &&
- electronWindow.getTitle() !== event.args[0]
+ electronWindow.getTitle() !== title
)
- electronWindow.setTitle(event.args[0]);
+ electronWindow.setTitle(title);
}
break;
case 'enhancer:select-tab':
@@ -746,7 +750,7 @@ module.exports = (store, __exports) => {
},
React.createElement('span', {
dangerouslySetInnerHTML: {
- __html: title,
+ __html: (title.img || '') + title.text,
},
}),
React.createElement(