aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-30 13:35:38 -0400
committerGitHub <noreply@github.com>2017-08-30 13:35:38 -0400
commita095623d23e6d90233fc3d21e905f773b4c12a1b (patch)
tree02adb88de4c88d2a03ee4efddc9683616450bf4a /app/src
parent270ff7705be5ec0c78f5eae4934779ff4b4c00ee (diff)
downloadfrost-a095623d23e6d90233fc3d21e905f773b4c12a1b.tar.gz
frost-a095623d23e6d90233fc3d21e905f773b4c12a1b.tar.bz2
frost-a095623d23e6d90233fc3d21e905f773b4c12a1b.zip
Add debugging for menu (#242)
* Add base for menu debugging * Add debug js
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/assets/js/menu.min.js3
-rw-r--r--app/src/main/assets/js/menu_debug.js46
-rw-r--r--app/src/main/assets/js/menu_debug.min.js34
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt2
-rw-r--r--app/src/main/res/xml/frost_changelog.xml2
6 files changed, 86 insertions, 3 deletions
diff --git a/app/src/main/assets/js/menu.min.js b/app/src/main/assets/js/menu.min.js
index 5b65ac9b..df51c13b 100644
--- a/app/src/main/assets/js/menu.min.js
+++ b/app/src/main/assets/js/menu.min.js
@@ -17,7 +17,8 @@ var o=document.querySelector(".mSideMenu")
for(x.disconnect(),console.log("Found side menu");root.firstChild;)root.removeChild(root.firstChild)
;for(;o.childNodes.length;)console.log("append"),
viewport.appendChild(o.childNodes[0])
-;"undefined"!=typeof Frost&&Frost.emit(0),setTimeout(function(){
+;"undefined"!=typeof Frost&&Frost.handleHtml(viewport.outerHTML),
+setTimeout(function(){
y.disconnect(),console.log("Unhook styler")
},500)
}
diff --git a/app/src/main/assets/js/menu_debug.js b/app/src/main/assets/js/menu_debug.js
new file mode 100644
index 00000000..552dc909
--- /dev/null
+++ b/app/src/main/assets/js/menu_debug.js
@@ -0,0 +1,46 @@
+//click menu and move contents to main view
+if (!window.hasOwnProperty('frost_menu')) {
+ console.log('Registering frost_menu');
+ window.frost_menu = true;
+ var viewport = document.querySelector('#viewport');
+ var root = document.querySelector('#root');
+ if (!viewport) console.log('Menu.js: viewport is null');
+ if (!root) console.log('Menu.js: root is null');
+ var y = new MutationObserver(function(mutations) {
+ viewport.removeAttribute('style');
+ root.removeAttribute('style');
+ });
+ y.observe(viewport, {
+ attributes: true
+ });
+ y.observe(root, {
+ attributes: true
+ });
+ var x = new MutationObserver(function(mutations) {
+ var menu = document.querySelector('.mSideMenu');
+ if (menu !== null) {
+ x.disconnect();
+ console.log('Found side menu');
+ while (root.firstChild)
+ root.removeChild(root.firstChild);
+ while (menu.childNodes.length) {
+ console.log('append');
+ viewport.appendChild(menu.childNodes[0]);
+ }
+ if (typeof Frost !== 'undefined') Frost.handleHtml(viewport.outerHTML);
+ setTimeout(function() {
+ y.disconnect();
+ console.log('Unhook styler');
+ }, 500);
+ }
+ });
+ var jewel = document.querySelector('#mJewelNav');
+ if (!jewel) console.log('Menu.js: jewel is null');
+ x.observe(jewel, {
+ childList: true,
+ subtree: true
+ });
+ var menuA = document.querySelector('#bookmarks_jewel').querySelector('a');
+ if (!menuA) console.log('Menu.js: jewel is null')
+ menuA.click();
+}
diff --git a/app/src/main/assets/js/menu_debug.min.js b/app/src/main/assets/js/menu_debug.min.js
new file mode 100644
index 00000000..df51c13b
--- /dev/null
+++ b/app/src/main/assets/js/menu_debug.min.js
@@ -0,0 +1,34 @@
+if(!window.hasOwnProperty("frost_menu")){
+console.log("Registering frost_menu"),window.frost_menu=!0
+;var viewport=document.querySelector("#viewport"),root=document.querySelector("#root")
+;viewport||console.log("Menu.js: viewport is null"),
+root||console.log("Menu.js: root is null")
+;var y=new MutationObserver(function(e){
+viewport.removeAttribute("style"),root.removeAttribute("style")
+})
+;y.observe(viewport,{
+attributes:!0
+}),y.observe(root,{
+attributes:!0
+})
+;var x=new MutationObserver(function(e){
+var o=document.querySelector(".mSideMenu")
+;if(null!==o){
+for(x.disconnect(),console.log("Found side menu");root.firstChild;)root.removeChild(root.firstChild)
+;for(;o.childNodes.length;)console.log("append"),
+viewport.appendChild(o.childNodes[0])
+;"undefined"!=typeof Frost&&Frost.handleHtml(viewport.outerHTML),
+setTimeout(function(){
+y.disconnect(),console.log("Unhook styler")
+},500)
+}
+}),jewel=document.querySelector("#mJewelNav")
+;jewel||console.log("Menu.js: jewel is null"),
+x.observe(jewel,{
+childList:!0,
+subtree:!0
+})
+;var menuA=document.querySelector("#bookmarks_jewel").querySelector("a")
+;menuA||console.log("Menu.js: jewel is null"),
+menuA.click()
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
index 27b0f92a..b4ce05a5 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt
@@ -11,7 +11,7 @@ import java.util.*
* The enum name must match the css file name
*/
enum class JsAssets : InjectorContract {
- MENU, CLICK_A, CONTEXT_A, HEADER_BADGES, SEARCH, TEXTAREA_LISTENER, NOTIF_MSG
+ MENU, MENU_DEBUG, CLICK_A, CONTEXT_A, HEADER_BADGES, SEARCH, TEXTAREA_LISTENER, NOTIF_MSG
;
var file = "${name.toLowerCase(Locale.CANADA)}.min.js"
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
index f8dc81d1..3375a444 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Debug.kt
@@ -14,6 +14,7 @@ import com.pitchedapps.frost.facebook.FbItem
import com.pitchedapps.frost.facebook.USER_AGENT_BASIC
import com.pitchedapps.frost.injectors.InjectorContract
import com.pitchedapps.frost.injectors.JsActions
+import com.pitchedapps.frost.injectors.JsAssets
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.cleanHtml
import com.pitchedapps.frost.utils.materialDialogThemed
@@ -49,6 +50,7 @@ fun SettingsActivity.getDebugPrefs(): KPrefAdapterBuilder.() -> Unit = {
}
private enum class Debugger(val data: FbItem, val injector: InjectorContract?, vararg query: String) {
+ MENU(FbItem.MENU, JsAssets.MENU_DEBUG, "#viewport"), //todo modify menu js for debugging
NOTIFICATIONS(FbItem.NOTIFICATIONS, null, "#notifications_list"),
SEARCH(FbItem.SEARCH, JsActions.FETCH_BODY);
diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml
index a53c1124..4363cf71 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -15,7 +15,7 @@
<item text="Fix theme for sharing and new messages" />
<item text="Prevent search bar settings from disabling itself if auto suggestions fail" />
<item text="Fix numerous crashes relating to search bar layouts" />
- <item text="" />
+ <item text="Add debugging for menu" />
<item text="" />
<item text="" />