mirror of
https://github.com/tachiyomiorg/tachiyomi-extensions.git
synced 2025-12-10 10:52:03 +01:00
fix RCO (#16900)
* lib-synchrony ported from aniyomiorg/aniyomi-extensions Co-authored-by: jmir1 <43830312+jmir1@users.noreply.github.com> * RCO: deobfuscate and extract beau function from rguard script * fix genre filter * bump --------- Co-authored-by: jmir1 <43830312+jmir1@users.noreply.github.com>
This commit is contained in:
22
lib/synchrony/build.gradle.kts
Normal file
22
lib/synchrony/build.gradle.kts
Normal file
@@ -0,0 +1,22 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
namespace = "eu.kanade.tachiyomi.lib.synchrony"
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
targetSdk = AndroidConfig.targetSdk
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.bundles.common)
|
||||
}
|
||||
289
lib/synchrony/src/main/assets/synchrony-v2.4.2.1.js
Normal file
289
lib/synchrony/src/main/assets/synchrony-v2.4.2.1.js
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,43 @@
|
||||
package eu.kanade.tachiyomi.lib.synchrony
|
||||
|
||||
import app.cash.quickjs.QuickJs
|
||||
|
||||
/**
|
||||
* Helper class to deobfuscate JavaScript strings with synchrony.
|
||||
*/
|
||||
object Deobfuscator {
|
||||
fun deobfuscateScript(source: String): String? {
|
||||
val originalScript = javaClass.getResource("/assets/$SCRIPT_NAME")
|
||||
?.readText() ?: return null
|
||||
|
||||
// Sadly needed until QuickJS properly supports module imports:
|
||||
// Regex for finding one and two in "export{one as Deobfuscator,two as Transformer};"
|
||||
val regex = """export\{(.*) as Deobfuscator,(.*) as Transformer\};""".toRegex()
|
||||
val synchronyScript = regex.find(originalScript)?.let { match ->
|
||||
val (deob, trans) = match.destructured
|
||||
val replacement = "const Deobfuscator = $deob, Transformer = $trans;"
|
||||
originalScript.replace(match.value, replacement)
|
||||
} ?: return null
|
||||
|
||||
return QuickJs.create().use { engine ->
|
||||
engine.evaluate("globalThis.console = { log: () => {}, warn: () => {}, error: () => {}, trace: () => {} };")
|
||||
engine.evaluate(synchronyScript)
|
||||
|
||||
engine.set(
|
||||
"source", TestInterface::class.java,
|
||||
object : TestInterface {
|
||||
override fun getValue() = source
|
||||
},
|
||||
)
|
||||
engine.evaluate("new Deobfuscator().deobfuscateSource(source.getValue())") as? String
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
private interface TestInterface {
|
||||
fun getValue(): String
|
||||
}
|
||||
}
|
||||
|
||||
// Update this when the script is updated!
|
||||
private const val SCRIPT_NAME = "synchrony-v2.4.2.1.js"
|
||||
Reference in New Issue
Block a user