@@ -19,6 +19,7 @@ togglbutton.render(
19
19
'.notion-peek-renderer:not(.toggl)' ,
20
20
{ observe : true } ,
21
21
function ( elem ) {
22
+ if ( ! elem ) return ;
22
23
function getDescription ( ) {
23
24
const descriptionElem = elem . querySelector ( '.notion-peek-renderer .notion-scroller h1[contenteditable]' ) ;
24
25
return descriptionElem ? descriptionElem . textContent . trim ( ) : '' ;
@@ -36,54 +37,63 @@ togglbutton.render(
36
37
if ( root ) {
37
38
root . parentElement . prepend ( wrapper ) ;
38
39
} else {
39
- elem . querySelector ( 'div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3)' ) . prepend ( wrapper )
40
+ const selector = elem . querySelector ( 'div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(3)' )
41
+ if ( ! selector ) return ;
42
+ selector . prepend ( wrapper )
40
43
}
41
44
}
42
45
) ;
43
46
44
- togglbutton . render (
45
- '.notion-topbar-action-buttons:not(.toggl)' ,
46
- { observe : true } ,
47
- function ( elem ) {
48
- if ( ! elem ) return ;
47
+ setTimeout ( ( ) => {
48
+ togglbutton . render (
49
+ '.notion-topbar-action-buttons' ,
50
+ { observe : true , debounceInterval : 1000 } ,
51
+ function ( elem ) {
52
+ if ( ! elem ) return ;
53
+ const elements = document . querySelectorAll ( '.notion-topbar-action-buttons .toggl-button-notion-wrapper' )
54
+ if ( elements . length > 0 ) {
55
+ elements . forEach ( element => element . remove ( ) )
56
+ }
49
57
50
- elem . style . position = 'relative' ;
58
+ elem . style . position = 'relative' ;
51
59
52
- function getDescription ( ) {
53
- const controls = document . querySelector ( '.notion-page-controls' ) ;
54
- const topBar = document . querySelector ( '.notion-topbar' ) ;
55
- let title = '' ;
60
+ function getDescription ( ) {
61
+ const controls = document . querySelector ( '.notion-page-controls' ) ;
62
+ const topBar = document . querySelector ( '.notion-topbar' ) ;
63
+ let title = '' ;
56
64
57
- if ( controls ) {
58
- if ( controls . nextElementSibling ) {
59
- title = controls . nextElementSibling ;
60
- } else {
61
- const parent = controls . parentElement ;
65
+ if ( controls ) {
66
+ if ( controls . nextElementSibling ) {
67
+ title = controls . nextElementSibling ;
68
+ } else {
69
+ const parent = controls . parentElement ;
62
70
63
- if ( ! parent ) return '' ;
71
+ if ( ! parent ) return '' ;
64
72
65
- title = parent ? parent . nextElementSibling : '' ;
66
- }
67
- } else if ( topBar ) {
68
- const breadcrumbs = topBar . querySelector ( 'div > .notranslate' )
69
- if ( breadcrumbs ) {
70
- title = breadcrumbs . childNodes [ breadcrumbs . childNodes . length - 1 ] . querySelector ( '.notranslate:last-child' )
73
+ title = parent ? parent . nextElementSibling : '' ;
74
+ }
75
+ } else if ( topBar ) {
76
+ const breadcrumbs = topBar . querySelector ( 'div > .notranslate' )
77
+ if ( breadcrumbs ) {
78
+ title = breadcrumbs . childNodes [ breadcrumbs . childNodes . length - 1 ] . querySelector ( '.notranslate:last-child' )
79
+ }
71
80
}
72
- }
73
81
74
- return title ? title . textContent . trim ( ) : '' ;
75
- }
82
+ return title ? title . textContent . trim ( ) : '' ;
83
+ }
76
84
77
- const link = togglbutton . createTimerLink ( {
78
- className : 'notion' ,
79
- description : getDescription ,
80
- } ) ;
85
+ const link = togglbutton . createTimerLink ( {
86
+ className : 'notion' ,
87
+ description : getDescription ,
88
+ } ) ;
81
89
82
- const wrapper = createWrapper ( link ) ;
90
+ const wrapper = createWrapper ( link ) ;
83
91
84
- elem . prepend ( wrapper ) ;
85
- }
86
- ) ;
92
+ elem . prepend ( wrapper ) ;
93
+ } ,
94
+ '.notion-topbar .shadow-cursor-breadcrumb *,title'
95
+ ) ;
96
+ } , 2000 )
87
97
88
98
/**
89
99
* @name Notion Calendar
@@ -94,6 +104,7 @@ togglbutton.render(
94
104
'div[data-context-panel-root]:not(.toggl)' ,
95
105
{ observe : true } ,
96
106
function ( elem ) {
107
+ if ( ! elem ) return ;
97
108
function getDescription ( ) {
98
109
const descriptionElem = elem . querySelector ( 'div[contenteditable="true"]' ) ;
99
110
return descriptionElem ? descriptionElem . textContent . trim ( ) : '' ;
0 commit comments