@@ -15,7 +15,6 @@ const bulkMode = document.getElementById('bulkMode');
1515
1616const nicheInput = document . getElementById ( 'niche' ) ;
1717const locationInput = document . getElementById ( 'location' ) ;
18- const refinementInput = document . getElementById ( 'refinement' ) ;
1918
2019const bulkNicheInput = document . getElementById ( 'bulkNiche' ) ;
2120const bulkQueriesInput = document . getElementById ( 'bulkQueries' ) ;
@@ -26,8 +25,10 @@ const queryCount = document.getElementById('queryCount');
2625
2726const speedSelect = document . getElementById ( 'speed' ) ;
2827const exportFormatSelect = document . getElementById ( 'exportFormat' ) ;
29- const extractWebsitesCheckbox = document . getElementById ( 'extractWebsites' ) ;
30- const extractWebsitesBulkCheckbox = document . getElementById ( 'extractWebsitesBulk' ) ;
28+ const searchPrepositionSingle = document . getElementById ( 'searchPrepositionSingle' ) ;
29+ const customPrepositionSingle = document . getElementById ( 'customPrepositionSingle' ) ;
30+ const searchPrepositionBulk = document . getElementById ( 'searchPrepositionBulk' ) ;
31+ const customPrepositionBulk = document . getElementById ( 'customPrepositionBulk' ) ;
3132const extractEmailsCheckbox = document . getElementById ( 'extractEmails' ) ;
3233const extractEmailsBulkCheckbox = document . getElementById ( 'extractEmailsBulk' ) ;
3334const startBtn = document . getElementById ( 'startBtn' ) ;
@@ -145,9 +146,33 @@ document.getElementById('performanceMode').addEventListener('change', (e) => {
145146 // Remove the performance-mode class since we're using a simpler design
146147} ) ;
147148
148- document . getElementById ( 'searchPreposition' ) . addEventListener ( 'change' , ( e ) => {
149- const preposition = e . target . value ;
150- localStorage . setItem ( 'searchPreposition' , preposition ) ;
149+ // Preposition dropdown handlers
150+ searchPrepositionSingle . addEventListener ( 'change' , ( e ) => {
151+ const value = e . target . value ;
152+ if ( value === 'custom' ) {
153+ customPrepositionSingle . style . display = 'block' ;
154+ } else {
155+ customPrepositionSingle . style . display = 'none' ;
156+ }
157+ localStorage . setItem ( 'searchPrepositionSingle' , value ) ;
158+ } ) ;
159+
160+ searchPrepositionBulk . addEventListener ( 'change' , ( e ) => {
161+ const value = e . target . value ;
162+ if ( value === 'custom' ) {
163+ customPrepositionBulk . style . display = 'block' ;
164+ } else {
165+ customPrepositionBulk . style . display = 'none' ;
166+ }
167+ localStorage . setItem ( 'searchPrepositionBulk' , value ) ;
168+ } ) ;
169+
170+ customPrepositionSingle . addEventListener ( 'input' , ( e ) => {
171+ localStorage . setItem ( 'customPrepositionSingle' , e . target . value ) ;
172+ } ) ;
173+
174+ customPrepositionBulk . addEventListener ( 'input' , ( e ) => {
175+ localStorage . setItem ( 'customPrepositionBulk' , e . target . value ) ;
151176} ) ;
152177
153178headlessModeCheckbox . addEventListener ( 'change' , ( e ) => {
@@ -503,20 +528,18 @@ async function startScraping() {
503528async function startSingleScraping ( ) {
504529 const niche = nicheInput . value . trim ( ) ;
505530 const location = locationInput . value . trim ( ) ;
506- const refinement = refinementInput . value . trim ( ) ;
507531
508532 if ( ! niche || ! location ) {
509533 alert ( 'Please fill in both Niche and Location fields' ) ;
510534 return ;
511535 }
512536
513- let searchLocation = location ;
514- if ( refinement ) {
515- searchLocation = `${ location } ${ refinement } ` ;
537+ // Get preposition from dropdown
538+ let preposition = searchPrepositionSingle . value ;
539+ if ( preposition === 'custom' ) {
540+ preposition = customPrepositionSingle . value . trim ( ) || 'in' ;
516541 }
517-
518- const preposition = localStorage . getItem ( 'searchPreposition' ) || 'in' ;
519- const query = `${ niche } ${ preposition } ${ searchLocation } ` ;
542+ const query = `${ niche } ${ preposition } ${ location } ` ;
520543
521544 if ( isAlreadyScraped ( query ) ) {
522545 const proceed = confirm (
@@ -543,9 +566,8 @@ async function startSingleScraping() {
543566
544567 const options = {
545568 niche,
546- location : searchLocation ,
569+ location,
547570 speed : speedSelect . value ,
548- extractWebsites : extractWebsitesCheckbox . checked ,
549571 extractEmails : extractEmailsCheckbox . checked ,
550572 headless : headlessModeCheckbox . checked
551573 } ;
@@ -696,7 +718,12 @@ async function startBulkScraping() {
696718 }
697719
698720 const location = bulkQueries [ i ] ;
699- const query = `${ niche } in ${ location } ` ;
721+ // Get preposition from dropdown
722+ let preposition = searchPrepositionBulk . value ;
723+ if ( preposition === 'custom' ) {
724+ preposition = customPrepositionBulk . value . trim ( ) || 'in' ;
725+ }
726+ const query = `${ niche } ${ preposition } ${ location } ` ;
700727
701728 currentQuery . textContent = i + 1 ;
702729 currentSearchQuery . textContent = query ;
@@ -708,7 +735,6 @@ async function startBulkScraping() {
708735 niche,
709736 location,
710737 speed : speedSelect . value ,
711- extractWebsites : extractWebsitesBulkCheckbox . checked ,
712738 extractEmails : extractEmailsBulkCheckbox . checked ,
713739 headless : headlessModeCheckbox . checked
714740 } ;
@@ -1127,39 +1153,54 @@ async function clearHistory() {
11271153 }
11281154}
11291155
1130- function initializeSettings ( ) {
1131- // Theme
1132- const theme = localStorage . getItem ( 'theme' ) || 'dark' ;
1133- document . getElementById ( 'themeSelect' ) . value = theme ;
1134- document . documentElement . setAttribute ( 'data-theme' , theme ) ;
1156+ async function initializeSettings ( ) {
1157+ // Load history
1158+ await loadHistory ( ) ;
1159+
1160+ // Initialize theme
1161+ const savedTheme = localStorage . getItem ( 'theme' ) || 'dark' ;
1162+ document . getElementById ( 'themeSelect' ) . value = savedTheme ;
1163+ document . documentElement . setAttribute ( 'data-theme' , savedTheme ) ;
11351164
1165+ // Initialize performance mode
11361166 const performanceMode = localStorage . getItem ( 'performanceMode' ) === 'true' ;
11371167 document . getElementById ( 'performanceMode' ) . checked = performanceMode ;
1138- // Remove the performance-mode class since we're using a simpler design
11391168
1140- // Search Preposition
1141- const preposition = localStorage . getItem ( 'searchPreposition' ) || 'in' ;
1142- document . getElementById ( 'searchPreposition' ) . value = preposition ;
1169+ // Initialize preposition dropdowns
1170+ const savedPrepositionSingle = localStorage . getItem ( 'searchPrepositionSingle' ) || 'in' ;
1171+ searchPrepositionSingle . value = savedPrepositionSingle ;
1172+ if ( savedPrepositionSingle === 'custom' ) {
1173+ customPrepositionSingle . style . display = 'block' ;
1174+ customPrepositionSingle . value = localStorage . getItem ( 'customPrepositionSingle' ) || '' ;
1175+ }
1176+
1177+ const savedPrepositionBulk = localStorage . getItem ( 'searchPrepositionBulk' ) || 'in' ;
1178+ searchPrepositionBulk . value = savedPrepositionBulk ;
1179+ if ( savedPrepositionBulk === 'custom' ) {
1180+ customPrepositionBulk . style . display = 'block' ;
1181+ customPrepositionBulk . value = localStorage . getItem ( 'customPrepositionBulk' ) || '' ;
1182+ }
11431183
1144- // Headless Mode
1184+ // Initialize headless mode
11451185 const headlessMode = localStorage . getItem ( 'headlessMode' ) !== 'false' ;
11461186 headlessModeCheckbox . checked = headlessMode ;
11471187
1148- // Default Export Format
1149- const defaultExportFormat = localStorage . getItem ( 'defaultExportFormat' ) || 'csv' ;
1150- defaultExportFormatSelect . value = defaultExportFormat ;
1188+ // Initialize export format
1189+ const exportFormat = localStorage . getItem ( 'defaultExportFormat' ) || 'csv' ;
1190+ defaultExportFormatSelect . value = exportFormat ;
1191+ exportFormatSelect . value = exportFormat ;
11511192
1152- // Auto -save Results
1153- const autoSaveResults = localStorage . getItem ( 'autoSaveResults' ) === 'true' ;
1154- autoSaveResultsCheckbox . checked = autoSaveResults ;
1193+ // Initialize auto -save
1194+ const autoSave = localStorage . getItem ( 'autoSaveResults' ) === 'true' ;
1195+ autoSaveResultsCheckbox . checked = autoSave ;
11551196
1156- // Save History Data
1197+ // Initialize save history data
11571198 const saveHistoryData = localStorage . getItem ( 'saveHistoryData' ) !== 'false' ;
11581199 document . getElementById ( 'saveHistoryData' ) . checked = saveHistoryData ;
11591200
1160- // Default Export Path
1161- const defaultExportPath = localStorage . getItem ( 'defaultExportPath' ) || '' ;
1162- defaultExportPathInput . value = defaultExportPath ;
1201+ // Initialize default export path
1202+ const defaultPath = localStorage . getItem ( 'defaultExportPath' ) || '' ;
1203+ defaultExportPathInput . value = defaultPath ;
11631204}
11641205
11651206function updateStats ( ) {
0 commit comments