Skip to content

Commit

Permalink
fix: FxxkQQBrowser when open preview link
Browse files Browse the repository at this point in the history
  • Loading branch information
HdShare committed Nov 16, 2024
1 parent ceb89f4 commit 7f8780b
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_DARK
import androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT
import cc.ioctl.hook.misc.JumpController
import io.github.qauxv.util.xpcompat.XC_MethodHook
import io.github.qauxv.base.annotation.UiItemAgentEntry
import io.github.qauxv.dsl.FunctionEntryRouter
import io.github.qauxv.router.decorator.BaseSwitchFunctionDecorator
import io.github.qauxv.router.decorator.IStartActivityHookDecorator
import io.github.qauxv.router.dispacher.StartActivityHook
import io.github.qauxv.ui.ResUtils
import io.github.qauxv.util.hostInfo
import io.github.qauxv.util.xpcompat.XC_MethodHook
import java.util.regex.Pattern

@UiItemAgentEntry
object FxxkQQBrowser : BaseSwitchFunctionDecorator(), IStartActivityHookDecorator {
Expand All @@ -47,7 +48,9 @@ object FxxkQQBrowser : BaseSwitchFunctionDecorator(), IStartActivityHookDecorato
override val description = "致敬 “去你大爷的内置浏览器”"
override val uiItemLocation = FunctionEntryRouter.Locations.Simplify.UI_MISC
override val dispatcher = StartActivityHook

const val EXTRA_BYPASS_FQB_HOOK = "me.singleneuron.hook.decorator.EXTRA_BYPASS_FQB_HOOK"
private const val URL_REGEX = "^(https?|ftp)://[^\\s/$.?#].[^\\s]*$|^www\\.[^.]+\\.[^.]+$|^[^.]+\\.[^.]+$"

@SuppressLint("ResourceType")
override fun onStartActivityIntent(intent: Intent, param: XC_MethodHook.MethodHookParam): Boolean {
Expand All @@ -59,7 +62,7 @@ object FxxkQQBrowser : BaseSwitchFunctionDecorator(), IStartActivityHookDecorato
val check3 = intent.component?.shortClassName?.contains("QQBrowserActivity")
Log.d("check1=$check1 check2=$check2 check3=$check3")*/
return if (!url.isNullOrBlank()
&& url.lowercase().let { it.startsWith("http://") || it.startsWith("https://") }
&& url.lowercase().let { Pattern.compile(URL_REGEX).matcher(it).matches() }
&& !shouldUseInternalBrowserForUrl(url)
&& intent.component?.shortClassName?.contains("QQBrowserActivity") == true
) {
Expand Down Expand Up @@ -89,7 +92,10 @@ object FxxkQQBrowser : BaseSwitchFunctionDecorator(), IStartActivityHookDecorato
putExtra(JumpController.EXTRA_JMP_JEFS_PERMISSIVE, true)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
customTabsIntent.launchUrl(hostInfo.application, Uri.parse(url))
customTabsIntent.launchUrl(
hostInfo.application,
Uri.parse(if (!url.startsWith("http://") && !url.startsWith("https://")) "http://$url" else url)
)
param.result = null
true
} else {
Expand Down

0 comments on commit 7f8780b

Please sign in to comment.