|  |  |  | @ -5,7 +5,6 @@ import androidx.annotation.Keep | 
			
		
	
		
			
				
					|  |  |  |  | import io.legado.app.constant.AppConst.SCRIPT_ENGINE | 
			
		
	
		
			
				
					|  |  |  |  | import io.legado.app.constant.Pattern.JS_PATTERN | 
			
		
	
		
			
				
					|  |  |  |  | import io.legado.app.data.entities.BaseBook | 
			
		
	
		
			
				
					|  |  |  |  | import io.legado.app.help.JsExtensions | 
			
		
	
		
			
				
					|  |  |  |  | import io.legado.app.utils.* | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.* | 
			
		
	
		
			
				
					|  |  |  |  | import java.util.regex.Pattern | 
			
		
	
	
		
			
				
					|  |  |  | @ -516,9 +515,8 @@ class AnalyzeRule(private var book: BaseBook? = null) { | 
			
		
	
		
			
				
					|  |  |  |  |     @Throws(Exception::class) | 
			
		
	
		
			
				
					|  |  |  |  |     private fun evalJS(jsStr: String, result: Any?): Any { | 
			
		
	
		
			
				
					|  |  |  |  |         val bindings = SimpleBindings() | 
			
		
	
		
			
				
					|  |  |  |  |         bindings["analyzeRule"] = this | 
			
		
	
		
			
				
					|  |  |  |  |         bindings["java"] = this | 
			
		
	
		
			
				
					|  |  |  |  |         bindings["book"] = book | 
			
		
	
		
			
				
					|  |  |  |  |         bindings["java"] = JsExtensions() | 
			
		
	
		
			
				
					|  |  |  |  |         bindings["result"] = result | 
			
		
	
		
			
				
					|  |  |  |  |         bindings["baseUrl"] = baseUrl | 
			
		
	
		
			
				
					|  |  |  |  |         return SCRIPT_ENGINE.eval(jsStr, bindings) | 
			
		
	
	
		
			
				
					|  |  |  | @ -529,4 +527,44 @@ class AnalyzeRule(private var book: BaseBook? = null) { | 
			
		
	
		
			
				
					|  |  |  |  |         private val getPattern = Pattern.compile("@get:\\{([^}]+?)\\}", Pattern.CASE_INSENSITIVE) | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * js实现跨域访问,不能删 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     fun ajax(urlStr: String): String? { | 
			
		
	
		
			
				
					|  |  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |  |             val analyzeUrl = AnalyzeUrl(urlStr, null, null, null, null, null) | 
			
		
	
		
			
				
					|  |  |  |  |             val call = analyzeUrl.getResponse() | 
			
		
	
		
			
				
					|  |  |  |  |             val response = call.execute() | 
			
		
	
		
			
				
					|  |  |  |  |             if (response.body() != null) { | 
			
		
	
		
			
				
					|  |  |  |  |                 return response.body()!!.toString() | 
			
		
	
		
			
				
					|  |  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |  |         } catch (e: Exception) { | 
			
		
	
		
			
				
					|  |  |  |  |             return e.localizedMessage | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         return null | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * js实现解码,不能删 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     fun base64Decoder(str: String): String { | 
			
		
	
		
			
				
					|  |  |  |  |         return Encoder.base64Decoder(str) | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |  |      * 章节数转数字 | 
			
		
	
		
			
				
					|  |  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |  |     fun toNumChapter(s: String?): String? { | 
			
		
	
		
			
				
					|  |  |  |  |         if (s == null) { | 
			
		
	
		
			
				
					|  |  |  |  |             return null | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |         val pattern = Pattern.compile("(第)(.+?)(章)") | 
			
		
	
		
			
				
					|  |  |  |  |         val matcher = pattern.matcher(s) | 
			
		
	
		
			
				
					|  |  |  |  |         return if (matcher.find()) { | 
			
		
	
		
			
				
					|  |  |  |  |             matcher.group(1) + StringUtils.stringToInt(matcher.group(2)) + matcher.group(3) | 
			
		
	
		
			
				
					|  |  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |  |             s | 
			
		
	
		
			
				
					|  |  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |