From 0ed6d8688d8782674a3100fdd1e37d1b1f577f89 Mon Sep 17 00:00:00 2001 From: Heath123 Date: Sat, 5 Dec 2020 11:33:57 +0000 Subject: [PATCH] Cleanup/bug fixes --- html/mainPage/index.html | 2 +- html/mainPage/js/filteringLogic.js | 4 ++++ html/mainPage/js/main.js | 14 ++++++++++++-- src/index.js | 7 ++++++- src/packetHandler.js | 2 -- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/html/mainPage/index.html b/html/mainPage/index.html index ca5aff5..ef4d7da 100644 --- a/html/mainPage/index.html +++ b/html/mainPage/index.html @@ -110,7 +110,7 @@

Scripting (beta)

Clear -
+
diff --git a/html/mainPage/js/filteringLogic.js b/html/mainPage/js/filteringLogic.js index 71e1d83..7e94587 100644 --- a/html/mainPage/js/filteringLogic.js +++ b/html/mainPage/js/filteringLogic.js @@ -9,4 +9,8 @@ exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets) { const comparisonString = packet.hexIdString + ' ' + packet.meta.name + ' ' + JSON.stringify(packet.data) return !comparisonString.includes(filter) +} + +exports.packetCollapsed = function (packet, filter, hiddenPackets) { + return packet.meta.name === 'position' } \ No newline at end of file diff --git a/html/mainPage/js/main.js b/html/mainPage/js/main.js index 1133914..1fb478c 100644 --- a/html/mainPage/js/main.js +++ b/html/mainPage/js/main.js @@ -31,6 +31,7 @@ function wrappedClusterizeUpdate (htmlArray) { for (const item of htmlArray) { if (!item[0] .match(/
  • /)) { + newArray.push(item) } } @@ -337,12 +338,20 @@ window.openMenu = function (evt, MenuName, id) { // window. stops standardjs fro document.body.addEventListener('contextmenu', (event) => { let target = event.srcElement + if (target.tagName !== 'LI') { target = target.parentElement } + if (!target || target.tagName !== 'LI') { return - }; + } + + // Don't allow right clicking in the filtering tab or on other places + if (target.parentElement.parentElement.id !== 'packetcontainer') { + return + } + sharedVars.ipcRenderer.send('contextMenu', JSON.stringify({ direction: target.className.split(' ')[1], text: target.children[0].innerText + ' ' + target.children[1].innerText, @@ -353,5 +362,6 @@ document.body.addEventListener('contextmenu', (event) => { var clusterize = new Clusterize({ rows: sharedVars.allPacketsHTML, scrollElem: sharedVars.packetList.parentElement, - contentElem: sharedVars.packetList + contentElem: sharedVars.packetList, + no_data_text: '' }) diff --git a/src/index.js b/src/index.js index e3764cd..17956cc 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ const { app, BrowserWindow, ipcMain, clipboard, Menu } = require('electron') +app.allowRendererProcessReuse = true const javaProxy = require('./proxy/java/proxy.js') const bedrockProxy = require('./proxy/bedrock/proxy.js') @@ -18,6 +19,11 @@ const osDataFolder = app.getPath('appData') const dataFolder = setupDataFolder.setup(osDataFolder, resourcesPath) function makeMenu (direction, text, id) { + if (direction !== 'clientbound' && direction !== 'serverbound') { + // This probably isn't a packet + return + } + let menuData = [ { icon: resourcesPath + `icons/${direction}.png`, @@ -142,7 +148,6 @@ ipcMain.on('copyToClipboard', (event, arg) => { ipcMain.on('contextMenu', (event, arg) => { const ipcMessage = JSON.parse(arg) - console.log(ipcMessage) makeMenu(ipcMessage.direction, ipcMessage.text, ipcMessage.id).popup(BrowserWindow.getAllWindows()[0]) }) diff --git a/src/packetHandler.js b/src/packetHandler.js index 6ea1b2c..db293ee 100644 --- a/src/packetHandler.js +++ b/src/packetHandler.js @@ -24,8 +24,6 @@ exports.init = function (window, passedIpcMain, passedProxy) { ipcMain = passedIpcMain proxy = passedProxy - console.log('init') - ipcMain.on('injectPacket', (event, arg) => { const ipcMessage = JSON.parse(arg) if (ipcMessage.direction === 'clientbound') {