Hide subscribe button when not subscribable

This commit is contained in:
Alex Ling
2022-06-05 12:33:26 +00:00
parent 2d97faa7c0
commit 30d5ad0c19
5 changed files with 25 additions and 4 deletions

View File

@@ -223,6 +223,10 @@ class Plugin
raise Error.new "Missing required fields in the Page type"
end
def can_subscribe? : Bool
info.version > 1 && eval_exists?("newChapters")
end
def search_manga(query : String)
if info.version == 1
raise Error.new "Manga searching is only available for plugins " \
@@ -327,6 +331,15 @@ class Plugin
JSON.parse eval(str).as String
end
private def eval_exists?(str) : Bool
@rt.eval str
true
rescue e : Duktape::ReferenceError
false
rescue e : Duktape::Error
raise Error.new e.message
end
private def def_helper_functions(sbx)
sbx.push_object