@@ -38,16 +38,7 @@ import java.util.logging.Logger
3838class SpamUtils {
3939
4040 companion object {
41- // URLs
42- const val LISTA_SPAM_URL_TEMPLATE = " https://www.listaspam.com/busca.php?Telefono=%s"
43- const val LISTA_SPAM_CSS_SELECTOR =
44- " .rate-and-owner .phone_rating:not(.result-4):not(.result-5)"
45- private const val RESPONDERONO_URL_TEMPLATE =
46- " https://www.responderono.es/numero-de-telefono/%s"
47- private const val RESPONDERONO_CSS_SELECTOR = " .scoreContainer .score.negative"
48- private const val CLEVER_DIALER_URL_TEMPLATE = " https://www.cleverdialer.es/numero/%s"
49- private const val CLEVER_DIALER_CSS_SELECTOR =
50- " body:has(#comments):has(.front-stars:not(.star-rating .stars-4, .star-rating .stars-5)), .circle-spam"
41+ // ...existing code...
5142
5243 private const val SPAM_PREFS = " SPAM_PREFS"
5344 private const val BLOCK_NUMBERS_KEY = " BLOCK_NUMBERS"
@@ -240,35 +231,25 @@ class SpamUtils {
240231
241232 private fun buildSpamCheckers (context : Context ): List <suspend (String ) -> Boolean > {
242233 val spamCheckers = mutableListOf< suspend (String ) -> Boolean > ()
243-
244- // ListaSpam
234+ // ...existing code for API-based checkers only...
245235 val listaSpamApi = shouldFilterWithListaSpamApi(context)
246236 if (listaSpamApi) {
247237 spamCheckers.add { number ->
248238 ApiUtils .checkListaSpamApi(number, getListaSpamApiLang(context) ? : " EN" )
249239 }
250240 }
251-
252- // Tellows
253241 val tellowsApi = shouldFilterWithTellowsApi(context)
254242 if (tellowsApi) {
255243 spamCheckers.add { number ->
256244 ApiUtils .checkTellowsSpamApi(number, getTellowsApiCountry(context) ? : " us" )
257245 }
258246 }
259-
260- // Truecaller
261247 val truecallerApi = shouldFilterWithTruecallerApi(context)
262248 if (truecallerApi) {
263249 spamCheckers.add { number ->
264250 ApiUtils .checkTruecallerSpamApi(number, getTruecallerApiCountry(context) ? : " US" )
265251 }
266252 }
267-
268- if (shouldFilterWithListaSpamScraper(context) && ! listaSpamApi) spamCheckers.add(::checkListaSpam)
269-
270- if (shouldFilterWithResponderONo(context)) spamCheckers.add(::checkResponderono)
271- if (shouldFilterWithCleverdialer(context)) spamCheckers.add(::checkCleverdialer)
272253 return spamCheckers
273254 }
274255
@@ -356,69 +337,7 @@ class SpamUtils {
356337 }
357338 }
358339
359- /* *
360- * Checks if a number is marked as spam on ListaSpam.
361- *
362- * @param number The phone number to check.
363- * @return True if the number is marked as spam, false otherwise.
364- */
365- private suspend fun checkListaSpam (number : String ): Boolean {
366- val url = LISTA_SPAM_URL_TEMPLATE .format(number)
367- return checkUrlForSpam(
368- url,
369- LISTA_SPAM_CSS_SELECTOR
370- )
371- }
372-
373- /* *
374- * Checks if a number is marked as spam on Responderono.
375- *
376- * @param number The phone number to check.
377- * @return True if the number is marked as spam, false otherwise.
378- */
379- private suspend fun checkResponderono (number : String ): Boolean {
380- val url = RESPONDERONO_URL_TEMPLATE .format(number)
381- return checkUrlForSpam(url, RESPONDERONO_CSS_SELECTOR )
382- }
383-
384- /* *
385- * Checks if a number is marked as spam on Cleverdialer.
386- *
387- * @param number The phone number to check.
388- * @return True if the number is marked as spam, false otherwise.
389- */
390- private suspend fun checkCleverdialer (number : String ): Boolean {
391- val url = CLEVER_DIALER_URL_TEMPLATE .format(number)
392- return checkUrlForSpam(url, CLEVER_DIALER_CSS_SELECTOR )
393- }
394-
395- /* *
396- * Checks a URL for spam indicators using a CSS selector.
397- *
398- * @param url The URL to check.
399- * @param cssSelector The CSS selector to use for finding spam indicators.
400- * @return True if spam indicators are found, false otherwise.
401- */
402- private suspend fun checkUrlForSpam (url : String , cssSelector : String ): Boolean {
403- val request = Request .Builder ()
404- .header(" User-Agent" , USER_AGENT )
405- .url(url)
406- .build()
407-
408- return withContext(Dispatchers .IO ) {
409- try {
410- client.newCall(request).execute().use { response ->
411- val body = response.body?.string() ? : return @withContext false
412- val doc = Jsoup .parse(body)
413- doc.select(cssSelector).isNotEmpty()
414- }
415- } catch (e: IOException ) {
416- Logger .getLogger(" checkUrlForSpam" )
417- .warning(" Error checking URL: $url with error ${e.message} " )
418- false
419- }
420- }
421- }
340+ // ...scraper logic removed...
422341
423342 /* *
424343 * Handles the scenario when a phone number is identified as spam.
0 commit comments