From 1fc3a466328d81cbf7afa74c439fcf7ecdb67a60 Mon Sep 17 00:00:00 2001 From: bapeey <90949336+bapeey@users.noreply.github.com> Date: Mon, 26 Feb 2024 09:18:46 -0500 Subject: [PATCH] Manga Crab: Add randomUa and change domain (#1539) * Add randomUa and change domain * Lint * Lint? * Remove lazy Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> --------- Co-authored-by: AwkwardPeak7 <48650614+AwkwardPeak7@users.noreply.github.com> --- src/es/mangacrab/build.gradle | 8 +++-- .../extension/es/mangacrab/MangaCrab.kt | 36 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/es/mangacrab/build.gradle b/src/es/mangacrab/build.gradle index 1e156e8da..a2e851051 100644 --- a/src/es/mangacrab/build.gradle +++ b/src/es/mangacrab/build.gradle @@ -2,8 +2,12 @@ ext { extName = 'Manga Crab' extClass = '.MangaCrab' themePkg = 'madara' - baseUrl = 'https://mangacrab3.com' - overrideVersionCode = 7 + baseUrl = 'https://httpmangacrab2.com' + overrideVersionCode = 8 } apply from: "$rootDir/common.gradle" + +dependencies { + implementation(project(':lib:randomua')) +} diff --git a/src/es/mangacrab/src/eu/kanade/tachiyomi/extension/es/mangacrab/MangaCrab.kt b/src/es/mangacrab/src/eu/kanade/tachiyomi/extension/es/mangacrab/MangaCrab.kt index 16d44f234..230157f52 100644 --- a/src/es/mangacrab/src/eu/kanade/tachiyomi/extension/es/mangacrab/MangaCrab.kt +++ b/src/es/mangacrab/src/eu/kanade/tachiyomi/extension/es/mangacrab/MangaCrab.kt @@ -1,17 +1,37 @@ package eu.kanade.tachiyomi.extension.es.mangacrab +import android.app.Application +import android.content.SharedPreferences +import androidx.preference.PreferenceScreen +import eu.kanade.tachiyomi.lib.randomua.addRandomUAPreferenceToScreen +import eu.kanade.tachiyomi.lib.randomua.getPrefCustomUA +import eu.kanade.tachiyomi.lib.randomua.getPrefUAType +import eu.kanade.tachiyomi.lib.randomua.setRandomUserAgent import eu.kanade.tachiyomi.multisrc.madara.Madara import eu.kanade.tachiyomi.network.interceptor.rateLimit +import eu.kanade.tachiyomi.source.ConfigurableSource +import uy.kohesive.injekt.Injekt +import uy.kohesive.injekt.api.get import java.text.SimpleDateFormat import java.util.Locale -class MangaCrab : Madara( - "Manga Crab", - "https://mangacrab3.com", - "es", - SimpleDateFormat("dd/MM/yyyy", Locale("es")), -) { +class MangaCrab : + Madara( + "Manga Crab", + "https://httpmangacrab2.com", + "es", + SimpleDateFormat("dd/MM/yyyy", Locale("es")), + ), + ConfigurableSource { + + private val preferences: SharedPreferences = + Injekt.get().getSharedPreferences("source_$id", 0x0000) + override val client = super.client.newBuilder() + .setRandomUserAgent( + preferences.getPrefUAType(), + preferences.getPrefCustomUA(), + ) .rateLimit(1, 2) .build() @@ -19,4 +39,8 @@ class MangaCrab : Madara( override fun chapterListSelector() = "div.listing-chapters_wrap > ul > li" override val mangaDetailsSelectorDescription = "div.c-page__content div.modal-contenido" + + override fun setupPreferenceScreen(screen: PreferenceScreen) { + addRandomUAPreferenceToScreen(screen) + } }