File tree 2 files changed +1338
-0
lines changed
2 files changed +1338
-0
lines changed Original file line number Diff line number Diff line change
1
+ function onPageLoad ( ) {
2
+ const header = document . querySelector ( '.notion-header' ) ;
3
+ const setActivePage = ( ) => {
4
+ const currentPage = document . querySelectorAll ( 'a[href="' + window . location . pathname + '"]' ) ;
5
+ currentPage . forEach ( function ( page ) {
6
+ if ( ! page . classList . contains ( 'super-navbar__logo' ) && ! page . parentNode . classList . contains ( 'notion-image' ) ) {
7
+ page . classList . add ( 'page-active' )
8
+ }
9
+ const pageIcon = page . querySelector ( '.notion-page__icon' )
10
+ if ( pageIcon ) {
11
+ pageIcon . setAttribute ( "style" , "opacity:1!important; filter:grayscale(0%)!important;" )
12
+ }
13
+ } ) ;
14
+ }
15
+ setActivePage ( )
16
+
17
+ const config = { subtree : true , characterData : true } ;
18
+
19
+ const callback = function ( mutationsList , observer ) {
20
+ for ( const mutation of mutationsList ) {
21
+ if ( mutation . type === 'characterData' ) {
22
+ setActivePage ( )
23
+ }
24
+ }
25
+ } ;
26
+
27
+ const observer = new MutationObserver ( callback ) ;
28
+ observer . observe ( header , config ) ;
29
+ }
30
+
31
+ document . addEventListener ( "DOMContentLoaded" , onPageLoad ) ;
You can’t perform that action at this time.
0 commit comments