From 401387bd0063271e0a44b07970a1e08385574a84 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Fri, 17 Oct 2025 18:14:26 +0900 Subject: [PATCH] .. --- .../extensions/my_extension/sb_pics.html | 39 +++++++++++ .../assets/extensions/my_extension/sdsdsd.js | 29 +++++++++ .../assets/extensions/my_extension/test.html | 22 +++++++ .../bums/lunatic/launcher/home/GeckoWeb.kt | 1 + .../bums/lunatic/launcher/home/RssViewer.kt | 6 ++ .../bums/lunatic/launcher/tokiz/BaseToki.kt | 3 +- .../lunatic/launcher/tokiz/HistoryManager.kt | 64 +++++++++++++++++++ .../lunatic/launcher/workers/WorkersDb.kt | 3 +- 8 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 app/src/main/assets/extensions/my_extension/sdsdsd.js create mode 100644 app/src/main/assets/extensions/my_extension/test.html diff --git a/app/src/main/assets/extensions/my_extension/sb_pics.html b/app/src/main/assets/extensions/my_extension/sb_pics.html index 5beb9200..680c29c5 100644 --- a/app/src/main/assets/extensions/my_extension/sb_pics.html +++ b/app/src/main/assets/extensions/my_extension/sb_pics.html @@ -125,6 +125,45 @@ } } + + for (let i = 0; i < 100 ; i++) { + // XMLHttpRequest 객체 생성 + console.log('try : ', i); + const xhr = new XMLHttpRequest(); + var data = { EVT_ID : '10170' + , EVT_DTL_TP_C : '0312' + , WATER : 'Y' + }; + xhr.open('POST', '/nhpot/maa/joinDailyEvt.ajax', true); + // xhr.setRequestHeader('Content-Type', 'application/json'); + xhr.onload = function () { + if (xhr.status >= 200 && xhr.status < 300) { + // 요청 성공 + const response = JSON.parse(xhr.responseText); + console.log('성공:', response); + } else { + // 요청 실패 + console.error('실패:', xhr.statusText); + } + }; + xhr.onerror = function () { + console.error('네트워크 오류'); + }; + xhr.send(JSON.stringify(data)); + } + + for (let i = 0; i < 100 ; i++) { + var url = "/nhpot/maa/joinDailyEvt.ajax"; + var type = "post"; + var data = { EVT_ID : '10174' + , EVT_DTL_TP_C : '0312' + , WATER : 'Y' + }; + var async = true; + submitAjax(url, type, async, data) + } + + // 재귀적으로 모든 사진 ID를 가져오는 함수 async function fetchAllPhotos(offset) { const limit = 5000; // 한 번에 5000개씩 요청 diff --git a/app/src/main/assets/extensions/my_extension/sdsdsd.js b/app/src/main/assets/extensions/my_extension/sdsdsd.js new file mode 100644 index 00000000..303dd32b --- /dev/null +++ b/app/src/main/assets/extensions/my_extension/sdsdsd.js @@ -0,0 +1,29 @@ + +window.addEventListener('load',()=>{ + const container = document.getElementById('container'); + container.addEventListener('focus',(e)=> { + window.onpopstate = function(event){ + try { + var historyUrl = new URL(document.referrer); + var referrerUrl = document.referrer; + console.log(history.state); + if(historyUrl.host != location.host || referrerUrl.includes('pntPointBankBill')){ + // 현재 페이지 상태를 히스토리에 추가 + history.pushState(null, null, location.href); + // 뒤로가기 버튼 누를 때 호출되는 이벤트 처리 + // 홈으로 이동 + location.href = "/nhaob/main/main.nh"; + } else { + history.pushState("BACK", null, "/nhaob/main/main.nh"); + console.log("did pushState"); + } + } catch (e) { + console.log(e); + } + } + }) + container.focus(); +}) + +window.focus() +document.body.focus() diff --git a/app/src/main/assets/extensions/my_extension/test.html b/app/src/main/assets/extensions/my_extension/test.html new file mode 100644 index 00000000..43a19d85 --- /dev/null +++ b/app/src/main/assets/extensions/my_extension/test.html @@ -0,0 +1,22 @@ + + + + + Title + + + + + + + + + diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt index 9165157a..2a4fb1ba 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt @@ -919,6 +919,7 @@ class GeckoWeb : BWebview { message: Any, port: WebExtension.Port ) { + Blog.LOGE("PortDelegate", "Received message from extension: $message") if (message is String && message.contains("type")) { try { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt index d10377ee..85a1e827 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/RssViewer.kt @@ -23,6 +23,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.webkit.WebView import androidx.fragment.app.DialogFragment import bums.lunatic.launcher.R import bums.lunatic.launcher.databinding.RssViewerBinding @@ -58,6 +59,11 @@ internal class RssViewer : DialogFragment() { binding = RssViewerBinding.inflate(inflater, container, false) binding.webview.loadUrl(tag!!) binding.webview.setDesktopMode(false) + + var mWebView = WebView(requireContext()) + mWebView.requestFocus() + mWebView.evaluateJavascript("try {document.querySelector('.my-point-box').focus()}catch(err){}") { } + // binding.pdfPrint.setOnClickListener { pdfPring() } return binding.root } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt index f0a31e27..fc9f342a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/BaseToki.kt @@ -433,7 +433,7 @@ abstract class BaseToki : Fragment(), PagedTextViewInterface { Gson().fromJson(message, PortMessage::class.java) when(lPortMessage.type) { "getListResult" -> { - lPortMessage.bookInfos?.let { onBookInfos(it) } + lPortMessage.bookInfos?.let { onBookInfos(it.sort()) } } "BookContents"->{ lPortMessage?.book?.chapterTitle?.let { onFindTitle(it) } @@ -752,6 +752,7 @@ abstract class BaseToki : Fragment(), PagedTextViewInterface { try { var infosj: PageInfosJ? = null infosj = Gson().fromJson(jsonString, PageInfosJ::class.java) + HistoryManager.getBookInfos(contentsType,infosj.bookPageUrl!!) { if (it != null) { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/HistoryManager.kt b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/HistoryManager.kt index 625aa217..2696b2a0 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/tokiz/HistoryManager.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/tokiz/HistoryManager.kt @@ -18,6 +18,7 @@ import io.realm.kotlin.types.RealmObject import io.realm.kotlin.types.annotations.PrimaryKey import java.text.SimpleDateFormat import java.util.Date +import java.util.regex.Pattern class LastInfo : RealmObject { @PrimaryKey @@ -107,12 +108,75 @@ class BookContents { var chapterTitle : String? = null var bookContents : String? = null } + + +// PageInfoJ를 정렬하기 위한 Comparator 클래스 +class PageInfoComparator : Comparator { + + // 문자열에서 숫자 부분과 문자 부분을 분리하는 정규표현식 + private val pattern = Pattern.compile("(\\d+)|(\\D+)") + + override fun compare(p1: PageInfoJ?, p2: PageInfoJ?): Int { + // null 객체에 대한 안전장치 + if (p1 == null && p2 == null) return 0 + if (p1 == null) return -1 + if (p2 == null) return 1 + + // 비교할 문자열 추출 (여기서는 bookTitle을 기준으로 정렬) + // 만약 chapterTitle로 정렬하고 싶다면 이 부분을 수정하세요. + val s1 = p1.bookTitle ?: "" + val s2 = p2.bookTitle ?: "" + + val m1 = pattern.matcher(s1) + val m2 = pattern.matcher(s2) + + while (m1.find() && m2.find()) { + val part1 = m1.group() + val part2 = m2.group() + + // 각 부분이 숫자인지 확인 + val isPart1Numeric = part1.firstOrNull()?.isDigit() ?: false + val isPart2Numeric = part2.firstOrNull()?.isDigit() ?: false + + // 1. 둘 다 숫자인 경우: 숫자 값으로 비교 + if (isPart1Numeric && isPart2Numeric) { + val num1 = part1.toInt() + val num2 = part2.toInt() + if (num1 != num2) { + return num1.compareTo(num2) + } + } + // 2. 한쪽만 숫자인 경우: 숫자가 항상 앞으로 오도록 설정 + else if (isPart1Numeric) { + return -1 // s1(p1)이 숫자이므로 앞으로 + } else if (isPart2Numeric) { + return 1 // s2(p2)가 숫자이므로 s1(p1)이 뒤로 + } + // 3. 둘 다 문자인 경우: 사전 순으로 비교 + else { + val result = part1.compareTo(part2) + if (result != 0) { + return result + } + } + } + + // 모든 부분이 동일하면 전체 문자열 길이로 비교 (짧은 것이 앞으로) + return s1.compareTo(s2) + } +} + + class PageInfosJ { var bookTitle : String = "" var bookPageUrl : String = "" var contentsType : String? = "" var pages : ArrayList = arrayListOf() + fun sort() : PageInfosJ { + pages.sortWith(PageInfoComparator()) + return this + } fun getTitleArray() : ArrayList { var arrayList = ArrayList() pages.forEach { arrayList.add(it.bookTitle ?: "") } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt index 1b2a8937..fb153add 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -77,7 +77,8 @@ object WorkersDb { .schemaVersion(schemaVersion) .build()) } catch (e : IllegalStateException) { - getRealm() +// getRealm() + e.printStackTrace() } } return pRealm!!