@@ -62,7 +62,9 @@ window.addEventListener('DOMContentLoaded', async function () {
6262
6363 // Restore the recent search replace instance and history list from storage
6464 port . onMessage . addListener ( function ( msg : SearchReplaceStorageItems ) {
65+ console . log ( 'received msg' , msg )
6566 const history : SearchReplaceInstance [ ] = msg . history || [ ]
67+ const hideAd : boolean = msg . hintPreferences ?. ad || false
6668 let recentSearch : SearchReplaceInstance = msg . instance
6769 if ( history . length > 0 ) {
6870 recentSearch = recentSearch || history [ 0 ]
@@ -71,6 +73,13 @@ window.addEventListener('DOMContentLoaded', async function () {
7173 if ( recentSearch ) {
7274 restoreSearchReplaceInstance ( recentSearch )
7375 }
76+ if ( hideAd ) {
77+ const adElement = document . getElementById ( 'ad' )
78+ if ( adElement ) {
79+ document . body . removeChild ( adElement )
80+ }
81+ }
82+
7483 // Trigger a search term count if there is an existing search term
7584 contentScriptCall ( 'count' , recentSearch , history ) . catch ( ( e ) => {
7685 console . error ( e )
@@ -139,6 +148,18 @@ window.addEventListener('DOMContentLoaded', async function () {
139148 autoGrow ( searchTerm )
140149 autoGrow ( replaceTerm )
141150 } )
151+
152+ // Click handler for closing the ad banner
153+ const adCloseElement = document . getElementById ( 'ad-close' )
154+ if ( adCloseElement ) {
155+ adCloseElement . onclick = function ( ) {
156+ const searchReplaceInput = getInputValues ( false )
157+ const history = constructSearchReplaceHistory ( )
158+ const hintPreferences : HintPreferences = { [ 'ad' ] : true }
159+ sendToStorage ( searchReplaceInput , history , hintPreferences )
160+ }
161+ }
162+
142163 // Localize HTML elements
143164 localizeElements ( langData )
144165} )
0 commit comments