100
100
101
101
</ head >
102
102
< body >
103
-
103
+
104
104
< form id ="urlForm ">
105
- < div class ="search-container ">
106
- < input type ="text " id ="codInput " placeholder ="Inserisci CODICE... ">
107
- < input type ="button " value ="Vai all'Ordine " onclick ="searchCOD() ">
108
- < br > < br >
109
-
110
- < input type ="text " id ="url " name ="url " placeholder ="Inserisci URL del prodotto... " required >
111
- < input type ="submit " value ="ricerca SKU ">
112
- </ form >
113
- < div id ="results "> </ div >
114
-
115
- < script >
116
- document . getElementById ( 'urlForm' ) . addEventListener ( 'submit' , async function ( event ) {
117
- event . preventDefault ( ) ; // Previene il refresh della pagina
118
- const url = document . getElementById ( 'url' ) . value ;
119
- const resultsDiv = document . getElementById ( 'results' ) ;
120
- resultsDiv . innerHTML = '' ; // Pulisce i risultati precedenti
121
-
122
- try {
123
- // Esegui la richiesta per ottenere il codice sorgente della pagina
124
- const response = await fetch ( `https://api.allorigins.win/raw?url=${ encodeURIComponent ( url ) } ` ) ;
125
- const text = await response . text ( ) ;
126
-
127
- // RegExp per trovare "SKU" e i 40 caratteri successivi
128
- const regex = / " s k u " .{ 0 , 40 } / g;
129
- let match ;
130
- const results = [ ] ;
131
-
132
- // Esegui la ricerca nel testo HTML
133
- while ( ( match = regex . exec ( text ) ) !== null ) {
134
- results . push ( match [ 0 ] ) ;
135
- }
136
-
137
- // Visualizza i risultati
138
- if ( results . length > 0 ) {
139
- resultsDiv . innerHTML = "<h2>stringhe trovate:</h2>" ;
140
- results . forEach ( result => {
141
- const p = document . createElement ( 'p' ) ;
142
- p . textContent = result ;
143
- resultsDiv . appendChild ( p ) ;
144
- } ) ;
145
- } else {
146
- resultsDiv . textContent = 'Nessuna stringa SKU trovata.' ;
147
- }
148
- } catch ( error ) {
149
- resultsDiv . textContent = 'Errore durante il recupero del codice HTML: ' + error ;
150
- }
151
- } ) ;
152
- </ script >
153
-
105
+ < div class ="search-container ">
106
+ < input type ="text " id ="codInput " placeholder ="Inserisci CODICE... ">
107
+ < input type ="button " value ="Vai all'Ordine " onclick ="searchCOD() ">
108
+ < br > < br >
109
+
110
+ < input type ="text " id ="url " name ="url " placeholder ="Inserisci URL del prodotto... " required >
111
+ < input type ="submit " value ="ricerca SKU ">
112
+ </ form >
113
+ < div id ="results "> </ div >
114
+
115
+ < script >
116
+ document . getElementById ( 'urlForm' ) . addEventListener ( 'submit' , async function ( event ) {
117
+ event . preventDefault ( ) ; // Previene il refresh della pagina
118
+ const url = document . getElementById ( 'url' ) . value ;
119
+ const resultsDiv = document . getElementById ( 'results' ) ;
120
+ resultsDiv . innerHTML = '' ; // Pulisce i risultati precedenti
121
+
122
+ try {
123
+ // Esegui la richiesta per ottenere il codice sorgente della pagina
124
+ const response = await fetch ( `https://api.allorigins.win/raw?url=${ encodeURIComponent ( url ) } ` ) ;
125
+ const text = await response . text ( ) ;
126
+
127
+ // RegExp per trovare "SKU" e i 40 caratteri successivi
128
+ const regex = / " s k u " .{ 0 , 40 } / g;
129
+ let match ;
130
+ const results = [ ] ;
131
+
132
+ // Esegui la ricerca nel testo HTML
133
+ while ( ( match = regex . exec ( text ) ) !== null ) {
134
+ results . push ( match [ 0 ] ) ;
135
+ }
136
+
137
+ // Visualizza i risultati
138
+ if ( results . length > 0 ) {
139
+ resultsDiv . innerHTML = "<h2>stringhe trovate:</h2>" ;
140
+ results . forEach ( result => {
141
+ const p = document . createElement ( 'p' ) ;
142
+ p . textContent = result ;
143
+ resultsDiv . appendChild ( p ) ;
144
+ } ) ;
145
+ } else {
146
+ resultsDiv . textContent = 'Nessuna stringa SKU trovata.' ;
147
+ }
148
+ } catch ( error ) {
149
+ resultsDiv . textContent = 'Errore durante il recupero del codice HTML: ' + error ;
150
+ }
151
+ } ) ;
152
+ </ script >
153
+
154
154
< br >
155
155
< input type ="text " id ="prodInput " placeholder ="Inserisci parole chiave... ">
156
156
< input type ="button " value ="Cerca sul sito Olalla.it " onclick ="searchPROD() ">
157
- </ div >
158
-
159
- < script >
160
- function searchCOD ( ) {
161
- const codice1 = document . getElementById ( 'codInput' ) . value . trim ( ) ;
162
-
163
- if ( codice1 ) {
164
- let nuovoURL = `https://www.olalla.it/wp-admin/post.php?post=${ codice1 } &action=edit` ;
165
- window . location . href = nuovoURL ;
166
- } else {
167
- alert ( "Per favore, inserisci un codice COD." ) ;
157
+ </ div >
158
+
159
+ < script >
160
+ function searchCOD ( ) {
161
+ const codice1 = document . getElementById ( 'codInput' ) . value . trim ( ) ;
162
+
163
+ if ( codice1 ) {
164
+ let nuovoURL = `https://www.olalla.it/wp-admin/post.php?post=${ codice1 } &action=edit` ;
165
+ window . open ( nuovoURL , '_blank' ) ; // Apri in una nuova scheda
166
+ } else {
167
+ alert ( "Per favore, inserisci un codice COD." ) ;
168
+ }
168
169
}
169
- }
170
- function searchSKU ( ) {
171
- const codice2 = document . getElementById ( 'skuInput' ) . value . trim ( ) ;
172
-
173
- if ( codice2 ) {
174
- const nuovoURL = `https://www.olalla.it/wp-admin/edit.php?s=${ codice2 } &post_status=all&post_type=product&action=-1&seo_filter&product_type&stock_status&wcpv_product_vendors&paged=1&action2=-1` ;
175
- window . location . href = nuovoURL ;
176
- } else {
177
- alert ( "Per favore, inserisci un codice SKU." ) ;
170
+
171
+ function searchSKU ( ) {
172
+ const codice2 = document . getElementById ( 'skuInput' ) . value . trim ( ) ;
173
+
174
+ if ( codice2 ) {
175
+ const nuovoURL = `https://www.olalla.it/wp-admin/edit.php?s=${ codice2 } &post_status=all&post_type=product&action=-1&seo_filter&product_type&stock_status&wcpv_product_vendors&paged=1&action2=-1` ;
176
+ window . open ( nuovoURL , '_blank' ) ; // Apri in una nuova scheda
177
+ } else {
178
+ alert ( "Per favore, inserisci un codice SKU." ) ;
179
+ }
178
180
}
179
- }
180
- function searchPROD ( ) {
181
- const codice3 = document . getElementById ( 'prodInput' ) . value . trim ( ) ;
182
-
183
- if ( codice3 ) {
184
- let nuovoURL = `https://www.olalla.it/?s=${ codice3 } &post_type=product` ;
185
- window . location . href = nuovoURL ;
186
- } else {
187
- alert ( "Per favore, inserisci una descrizione migliore." ) ;
181
+
182
+ function searchPROD ( ) {
183
+ const codice3 = document . getElementById ( 'prodInput' ) . value . trim ( ) ;
184
+
185
+ if ( codice3 ) {
186
+ let nuovoURL = `https://www.olalla.it/?s=${ codice3 } &post_type=product` ;
187
+ window . open ( nuovoURL , '_blank' ) ; // Apri in una nuova scheda
188
+ } else {
189
+ alert ( "Per favore, inserisci una descrizione migliore." ) ;
190
+ }
188
191
}
189
- }
190
-
191
- </ script >
192
- </ body >
193
- </ html >
194
-
195
-
196
-
197
-
192
+ </ script >
193
+ </ body >
194
+ </ html >
0 commit comments