@@ -11,6 +11,11 @@ document.addEventListener('DOMContentLoaded', (event) => {
1111 let showExamplesIcon = document . getElementById ( 'show-examples-icon' ) ;
1212 showExamplesIcon ! . textContent = result . showExamples ? '✅' : '❌' ;
1313 } ) ;
14+
15+ chrome . storage . local . get ( [ 'showDifficulty' ] , ( result ) => {
16+ let showDifficultyIcon = document . getElementById ( 'show-difficulty-icon' ) ;
17+ showDifficultyIcon ! . textContent = result . showDifficulty ? '✅' : '❌' ;
18+ } ) ;
1419} ) ;
1520
1621// Get font fize and check if it is already set in local storage
@@ -54,6 +59,19 @@ document.getElementById('show-examples-btn')!.addEventListener('click', function
5459 } ) ;
5560} ) ;
5661
62+ document . getElementById ( 'show-difficulty-btn' ) ! . addEventListener ( 'click' , function ( ) {
63+ chrome . storage . local . get ( [ 'showDifficulty' ] , ( result ) => {
64+ const showDifficulty = ! result . showDifficulty ;
65+ chrome . storage . local . set ( { showDifficulty : showDifficulty } , ( ) => {
66+ document . getElementById ( 'show-difficulty-icon' ) ! . textContent = showDifficulty ? '✅' : '❌' ;
67+ } )
68+ // Manually trigger the update description after toggling
69+ chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
70+ chrome . tabs . sendMessage ( tabs [ 0 ] . id ! , { action : 'updateDescription' , title : tabs [ 0 ] . title || 'title' } ) ;
71+ } ) ;
72+ } ) ;
73+ } ) ;
74+
5775function sendMessageToActiveTab ( message : object ) : void {
5876 chrome . tabs . query ( { active : true , currentWindow : true } , ( tabs ) => {
5977 chrome . tabs . sendMessage ( tabs [ 0 ] . id ! , message ) ;
0 commit comments