1
0
mirror of https://github.com/fumiama/copymanga.git synced 2026-06-09 01:10:28 +08:00
修复阅读
This commit is contained in:
源文雨
2022-06-17 14:59:15 +08:00
parent d931b1334d
commit a97e38b82e
3 changed files with 32 additions and 12 deletions

View File

@@ -14,14 +14,21 @@ if (typeof (loaded) == "undefined"){
function modify() {
var url = location.href;
if(url.indexOf("/chapter/")>0){
var imglist = document.getElementsByClassName("container-fluid comicContent")[0].getElementsByTagName("li");
var nextChapter = document.getElementsByClassName("comicContent-next")[0].getElementsByTagName("a")[0].href;
var prevChapter = document.getElementsByClassName("comicContent-prev")[1].getElementsByTagName("a")[0].href;
if(nextChapter == location.href) nextChapter = "null";
if(prevChapter == location.href) prevChapter = "null";
var liststr = document.title.split(" - ")[1] + " " + location.href.substring(location.href.lastIndexOf("/")+1) + "\n" + nextChapter + "\n" + prevChapter;
for(var i = 0; i < imglist.length; i++) liststr += "\n" + imglist[i].getElementsByTagName("img")[0].dataset.src;
GM.loadChapter(liststr);
window.scroll({ top: document.body.scrollHeight, left: 0, behavior: 'smooth' });
setTimeout(() => {
window.scroll({ top: document.body.scrollHeight, left: 0, behavior: 'smooth' });
setTimeout(() => {
window.scroll({ top: document.body.scrollHeight, left: 0, behavior: 'smooth' });
var imglist = document.getElementsByClassName("container-fluid comicContent")[0].getElementsByTagName("li");
var nextChapter = document.getElementsByClassName("comicContent-next")[0].getElementsByTagName("a")[0].href;
var prevChapter = document.getElementsByClassName("comicContent-prev")[1].getElementsByTagName("a")[0].href;
if(nextChapter == location.href) nextChapter = "null";
if(prevChapter == location.href) prevChapter = "null";
var liststr = document.title.split(" - ")[1] + " " + location.href.substring(location.href.lastIndexOf("/")+1) + "\n" + nextChapter + "\n" + prevChapter;
for(var i = 0; i < imglist.length; i++) liststr += "\n" + imglist[i].getElementsByTagName("img")[0].dataset.src;
GM.loadChapter(liststr);
}, 500);
}, 500);
} else {
var json = Array();
var chapters = document.getElementsByClassName("upLoop")[0].children;

View File

@@ -45,6 +45,7 @@ class MainActivity: Activity() {
w.loadUrl(getString(R.string.web_home))
wh = JSWebView(this, getString(R.string.pc_ua))
wh?.webChromeClient = WebChromeClient()
wh?.setWebViewClient("h.js")
wh?.loadJSInterface(JSHidden())
}

View File

@@ -2,8 +2,9 @@ package top.fumiama.copymanga.web
import android.content.Context
import android.graphics.Bitmap
import android.net.http.SslError
import android.util.Log
import android.webkit.WebView
import android.webkit.*
import android.webkit.WebViewClient
import android.widget.Toast
import top.fumiama.copymanga.R
@@ -22,9 +23,20 @@ class WebViewClient(private val context: Context, jsFileName: String):WebViewCli
}
override fun onPageFinished(view: WebView?, url: String?) {
view?.loadUrl(js)
Log.d("MyWC", "Inject JS into: $url")
super.onPageFinished(view, url)
url?.let {
view?.postDelayed({view.loadUrl(js)}, 1000)
}
}
override fun onReceivedSslError(view: WebView?, handler: SslErrorHandler?, error: SslError?) {
handler?.proceed() // ignore ssl errors
}
override fun shouldInterceptRequest(
view: WebView?,
request: WebResourceRequest?
): WebResourceResponse? {
request?.requestHeaders?.set("Access-Control-Allow-Origin", "*")
return super.shouldInterceptRequest(view, request)
}
}