From 9363d4bc987cb7b4886ffb6a863b5d14c602e402 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 7 Sep 2019 18:15:53 -0700 Subject: Remove desktop and mobile user agent def --- .../kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt | 4 ++-- app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt | 10 ++++++++-- .../com/pitchedapps/frost/facebook/requests/FbRequest.kt | 4 ++-- app/src/main/kotlin/com/pitchedapps/frost/utils/Downloader.kt | 6 +++--- app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 9 +++++---- .../main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt | 9 ++------- app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | 4 ++-- .../com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt | 1 + app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt | 4 ++-- 9 files changed, 27 insertions(+), 24 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt index 8215de03..bc453250 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/debugger/OfflineWebsite.kt @@ -19,7 +19,7 @@ package com.pitchedapps.frost.debugger import ca.allanwang.kau.logging.KauLoggerExtension import ca.allanwang.kau.utils.copyFromInputStream import com.pitchedapps.frost.facebook.FB_CSS_URL_MATCHER -import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP +import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.facebook.requests.call import com.pitchedapps.frost.utils.createFreshDir @@ -59,7 +59,7 @@ class OfflineWebsite( * Directory that holds all the files */ val baseDir: File, - private val userAgent: String = USER_AGENT_DESKTOP + private val userAgent: String = USER_AGENT ) { /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt index 032ff31e..c01bce55 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbConst.kt @@ -28,6 +28,13 @@ fun profilePictureUrl(id: Long) = "https://graph.facebook.com/$id/picture?type=l const val FB_LOGIN_URL = "${FB_URL_BASE}login" const val FB_HOME_URL = "${FB_URL_BASE}home.php" +/* + * User agent candidates. + * For those building from source, you can feel free to set the used agent to one of these options. + * Following https://github.com/AllanWang/Frost-for-Facebook/pull/1531, we do not support multiple + * agents per login session. + */ + // Default user agent private const val USER_AGENT_MOBILE_CONST = "Mozilla/5.0 (Linux; Android 8.0.0; ONEPLUS A3000) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Mobile Safari/537.36" @@ -35,8 +42,7 @@ private const val USER_AGENT_MOBILE_CONST = private const val USER_AGENT_DESKTOP_CONST = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.90 Safari/537.36" -const val USER_AGENT_MOBILE = USER_AGENT_DESKTOP_CONST -const val USER_AGENT_DESKTOP = USER_AGENT_DESKTOP_CONST +const val USER_AGENT = USER_AGENT_DESKTOP_CONST /** * Animation transition delay, just to ensure that the styles diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt index 8a89b973..b948506f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt @@ -22,7 +22,7 @@ import com.pitchedapps.frost.facebook.FB_JSON_URL_MATCHER import com.pitchedapps.frost.facebook.FB_REV_MATCHER import com.pitchedapps.frost.facebook.FB_URL_BASE import com.pitchedapps.frost.facebook.FB_USER_MATCHER -import com.pitchedapps.frost.facebook.USER_AGENT_DESKTOP +import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.kotlin.Flyweight import com.pitchedapps.frost.utils.L @@ -97,7 +97,7 @@ internal fun List>.withEmptyData(vararg key: String): List = setOf(FbItem.MESSAGES, FbItem.CHAT, FbItem.FEED_MOST_RECENT, FbItem.FEED_TOP_STORIES) .mapTo(mutableSetOf(), FbItem::url) +@Deprecated(message = "Should not be used in production as we only support one user agent at a time.") val String.shouldUseDesktopAgent: Boolean get() = when { contains("story.php") -> false // do not use desktop for comment section diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt index 8e437c29..857c166d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -33,7 +33,7 @@ import com.pitchedapps.frost.db.CookieEntity import com.pitchedapps.frost.facebook.FB_LOGIN_URL import com.pitchedapps.frost.facebook.FB_USER_MATCHER import com.pitchedapps.frost.facebook.FbCookie -import com.pitchedapps.frost.facebook.USER_AGENT_MOBILE +import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.jsInject @@ -58,7 +58,7 @@ class LoginWebView @JvmOverloads constructor( @SuppressLint("SetJavaScriptEnabled") private fun setupWebview() { settings.javaScriptEnabled = true - settings.userAgentString = USER_AGENT_MOBILE + settings.userAgentString = USER_AGENT setLayerType(View.LAYER_TYPE_HARDWARE, null) webViewClient = LoginClient() webChromeClient = LoginChromeClient() -- cgit v1.2.3