mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-09-19 23:21:34 +02:00
Improve menu loading when going back
This commit is contained in:
parent
c28973319d
commit
ba458a6126
@ -61,20 +61,4 @@ class WebFragment : BaseFragment() {
|
||||
}
|
||||
super.updateFab(contract)
|
||||
}
|
||||
|
||||
override fun onBackPressed(): Boolean {
|
||||
if (baseEnum == FbItem.MENU) {
|
||||
val core = core
|
||||
val web = core as? WebView
|
||||
if (web != null && web.canGoBack() && !web.canGoBackOrForward(-2)) {
|
||||
// If menu item + we are at the second last entry, reload the base
|
||||
// To properly inflate the menu
|
||||
// Related to https://github.com/AllanWang/Frost-for-Facebook/issues/1593
|
||||
core.clearHistory()
|
||||
core.reloadBase(true)
|
||||
return true
|
||||
}
|
||||
}
|
||||
return super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,12 @@ import com.pitchedapps.frost.prefs.Prefs
|
||||
* Small misc inline css assets
|
||||
*/
|
||||
enum class CssAsset(private val content: String) : InjectorContract {
|
||||
FullSizeImage("div._4prr[style*=\"max-width\"][style*=\"max-height\"]{max-width:none !important;max-height:none !important}")
|
||||
FullSizeImage("div._4prr[style*=\"max-width\"][style*=\"max-height\"]{max-width:none !important;max-height:none !important}"),
|
||||
|
||||
/*
|
||||
* Remove top margin and hide some contents from the top bar and notification page (as it's our base url)
|
||||
*/
|
||||
Menu("#bookmarks_flyout{margin-top:0 !important}#notifications_list{display:none !important}")
|
||||
;
|
||||
|
||||
val injector: JsInjector by lazy {
|
||||
|
@ -34,7 +34,7 @@ import java.util.Locale
|
||||
* The enum name must match the css file name
|
||||
*/
|
||||
enum class JsAssets(private val singleLoad: Boolean = true) : InjectorContract {
|
||||
MENU, CLICK_A, CONTEXT_A, MEDIA, HEADER_BADGES, TEXTAREA_LISTENER, NOTIF_MSG,
|
||||
MENU, MENU_QUICK(singleLoad = false), CLICK_A, CONTEXT_A, MEDIA, HEADER_BADGES, TEXTAREA_LISTENER, NOTIF_MSG,
|
||||
DOCUMENT_WATCHER, HORIZONTAL_SCROLLING, AUTO_RESIZE_TEXTAREA(singleLoad = false), SCROLL_STOP,
|
||||
;
|
||||
|
||||
|
@ -302,7 +302,7 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) {
|
||||
* Instead, we remove the flyout margins within the js script so that it covers the header.
|
||||
*/
|
||||
override val facebookJsInjectors: List<InjectorContract> =
|
||||
super.facebookJsInjectors - CssHider.HEADER
|
||||
super.facebookJsInjectors - CssHider.HEADER + CssAsset.Menu
|
||||
|
||||
override fun emit(flag: Int) {
|
||||
super.emit(flag)
|
||||
@ -313,6 +313,17 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Facebook doesn't properly load back to the menu even in standard browsers.
|
||||
* Instead, if we detect the base soft url, we will manually click the menu item
|
||||
*/
|
||||
override fun doUpdateVisitedHistory(view: WebView, url: String?, isReload: Boolean) {
|
||||
super.doUpdateVisitedHistory(view, url, isReload)
|
||||
if (url?.startsWith(FbItem.MENU.url) == true) {
|
||||
jsInject(JsAssets.MENU_QUICK, prefs = prefs)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPageFinishedActions(url: String) {
|
||||
// Skip
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
v3.1.2
|
||||
|
||||
* Fix loading full size images
|
||||
* Fix loading full size images
|
||||
* Fix menu tab
|
@ -8,7 +8,7 @@
|
||||
|
||||
<version title="v3.1.2" />
|
||||
<item text="Fix loading full size images" />
|
||||
<item text="" />
|
||||
<item text="Fix menu tab" />
|
||||
<item text="" />
|
||||
|
||||
<version title="v3.1.1" />
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Click menu and move contents to main view
|
||||
// Click menu after delay and notify
|
||||
(function () {
|
||||
const viewport = document.querySelector("#viewport");
|
||||
const root = document.querySelector("#root");
|
||||
@ -20,12 +20,6 @@
|
||||
return
|
||||
}
|
||||
|
||||
// menu container
|
||||
const bookmarkFlyout = document.querySelector('#bookmarks_flyout');
|
||||
if (bookmarkFlyout instanceof HTMLElement) {
|
||||
bookmarkFlyout.style.marginTop = "0";
|
||||
}
|
||||
|
||||
// Js handling is a bit slow so we need to wait
|
||||
setTimeout(() => {
|
||||
menuA.click();
|
||||
@ -34,5 +28,5 @@
|
||||
setTimeout(() => {
|
||||
Frost.emit(0);
|
||||
}, 100);
|
||||
}, 200);
|
||||
}, 500);
|
||||
}).call(undefined);
|
||||
|
24
app/src/web/ts/menu_quick.ts
Normal file
24
app/src/web/ts/menu_quick.ts
Normal file
@ -0,0 +1,24 @@
|
||||
// Copy of menu.ts without timeouts or notifications
|
||||
(function () {
|
||||
const viewport = document.querySelector("#viewport");
|
||||
const root = document.querySelector("#root");
|
||||
const bookmarkJewel = document.querySelector("#bookmarks_jewel");
|
||||
if (!viewport || !root || !bookmarkJewel) {
|
||||
console.log('Menu.js: main elements not found');
|
||||
Frost.emit(0);
|
||||
return
|
||||
}
|
||||
const menuA = bookmarkJewel.querySelector("a");
|
||||
if (!menuA) {
|
||||
console.log('Menu.js: menu links not found');
|
||||
Frost.emit(0);
|
||||
return
|
||||
}
|
||||
const jewel = document.querySelector('#mJewelNav');
|
||||
if (!jewel) {
|
||||
console.log('Menu.js: jewel is null');
|
||||
return
|
||||
}
|
||||
|
||||
menuA.click();
|
||||
}).call(undefined);
|
@ -2,6 +2,7 @@
|
||||
|
||||
## v3.1.2
|
||||
* Fix loading full size images
|
||||
* Fix menu tab
|
||||
|
||||
## v3.1.1
|
||||
* Many internal fixes to address 3.1.0 issues
|
||||
|
Loading…
Reference in New Issue
Block a user