From 71fe20d3b8f8e86c396e5f0cdb2387fc01204024 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 8 Oct 2022 09:45:10 -0400 Subject: [PATCH] Add JavaScriptEngine abstraction to extensions-lib (#9) --- .../tachiyomi/network/JavaScriptEngine.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt diff --git a/library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt b/library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt new file mode 100644 index 0000000..9d15f29 --- /dev/null +++ b/library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt @@ -0,0 +1,19 @@ +package eu.kanade.tachiyomi.network + +import android.content.Context + +/** + * Util for evaluating JavaScript in sources. + */ +class JavaScriptEngine(context: Context) { + + /** + * Evaluate arbitrary JavaScript code and get the result as a primtive type + * (e.g., String, Int). + * + * @since extensions-lib 1.4 + * @param script JavaScript to execute. + * @return Result of JavaScript code as a primitive type. + */ + suspend fun evaluate(script: String): T = throw Exception("Stub!") +} \ No newline at end of file