This commit is contained in:
lunaticbum 2024-09-07 17:55:28 +09:00
parent f5003d9378
commit ac6523b2dd
9 changed files with 334 additions and 118 deletions

View File

@ -64,7 +64,7 @@ dependencies {
implementation 'com.google.code.gson:gson:2.10.1'
// implementation files('libs/DualScreen.jar')
implementation ("org.jsoup:jsoup:1.18.1")
implementation 'io.realm.kotlin:library-base:2.0.0'

View File

@ -21,6 +21,7 @@ import android.view.KeyEvent
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.webkit.JavascriptInterface
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
@ -57,12 +58,19 @@ import com.mime.dualscreenview.webcontents.BaseWebContentsViewer
import com.mime.dualscreenview.webcontents.MainControllInterface
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.GotoSomeWhere
import com.mime.dualscreenview.webcontents.contentsinfo.NewtokiOne
import com.mime.dualscreenview.webcontents.getT
import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.ext.copyFromRealm
import io.realm.kotlin.ext.isManaged
import io.realm.kotlin.ext.query
import io.realm.kotlin.ext.realmListOf
import org.jsoup.Jsoup
import java.lang.System.currentTimeMillis
import java.text.SimpleDateFormat
import java.util.Date
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import kotlin.random.Random
@ -88,7 +96,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
fun getCurrentUrl() : String {
var currentPath = currentBooinfo?.pathUrl ?: mBaseWebContentsViewer.webview.url?.toUri()?.path ?: ""
var domain = PrefManager.getLastDomain()
return domain.plus("/").plus(if (currentPath.length > 4) currentPath else "")
return domain.plus(if (currentPath.length > 4) currentPath else "")
}
override fun onConfigurationChanged(newConfig: Configuration) {
@ -130,6 +138,10 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
binding.hiddenWeb?.let { v->
contentsSaver = v
contentsSaver?.webViewClient = saveClient
try {
contentsSaver?.removeJavascriptInterface("MyJavaScriptInterface")
} catch (e:Exception) {e.printStackTrace()}
contentsSaver?.addJavascriptInterface(SaveHelper(),"MyJavaScriptInterface")
contentsSaver?.settings?.textZoom = 100
contentsSaver?.settings?.javaScriptEnabled = true
contentsSaver?.settings?.javaScriptCanOpenWindowsAutomatically = false
@ -158,7 +170,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
binding.btnHome.setOnClickListener { v->
paged_layer.visibility = GONE
mBaseWebContentsViewer.loadContents(Booktoki)
mBaseWebContentsViewer.loadContents(NewtokiOne)
}
loadLastInfo()
@ -181,8 +193,8 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
Blog.LOGE("HistoryManager.getNextPage(${lastInfo?.pageUrl})")
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
Blog.LOGE("HistoryManager.getNextPage(${Booktoki.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
Blog.LOGE("HistoryManager.getNextPage(${NewtokiOne.getLastedDoamin()})")
mBaseWebContentsViewer.webview.loadUrl(NewtokiOne.getLastedDoamin() + it?.pathUrl!!)
}
it?.pathUrl?.let {
HistoryManager.getBookInfos(it) {
@ -230,8 +242,15 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
}
}
override fun onBookInfos(aInfos: BookPageInfos) {
Blog.LOGE("onBookInfos(aInfos: ${aInfos})")
runOnUiThread {
showList(aInfos)
}
}
override fun onBookInfos(jsonString: String) {
Blog.LOGE("onBookInfos" , "onBookInfos >> ${jsonString}")
Blog.LOGE("onBookInfos" , "jsonString >> ${jsonString}")
val realm = openRealm()
var infos : BookPageInfos? = null
realm.writeBlocking {
@ -270,7 +289,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
infos?.bookPageUrl?.let {
HistoryManager.getBookInfos(it){
it?.let {
Blog.LOGE("onBookInfos" , "onBookInfos it >> ${it}")
Blog.LOGE(s(), "onBookInfos it >> ${it}")
runOnUiThread {
showList(it)
}
@ -281,12 +300,14 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
}
}
private fun s() = "onBookInfos"
fun reloadTo(lastInfo: LastInfo?) {
findViewById<WebView>(R.id.menu_web)?.postDelayed({
if (lastInfo != null) {
mBaseWebContentsViewer.loadLastInfo(lastInfo!!)
} else {
mBaseWebContentsViewer.loadContents(Booktoki)
mBaseWebContentsViewer.loadContents(NewtokiOne)
}
},200L)
}
@ -380,7 +401,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
}
fun showList(infos: BookPageInfos) {
Blog.LOGE("showList infos >>>>${infos}")
if (infos != null && infos.pages.size ?: 0 > 0) {
var items : ArrayList<BookPageInfo> = arrayListOf()
for (item in infos.pages) {
@ -391,7 +412,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
DefaultList.showDefaultList(
this@Intro,
"현제는 ${currentTitle} - ${(infos.pages.size ?: 0) - currentChapter} -> 다른화를 골라",
"현제는 ${currentTitle} - ${currentChapter} -> 다른화를 골라",
items,
currentChapter,
{ position ->
@ -420,17 +441,29 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
return text.trim()
}
var isLoading = false
var saveClient = object : WebViewClient() {
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
isLoading = true
Blog.LOGE("saveClient >>> ${isLoading} ${url}")
}
override fun onPageFinished(webView: WebView?, url: String?) {
super.onPageFinished(webView, url)
isLoading = false
webView?.postDelayed({ autoScrollDown(webView, url) },(1300L + Random(System.currentTimeMillis()).nextLong().rem(1286L)))
finishedUrl = url ?: ""
webView?.postDelayed({
webView?.evaluateJavascript(
"function getAll() {\n" +
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
" };getAll()"
) { result ->
(result as? String)?.let {
}
}
}, 11000L)
}
}
fun showToast(origin: String) {
runOnUiThread {
@ -443,48 +476,32 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
).show()
}
}
fun autoScrollDown(webView: WebView?, url: String?) {
webView?.let { webView ->
val ramdomTimeSec =
800L.plus(Random(System.currentTimeMillis()).nextLong().rem(789L))
Blog.LOGE("ramdomTime >>> ${ramdomTimeSec}")
if (((webView?.scrollY ?: 0) + (webView?.height
?: 0)) < webView?.contentHeight ?: 0
) {
webView?.postDelayed({
webView?.pageDown(false)
autoScrollDown(webView, url)
}, ramdomTimeSec)
var finishedUrl : String? = null
inner class SaveHelper {
@JavascriptInterface
fun sendValueFromHtml(string: String) {
Jsoup.parse(string)?.let { html ->
val view_padding = html.getElementsByClass("view-padding")
if (view_padding.size > 0){
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
val contents = view_padding.get(0).children().html().replace("<p>"," ").replace("</p>","\n\n")
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: view_padding.get(0)\n${contents}")
if (contents.length > 20) {
Uri.parse(finishedUrl).path?.let {
HistoryManager.getBooPageInfoContentsSave(it, contents).apply {
HistoryManager.getBookPageInfo(it) { book ->
showToast("saved ${book?.getTitleItem()} :: lenght = ${contents.length}")
}
}.apply {
HistoryManager.getBookInfos(it) { saveItem(it)}
}
}
}
} else {
webView?.postDelayed({
var findContents = Booktoki.getFindContentsJs()
webView?.evaluateJavascript(findContents) { result: String? ->
result?.let { string: String ->
if (string.length > 10) {
val contents = string.replace("\\\"", "\"")
.replace("\\n", System.getProperty("line.separator"))
.replace("\\n", System.getProperty("line.separator"))
Uri.parse(url)?.let {
it.path?.let {
HistoryManager.getBooPageInfoContentsSave(it, contents.replace(Char(0x20).toString(), " "))
HistoryManager.getBookPageInfo(it) { info ->
info?.let { showToast(info.getTitleItem()) }
}
}
}
}
var ramdomTime = 2000L.plus(Random(System.currentTimeMillis()).nextLong().rem(1785L))
Blog.LOGE("afterNextPageTime >>> ${ramdomTime}")
contentsSaver?.postDelayed({ saveItem(null) }, ramdomTime)
}
}
}, ramdomTimeSec)
}
}
}
}
var saveTarget : ArrayList<BookPageInfo> = arrayListOf()
private fun saveItem(infos: BookPageInfos?) {
Blog.LOGE("saveItem >>> infos?.pages ${infos?.pages?.size ?: 0}")
@ -513,7 +530,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
Blog.LOGE("saveItem >>> saveTarget ${saveTarget.count()}")
if (isLoading == false) {
try {
saveTarget.removeFirst().let {
Blog.LOGE("saveItem >>> ${it.pathUrl}")
@ -532,8 +548,6 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
}
}
}
private fun moveTo(item: BookPageInfo?) {
item?.pathUrl?.let { newPath ->
if (item.contents?.length ?: 0 > 10) {
@ -597,8 +611,13 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
fun contentsLoad(pathUrl : String) {
HistoryManager.getBookPageInfo(pathUrl) {
Blog.LOGE("contentsLoad :::: pathUrl >> ${pathUrl}")
it?.pathUrl?.let {
HistoryManager.getBookInfos(it) { saveItem(it) }
Blog.LOGE("contentsLoad :::: pathUrl >> ${it}")
HistoryManager.getBookInfos(it) {
Blog.LOGE("contentsLoad :::: getBookInfos >> ${it}")
saveItem(it)
}
}
if (it != null) currentBooinfo = it
if (it != null && (it?.contents?.length ?: 0) > 10) {
@ -608,7 +627,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
if (lastInfo?.pageUrl?.length ?: 0 > 0 && lastInfo?.pageUrl!!.startsWith("http")) {
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
mBaseWebContentsViewer.webview.loadUrl(NewtokiOne.getLastedDoamin() + it?.pathUrl!!)
}
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
}
@ -620,7 +639,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
mBaseWebContentsViewer.webview.loadUrl(lastInfo!!.pageUrl!!.replace(Uri.parse(lastInfo!!.pageUrl)!!.path!!,it?.pathUrl!!))
} else {
paged_layer.visibility = GONE
mBaseWebContentsViewer.webview.loadUrl(Booktoki.getLastedDoamin() + it?.pathUrl!!)
mBaseWebContentsViewer.webview.loadUrl(NewtokiOne.getLastedDoamin() + it?.pathUrl!!)
}
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
}
@ -726,6 +745,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
@RequiresApi(Build.VERSION_CODES.O)
override fun onLoadedContents(aContents: String) {
paged_layer.apply {
paged_layer.post {
if (aContents != null && aContents.length > 10) {
var contents = aContents.replace("\\\"", "\"")
contents = (contents.replace("\\n", System.getProperty("line.separator")))
@ -750,7 +770,12 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
currentBooinfo = it
currentChapter = it?.chapterNum ?: 0
currentPage = it?.chapterNum ?: 0
HistoryManager.save(historyItem = HistoryItem().putHistory(it,mBaseWebContentsViewer.webview.url!!))
HistoryManager.save(
historyItem = HistoryItem().putHistory(
it,
mBaseWebContentsViewer.webview.url!!
)
)
}
}
HistoryManager.getBooPageInfoContentsSave(it!!.path!!, contents)
@ -758,6 +783,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
}
}
}
}
Log.i(TAG,"onLoadedContents >> " + aContents)
}

View File

@ -3,6 +3,7 @@ package com.mime.dualscreenview.common
import android.content.Context
import android.content.SharedPreferences
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.NewtokiOne
object PrefManager {
private val mainName = "Main_Pref_"
@ -20,7 +21,7 @@ object PrefManager {
}
fun getLastDomain() : String {
return main.getString(domainKey, Booktoki.getLastedDoamin()) ?: Booktoki.getLastedDoamin()
return main.getString(domainKey, NewtokiOne.getLastedDoamin()) ?: NewtokiOne.getLastedDoamin()
}
fun putLastDomain(domain : String) {
Blog.LOGE("domain >>> ${domain}")

View File

@ -61,13 +61,18 @@ object HistoryManager {
url = url.replace("//","/").trim()
}
}
var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0 || bookPageUrl == $1","${url}","${url}").find()
Blog.LOGE("aUrl >>> ${aUrl}")
Blog.LOGE("aUrl >>> ${aUrl}")
var bookPageInfo = this.query(BookPageInfo::class).query("pathUrl == $0 || bookPageUrl == $0","${url}").find()
if (bookPageInfo != null && bookPageInfo.count() > 0) {
Blog.LOGE("get ${bookPageInfo}" )
this.query(BookPageInfos::class,"bookPageUrl == $0",bookPageInfo.first().bookPageUrl).find().first().let {
var pgs = this.query(BookPageInfos::class,"bookPageUrl == $0", bookPageInfo.first().bookPageUrl).find()
if (pgs.size > 0) {
pgs.first().let {
Blog.LOGE("get ${it} , ${it?.pages}")
callback.invoke(this.copyFromRealm(it))
}
}
} else {
callback.invoke(null)
}

View File

@ -1,5 +1,6 @@
package com.mime.dualscreenview.webcontents
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.graphics.Bitmap
import android.net.Uri
@ -7,15 +8,22 @@ import android.net.http.SslError
import android.util.Log
import android.webkit.*
import androidx.core.net.toUri
import com.google.gson.Gson
import com.mime.dualscreenview.common.Blog
import com.mime.dualscreenview.common.PrefManager
import com.mime.dualscreenview.data.HistoryManager
import com.mime.dualscreenview.data.model.BookPageInfo
import com.mime.dualscreenview.data.model.BookPageInfos
import com.mime.dualscreenview.data.model.LastInfo
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents
import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.ext.realmListOf
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.json.JSONObject
import org.jsoup.Jsoup
import org.jsoup.select.Elements
open class BaseWebContentsViewer {
@ -38,6 +46,7 @@ open class BaseWebContentsViewer {
}
}
@SuppressLint("JavascriptInterface")
constructor(webview : WebView, mainControllInterface : MainControllInterface ) {
this.webview = webview
this.mainControllInterface = mainControllInterface
@ -51,6 +60,10 @@ open class BaseWebContentsViewer {
webview.settings.setPluginState(WebSettings.PluginState.ON)
webview.settings.domStorageEnabled = true
webview.clearCache(true);
try {
webview.removeJavascriptInterface("MyJavaScriptInterface")
}catch (e :Exception){e.printStackTrace()}
webview.addJavascriptInterface( BookHelper(),"MyJavaScriptInterface")
webview.clearHistory();
webview.clearSslPreferences();
WebView.setWebContentsDebuggingEnabled(true)
@ -83,7 +96,7 @@ open class BaseWebContentsViewer {
webview.loadUrl(last.pageUrl)
} else {
try {
webview.loadUrl(PrefManager.getLastDomain().plus("/").plus(last.pageUrl))
webview.loadUrl(PrefManager.getLastDomain().plus(last.pageUrl))
} catch (e : Exception) {
webview.loadUrl(PrefManager.getLastDomain())
}
@ -92,7 +105,6 @@ open class BaseWebContentsViewer {
}
val rootWebViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
@ -131,8 +143,10 @@ open class BaseWebContentsViewer {
// super.onReceivedHttpError(view, request, errorResponse)
}
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
finishedUrl = url ?: ""
view?.let {
url?.toUri()?.let {
PrefManager.putLastDomain(it.scheme.plus("::/").plus(it.host))
@ -143,10 +157,21 @@ open class BaseWebContentsViewer {
Blog.LOGE("onPageFinished", url ?: "")
}
} else if (url?.contains("booktoki") ?: false){
findListItem {
Blog.LOGE("onPageFinished", url ?: "")
// findListItem {
// Blog.LOGE("onPageFinished", url ?: "")
// }
}
view?.postDelayed({
view?.evaluateJavascript(
"function getAll() {\n" +
" MyJavaScriptInterface.sendValueFromHtml(document.getElementsByTagName('html')[0].innerHTML)" +
" };getAll()"
) { result ->
(result as? String)?.let {
}
}
}, 500L)
currentContentsProvider?.doOnloaded(it , { result ->
result?.let { mainControllInterface.onLoadedContents(it) }
@ -162,4 +187,65 @@ open class BaseWebContentsViewer {
}
}
}
var finishedUrl : String = ""
inner class BookHelper {
@JavascriptInterface
fun sendValueFromHtml(string: String) {
Jsoup.parse(string)?.let { html ->
val toon_intro = html.getElementById("toon_intro")
val view_padding = html.getElementsByClass("view-padding")
if (toon_intro != null) {
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
val bookPageInfos = BookPageInfos()
bookPageInfos.bookPageUrl = Uri.parse(finishedUrl).path
bookPageInfos.bookTitle = if (toon_intro.getElementsByTag("h3").size > 0) toon_intro.getElementsByTag("h3").get(0).text() else ""
bookPageInfos.pages = realmListOf<BookPageInfo>()
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookPageInfos >>>> ${Gson().toJson(bookPageInfos)}")
val listParent = html.getElementById("list_type")
if (listParent != null) {
listParent.getElementsByClass("row").forEach { bookitem ->
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookItemInfo ${bookitem}")
try {
val bookPageInfo = BookPageInfo()
bookPageInfo.bookTitle = bookPageInfos.bookTitle
bookPageInfo.chapterNum = bookitem.getElementsByClass("cell_num").getT().toInt()
bookPageInfo.chapterID = bookitem.getElementsByClass("cell_num").getT().toInt()
bookPageInfo.chapterTitle = bookitem.getElementsByTag("a").getT()
bookPageInfo.bookPageUrl = bookPageInfos.bookPageUrl
val href = bookitem.getElementsByTag("a").get(0).attr("href")
bookPageInfo.pathUrl = Uri.parse(href).path
bookPageInfos.pages.add(bookPageInfo)
}catch (nfe : NumberFormatException) {
nfe.printStackTrace()
}
}.apply {
HistoryManager.openRealm.writeBlocking {
copyToRealm(bookPageInfos, UpdatePolicy.ALL)
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: bookPageInfos saved >>>> ${bookPageInfos.bookPageUrl}")
}
mainControllInterface.onBookInfos(bookPageInfos)
}
}
}else if (view_padding.size > 0){
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
val contents = view_padding.get(0).children().html().replace("<p>"," ").replace("</p>","\n\n")
// Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: view_padding.get(0)\n${contents}")
if (contents.length > 20) {
Uri.parse(finishedUrl).path?.let {
HistoryManager.getBooPageInfoContentsSave(it, contents)
mainControllInterface.onLoadedContents(contents)
}
}
} else {
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: ${html.title()}")
Blog.LOGE("finishedUrl >>> ${finishedUrl} :::: whole body ${html}")
}
}
}
}
}
fun Elements.getT() = if (size > 0) get(0).text() else ""

View File

@ -1,5 +1,6 @@
package com.mime.dualscreenview.webcontents
import com.mime.dualscreenview.data.model.BookPageInfos
import com.mime.dualscreenview.data.model.LastInfo
import com.mime.dualscreenview.webcontents.contentsinfo.GotoSomeWhere
@ -16,5 +17,6 @@ interface MainControllInterface {
fun onFindTitle(contents :String)
fun onBookInfos(jsonString : String)
fun onBookInfos(infos : BookPageInfos)
}

View File

@ -2,9 +2,10 @@ package com.mime.dualscreenview.webcontents
import com.mime.dualscreenview.webcontents.contentsinfo.Agit
import com.mime.dualscreenview.webcontents.contentsinfo.Booktoki
import com.mime.dualscreenview.webcontents.contentsinfo.NewtokiOne
object WebContentsManger {
val allContentsList : ArrayList<BaseWebContents> = arrayListOf(Booktoki)
val allContentsList : ArrayList<BaseWebContents> = arrayListOf(NewtokiOne)
fun getBaseWebContentsBy(name : String) : BaseWebContents {
var correctContents : BaseWebContents = Booktoki

View File

@ -4,7 +4,7 @@ import com.mime.dualscreenview.webcontents.BaseWebContents
object Booktoki : BaseWebContents() {
override var lastNumber : Int = 350
override var lastNumber : Int = 351
override fun getWebcontentsName(): String {
return "Booktoki"

View File

@ -0,0 +1,95 @@
package com.mime.dualscreenview.webcontents.contentsinfo
import com.mime.dualscreenview.webcontents.BaseWebContents
object NewtokiOne : BaseWebContents() {
override var lastNumber : Int = 351
override fun getWebcontentsName(): String {
return "newtokione"
}
override fun getLastedDoamin(): String {
return "https://newtoki.one"
}
override fun getContentsList(): String {
return "function getList() {\n" +
" const contentsArray = [];\n" +
" var children = document.getElementsByClassName('list-body')[0].children;\n" +
" var maxCount = children.length;\n" +
" for (i= 0; i < maxCount; i++) {\n" +
" var chapterNum = children[i].getElementsByClassName('wr-num')[0].textContent;\n" +
" var pageUrl = children[i].getElementsByClassName('wr-subject')[0].getElementsByTagName('a')[0].href;\n" +
" if (pageUrl != null && pageUrl.length > 0 && pageUrl.startsWith(\"http\")) {\n" +
" pageUrl = new URL(pageUrl).pathname;\n" +
" }\n" +
" var chapterTitle = children[i].getElementsByClassName('wr-subject')[0].getElementsByTagName('a')[0].innerText;\n" +
" if(chapterTitle.split('\\n').length > 1) {\n" +
" chapterTitle = chapterTitle.split('\\n')[1];\n" +
" }\n" +
"\n" +
" var bookPageUrl = location.pathname;\n" +
" var bookTitle = document.getElementsByClassName('view-title')[0].getElementsByTagName('span')[0].innerText;\n" +
" var data = {\n" +
" 'chapterID': Number(chapterNum),\n" +
" 'chapterNum': Number(chapterNum),\n" +
" 'pathUrl': pageUrl,\n" +
" 'bookPageUrl': bookPageUrl,\n" +
" 'chapterTitle': chapterTitle,\n" +
" 'bookTitle': bookTitle,\n" +
" };\n" +
" contentsArray.push(\n" +
" data\n" +
" );\n" +
" }\n" +
" \n" +
" if(contentsArray.length > 0) {\n" +
" PAgit.onBookInfo(JSON.stringify({\n" +
" 'bookTitle': bookTitle,\n" +
" 'bookPageUrl': new URL(location.href).pathname,\n" +
" 'pages': contentsArray ,\n" +
" }));\n" +
" }\n" +
"}\n" +
"getList()\n" +
""
}
override fun acccceptResourceKeyword(): String {
return "toki"
}
override fun getNextButtonJs(): String {
return "goNextBtn"
}
override fun getPrevButtonJs(): String {
return "goPrevBtn"
}
override fun getTitleJs(): String {
return "document.getElementsByClassName(\"toon-title\").length > 0 ? document.getElementsByClassName(\"toon-title\")[0].title : null"
}
override fun getFindContentsJs(): String {
return "document.getElementById(\"novel_content\") != null ? document.getElementById(\"novel_content\").innerText : null"
}
override fun checkCorrectContents(contents: String): String {
return if (contents != null && !contents.isNullOrEmpty()) {
contents
} else {
"fail load"
}
}
// "if(document.getElementsByClassName(\"hd_pops\") != null && document.getElementsByClassName(\"hd_pops\").length > 0) document.getElementsByClassName(\"hd_pops\")[0].remove();" +
// "if(document.getElementsByClassName(\"hd_pops\") != null && document.getElementsByClassName(\"hd_pops\").length > 0) document.getElementsByClassName(\"hd_pops\")[0].remove();" +
// "if(document.getElementById(\"main-banner-view\") != null) document.getElementById(\"main-banner-view\").remove();" +
// "if(document.getElementsByClassName(\"board-tail-banner\") != null && document.getElementsByClassName(\"board-tail-banner\").length > 0)document.getElementsByClassName(\"board-tail-banner\")[0].remove();" +
// "if(document.getElementById(\"id_mbv\") != null)document.getElementById(\"id_mbv\").remove();"
override fun onLoadedJs(): String {
return ""
}
}