From 668d33543c28f5fe66811dd20fa097a30b1a5b69 Mon Sep 17 00:00:00 2001 From: lunaticbum Date: Wed, 23 Jul 2025 18:12:30 +0900 Subject: [PATCH] .. --- .../extensions/my_extension/messaging.js | 65 +++++++++++++------ .../bums/lunatic/launcher/home/GeckoWeb.kt | 11 +++- .../bums/lunatic/launcher/home/RssHome.kt | 47 +++++++++++--- .../lunatic/launcher/model/CommunityData.kt | 40 +++++++++--- .../bums/lunatic/launcher/model/NewsData.kt | 6 ++ .../launcher/model/RssDataInterface.kt | 2 + .../lunatic/launcher/model/others/Reddit.kt | 7 ++ .../launcher/model/others/YoutubeData.kt | 14 ++++ .../lunatic/launcher/workers/WorkersDb.kt | 45 ++++++------- .../main/res/layout/layout_rss_summary.xml | 56 ++++++++++------ 10 files changed, 211 insertions(+), 82 deletions(-) diff --git a/app/src/main/assets/extensions/my_extension/messaging.js b/app/src/main/assets/extensions/my_extension/messaging.js index f9c3b99a..aa05c2c1 100644 --- a/app/src/main/assets/extensions/my_extension/messaging.js +++ b/app/src/main/assets/extensions/my_extension/messaging.js @@ -1,4 +1,3 @@ -const list = ["?page=2","?page=3","?page=4","?page=5","?page=6"]; const port = browser.runtime.connectNative("browser"); port.onMessage.addListener(response => { var type= response["type"]; @@ -237,9 +236,9 @@ function sendMessage(msg) { function toast(msg) { port.postMessage(JSON.stringify({type:"MSG",msg:msg})); } - +var time1 = null if (port) { - setTimeout( + time1 = setTimeout( function(){ if (location.hostname.search("clien") > -1 && document.querySelectorAll('[class^="view_top"]')) { document.querySelectorAll('[class^="view_top"]').forEach(e => e.remove()) @@ -342,7 +341,11 @@ if (port) { var title = ""; try { - title = e.querySelector(".name").querySelector("a").querySelector("span").textContent.trim(); + e.querySelector(".name").querySelector("a").querySelectorAll("span").forEach(function (e) { + if (e.hasAttribute("class") == false) { + title = e.textContent.trim(); + } + }) }catch (e) { } @@ -367,10 +370,10 @@ if (port) { "title" : title, "description" : desc, "originPage" : originPage, - "magnet" : magnet, + "magnet_link" : magnet, "thumbnail" : thumb, "pubDate" : date, - "screenshots" : screenshots, + "screenshotsUrl" : screenshots, "chosung" : "", "category" : "PRIVATE" }); @@ -387,24 +390,48 @@ if (port) { },1500) } - +var targetUrl = "" +var time2 = null function gotoNext() { - if (location.href.search("page") < 0) { - targetUrl = location.protocol + "//" + location.hostname + "/" + list[0] - }else { - var targetUrl = "" - for (i = 0; i < list.length - 1; i++) { + clearTimeout(time1) + try{ + + var url = new URL(location.href); + var params = url.searchParams; + var keys = Array.from(params.keys()); + console.log("targetUrl :: " + params); + console.log("targetUrl :: " + keys.length); + if (keys.length === 0 && location.href.search("page") < 0) { + targetUrl = location.protocol + "//" + location.hostname + "/?page=2" + } else { try { - if (location.href.search(list[i]) > -1) { - targetUrl = location.protocol + "//" + location.hostname + list[i + 1] + var lastValue = params.get("page"); + console.log("targetUrl :: " + lastValue); + var numValue = Number(lastValue); + console.log("targetUrl :: " + numValue); + if (numValue < Number("5")) { + params.set("page", (numValue + 1).toString()); + console.log("targetUrl :: " + params); + url.search = params.toString(); + console.log("targetUrl :: " + url.search); + targetUrl = url.toString(); + } else { + console.log("targetUrl :: "); } - }catch (e) { + } catch (e) { console.error(e) } - } - } - if (targetUrl.length > 5) { - setTimeout(function () {location.href = targetUrl},3000) + console.log("targetUrl :: " + targetUrl); + time2 = setTimeout(function () { + clearTimeout(time2) + if (targetUrl.length > 5) { + console.log("targetUrl :: " + targetUrl); + location.href = targetUrl + } + }, 5000); + + } catch (e) { + } } \ No newline at end of file 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 15b61fe8..5cb1cb6f 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/GeckoWeb.kt @@ -36,7 +36,9 @@ import bums.lunatic.launcher.tokiz.view.JxEvent import bums.lunatic.launcher.utils.Blog import bums.lunatic.launcher.utils.afterDay import bums.lunatic.launcher.workers.WorkersDb +import bums.lunatic.launcher.workers.WorkersDb.getRealm import com.google.gson.Gson +import io.realm.kotlin.UpdatePolicy import org.json.JSONException import org.json.JSONObject import org.jsoup.Jsoup @@ -472,9 +474,14 @@ class GeckoWeb : BWebview { } "PRIVATES"->{ lPortMessage.privates?.forEach { - Blog.LOGE("Item screenshots >>> ${it.screenshots}") + Blog.LOGE("Item screenshots >>> ${it.getScreen()}") it.pubDate = afterDay(it.pubDate) - WorkersDb.insertData(it) +// WorkersDb.insertData(it) + getRealm().apply { + this.writeBlocking { + copyToRealm(it, UpdatePolicy.ALL) + } + } } } "PagerContents" -> { diff --git a/app/src/main/kotlin/bums/lunatic/launcher/home/RssHome.kt b/app/src/main/kotlin/bums/lunatic/launcher/home/RssHome.kt index 5735ca7c..965c6027 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/home/RssHome.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/home/RssHome.kt @@ -59,8 +59,11 @@ import bums.lunatic.launcher.utils.SimpleFingerGestures import bums.lunatic.launcher.utils.beforeDay import bums.lunatic.launcher.utils.beforeOneDay import bums.lunatic.launcher.workers.WorkersDb +import bums.lunatic.launcher.workers.WorkersDb.prvClear import com.bumptech.glide.Glide +import com.bumptech.glide.load.engine.DiskCacheStrategy import com.google.android.material.imageview.ShapeableImageView +import com.google.gson.Gson import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.ext.query import io.realm.kotlin.notifications.InitialResults @@ -268,13 +271,34 @@ internal class RssHome : Fragment() { } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { - lasted?.removeFirst()?.let { - binding.layoutRssSummary.root.visibility = View.VISIBLE - binding.layoutRssSummary.title.text = it.title() - binding.layoutRssSummary.desc.text = it.description() - binding.layoutRssSummary.link.text = it.originPage() - loadImage(binding.layoutRssSummary.cover,it.thumbnailUrl()) - loadImage(binding.layoutRssSummary.screen,it.getScreen()) + if (lasted.size > 0) { + lasted?.removeFirst()?.let { + Blog.LOGE("removeFirst >>> ${Gson().toJson(it)}") + binding.layoutRssSummary.root.visibility = View.VISIBLE + it.title()?.let { + Blog.LOGE(it) + binding.layoutRssSummary.title.text = it + } + + it.description()?.let { + Blog.LOGE(it) + binding.layoutRssSummary.desc.text = it + } + it.getMagnet().let { + Blog.LOGE(it) + binding.layoutRssSummary.link.text = it + } + it.thumbnailUrl().let { + Blog.LOGE(it) + loadImage(binding.layoutRssSummary.cover, it) + } + it.getScreen().let { + Blog.LOGE(it) + loadImage(binding.layoutRssSummary.screen, it) + } + } + } else { + binding.home.performClick() } } @@ -360,6 +384,10 @@ internal class RssHome : Fragment() { binding.prv.setOnClickListener { queryPrevate() } + binding.layoutRssSummary.close.setOnClickListener { + binding.home.performClick() + } + queryInfos() binding.geckoWeb.progress = binding.progressBar binding.geckoWeb.jxInteface = { jxEvent -> @@ -598,14 +626,15 @@ fun loadImage(imageView: ImageView, url: String?) { Blog.LOGE("loadImage >>> $it") Glide.with(imageView.context) .load(url) + .diskCacheStrategy(DiskCacheStrategy.ALL) .fitCenter() .into(imageView) imageView.visibility = View.VISIBLE } else { - imageView.visibility = View.GONE + imageView.visibility = View.INVISIBLE } } ?: { - imageView.visibility = View.GONE + imageView.visibility = View.INVISIBLE } } diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt index 481cf866..08d517b5 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/CommunityData.kt @@ -39,6 +39,14 @@ class Clien : DcInside() { } class Arca : RssDataInterface { + override fun getScreen(): String { + return "" + } + + override fun getMagnet(): String { + return "" + } + var link : String? = null var title : String? = null var thumbnail : String? = null @@ -160,6 +168,14 @@ open class DcInside : RssDataInterface { return desc ?: "" } + override fun getScreen(): String { + return "" + } + + override fun getMagnet(): String { + return "" + } + override fun pubDate(): Long { if (dateTiemL < 1L) { if (dateTiem?.length ?: 0 < 1) return 0L @@ -219,11 +235,15 @@ class RssData : RealmObject, RssDataInterface { var thumbnail : String? = null var pubDate : Long = 0L var category : String? = null - var magnet : String? = null - var screenshots : String? = null - fun getScreen() : String { - Blog.LOGE("getScreen $screenshots") - return screenshots ?: "" + var magnet_link : String? = null + var screenshotsUrl : String? = null + + override fun getScreen() : String { + return screenshotsUrl ?: "" + } + + override fun getMagnet(): String { + return magnet_link ?: "" } var chosung : String? = null @@ -239,18 +259,15 @@ class RssData : RealmObject, RssDataInterface { } else -> title ?: "" }.apply { - Blog.LOGE("title $this") chosung = JamoUtils.split(title).joinToString("") } } override fun thumbnailUrl(): String { - Blog.LOGE("thumbnail $thumbnail") return thumbnail ?: "" } override fun originPage(): String { - Blog.LOGE("originPage $originPage") return originPage ?: "" } @@ -288,6 +305,13 @@ open class Dotax(var pageLink : String, var dateTime : String, var title : String, var thumbnail : String) : RssDataInterface { + override fun getScreen(): String { + return "" + } + + override fun getMagnet(): String { + return "" + } var updateDateTime = 0L override fun title(): String { return title diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt index d2fa89cb..1ab94919 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/NewsData.kt @@ -3,7 +3,13 @@ package bums.lunatic.launcher.model import bums.lunatic.launcher.utils.JamoUtils class NewsData : RssDataInterface { + override fun getScreen(): String { + return "" + } + override fun getMagnet(): String { + return "" + } var title : String? = "" var link : String? = "" var guid : String? = "" diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt index 3883f056..e11c681a 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/RssDataInterface.kt @@ -69,4 +69,6 @@ interface RssDataInterface { fun pubDate() : Long fun category() : RssDataType fun getCho() : String? + fun getScreen() : String + fun getMagnet() : String } \ No newline at end of file diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt index 95cfe955..8b3baced 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/others/Reddit.kt @@ -124,6 +124,13 @@ class CrosspostParentList { } class Data : RssDataInterface { + override fun getScreen(): String { + return "" + } + + override fun getMagnet(): String { + return "" + } var after: String? = null var dist: Int = 0 var modhash: String? = null diff --git a/app/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt b/app/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt index 7d1b38fa..27e0e3cc 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/model/others/YoutubeData.kt @@ -506,6 +506,13 @@ class GridChannelRenderer { } class GridVideoRenderer : VideoRenderer() { + override fun getScreen(): String { + return "" + } + + override fun getMagnet(): String { + return "" + } // var videoId: String? = null // var thumbnail: Thumbnail? = null // var title: Title? = null @@ -1567,6 +1574,13 @@ class VideoCountText { } open class VideoRenderer : RssDataInterface { + override fun getScreen(): String { + return "" + } + + override fun getMagnet(): String { + return "" + } var videoId: String? = null var thumbnail: Thumbnail? = null var title: Title? = null 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 57920718..ef4d5a00 100644 --- a/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt +++ b/app/src/main/kotlin/bums/lunatic/launcher/workers/WorkersDb.kt @@ -51,15 +51,16 @@ import java.util.regex.Pattern import kotlin.reflect.KClass class CustMigration : AutomaticSchemaMigration { - override fun migrate(migrationContext: AutomaticSchemaMigration.MigrationContext) { - Blog.LOGE(migrationContext.oldRealm.configuration.schemaVersion.toString()) - Blog.LOGE(migrationContext.newRealm.configuration.schemaVersion.toString()) - } - } + override fun migrate(migrationContext: AutomaticSchemaMigration.MigrationContext) { + Blog.LOGE(migrationContext.oldRealm.configuration.schemaVersion.toString()) + Blog.LOGE(migrationContext.newRealm.configuration.schemaVersion.toString()) + } +} object WorkersDb { - val clazz : Set> = setOf(RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class, + val clazz : Set> = setOf( + RssData::class, NotificationItem::class, AppInfo::class,SimpleContact::class, RecentCall::class, RecentSms::class, CurrentPlayItem::class, TelegramBotUpdate::class, TelegramData::class, TelegramMessage::class, TelegramChat::class, BotCommandEentitie::class, TelegramFrom::class, WeatherForcast::class, Location::class, Current::class, Forecast::class, Condition::class, Forecastday::class, Day::class, Astro::class, Hour::class, LocationLog::class, @@ -88,21 +89,11 @@ object WorkersDb { getRealm().apply { this.writeBlocking { try { - if (rssData.category().equals(RssDataType.PRIVATE)) { - this.copyToRealm(rssData, UpdatePolicy.ALL) - Blog.LOGE("rssData >> $rssData ${rssData.getScreen()}") - } else { - if (query("originPage == $0", rssData.originPage).find() - .isEmpty() - ) { - this.copyToRealm(rssData, UpdatePolicy.ERROR) - } + if (query("originPage == $0", rssData.originPage).find() + .isEmpty() + ) { + this.copyToRealm(rssData, UpdatePolicy.ERROR) } - try { - query("originPage == $0",rssData.originPage).find()?.first()?.let { - Blog.LOGE("SAVED CHECK ${Gson().toJson(this.copyFromRealm(it))}") - } - }catch (e: Exception) {e.printStackTrace()} } catch (e : Exception) { } @@ -110,7 +101,7 @@ object WorkersDb { } } -// val blockKeyword = arrayListOf("붕괴 스타레일","붕괴 스타일","트릭컬 RE:VIVE","원신","메이플스토리","") + // val blockKeyword = arrayListOf("붕괴 스타레일","붕괴 스타일","트릭컬 RE:VIVE","원신","메이플스토리","") fun insertBulkData(rssDatas: Collection) { rssDatas.forEach { try { @@ -120,7 +111,7 @@ object WorkersDb { if (query("originPage == $0", t.originPage).find().isEmpty()) { // val catfillters = arrayListOf(RssDataType.THEQOO,RssDataType.RULIWEB,RssDataType.ARCA,RssDataType.CLIEN,RssDataType.FMKORAE,RssDataType.DOTAX,RssDataType.DCINSIDE) // if(catfillters.contains(it.category()) && query("chosung == $0",it.chosung).find().size == 0) { - this.copyToRealm(t, UpdatePolicy.ERROR) + this.copyToRealm(t, UpdatePolicy.ERROR) // } else if(!catfillters.contains(it.category())){ // this.copyToRealm(it, UpdatePolicy.ERROR) // } else { @@ -188,7 +179,7 @@ object WorkersDb { try { this.copyToRealm(contact, UpdatePolicy.ALL) } catch (e : Exception) { - e.printStackTrace() + e.printStackTrace() } } } @@ -225,7 +216,13 @@ object WorkersDb { } } } - + fun prvClear() { + getRealm().writeBlocking { + var results = query().query("category == $0 ", + RssDataType.PRIVATE.name).find() + delete(results) + } + } fun getPrivate() = getRealm().query().query("category == $0 ", RssDataType.PRIVATE.name).distinct("originPage", "title").sort("pubDate", Sort.DESCENDING) diff --git a/app/src/main/res/layout/layout_rss_summary.xml b/app/src/main/res/layout/layout_rss_summary.xml index 61a1687c..3c79b23b 100644 --- a/app/src/main/res/layout/layout_rss_summary.xml +++ b/app/src/main/res/layout/layout_rss_summary.xml @@ -8,61 +8,77 @@ name="rss" type="bums.lunatic.launcher.model.RssData" /> - - + android:layout_height="wrap_content"/> + android:layout_height="wrap_content"/> - + android:layout_height="wrap_content"/> + - + + \ No newline at end of file