From b79a40777dbf12f4728a1e4c7c47fe32194392f8 Mon Sep 17 00:00:00 2001
From: CloudHill <rh.cloudhill@gmail.com>
Date: Mon, 14 Dec 2020 20:57:26 +0700
Subject: [PATCH] topbar icons: more specific selectors + fixes compatibility
 with global links mod

---
 repo/topbar-icons/app.css |  2 +-
 repo/topbar-icons/mod.js  | 24 ++++++++++++++----------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/repo/topbar-icons/app.css b/repo/topbar-icons/app.css
index 3559111..23d74b6 100644
--- a/repo/topbar-icons/app.css
+++ b/repo/topbar-icons/app.css
@@ -10,7 +10,7 @@
   padding: 0 7px !important;
 }
 
-.notion-topbar-icon:not(:first-child) > *:not(div) {
+.notion-topbar-icon:not(.notion-topbar-share-menu) > *:not(div) {
   display: none !important;
 }
 
diff --git a/repo/topbar-icons/mod.js b/repo/topbar-icons/mod.js
index 86b2baf..410348a 100644
--- a/repo/topbar-icons/mod.js
+++ b/repo/topbar-icons/mod.js
@@ -37,7 +37,7 @@ module.exports = {
       value: true,
     }, 
   ],
-  version: '1.0.0',
+  version: '1.1.0',
   author: 'CloudHill',
   hacks: {
     'renderer/preload.js'(store, __exports) {
@@ -96,22 +96,26 @@ module.exports = {
           }
 
           async function setIcons(buttons) {
-            const buttonList = buttons.children;
+            const $shareButton = buttons.querySelector('.notion-topbar-share-menu');
+            
             if (store().share) {
-              buttonList[0].classList.add('notion-topbar-icon');
-              buttonList[0].innerHTML = await icons.share;
+              $shareButton.classList.add('notion-topbar-icon');
+              $shareButton.innerHTML = await icons.share;
             }
+            
             const elements = {
-              updates: buttonList[1],
-              favorite: buttonList[2],
+              updates: $shareButton.nextElementSibling,
+              favorite: $shareButton.nextElementSibling.nextElementSibling,
             };
             for (let btn of icons.selected) {
               elements[btn].classList.add('notion-topbar-icon')
               elements[btn].prepend(
-                createElement(
-                  `<div>${(await icons[btn].off).toString()}        
-                  ${(await icons[btn].on).toString()}</div>`        
-                )
+                createElement(`
+                  <div>
+                    ${(await icons[btn].off)}        
+                    ${(await icons[btn].on)}
+                  </div>
+                `)
               );
             }
           }