\n \n ' +
@@ -463,10 +463,10 @@ window.jsonTree = (function () {
return str
}
- var childNodesUl
- var labelEl
- var moreContentEl
- var childNodes = []
+ let childNodesUl
+ let labelEl
+ let moreContentEl
+ const childNodes = []
self.label = label
self.isComplex = true
@@ -606,7 +606,7 @@ window.jsonTree = (function () {
this.el.classList.toggle('jsontree_node_expanded')
if (isRecursive) {
- var isExpanded = this.el.classList.contains('jsontree_node_expanded')
+ const isExpanded = this.el.classList.contains('jsontree_node_expanded')
this.childNodes.forEach(function (item, i) {
if (item.isComplex) {
@@ -778,8 +778,8 @@ window.jsonTree = (function () {
return JSON.stringify(this.sourceJSONObj)
}
- var DELIMETER = '[%^$#$%^%]'
- var jsonStr = JSON.stringify(this.sourceJSONObj, null, DELIMETER)
+ const DELIMETER = '[%^$#$%^%]'
+ let jsonStr = JSON.stringify(this.sourceJSONObj, null, DELIMETER)
jsonStr = jsonStr.split('\n').join('
')
jsonStr = jsonStr.split(DELIMETER).join(' ')
diff --git a/html/mainPage/js/filteringLogic.js b/html/mainPage/js/filteringLogic.js
index 7e94587..4fbf04a 100644
--- a/html/mainPage/js/filteringLogic.js
+++ b/html/mainPage/js/filteringLogic.js
@@ -13,4 +13,4 @@ exports.packetFilteredByFilterBox = function (packet, filter, hiddenPackets) {
exports.packetCollapsed = function (packet, filter, hiddenPackets) {
return packet.meta.name === 'position'
-}
\ No newline at end of file
+}
diff --git a/html/mainPage/js/ipcHandler.js b/html/mainPage/js/ipcHandler.js
index ad371a1..b57388c 100644
--- a/html/mainPage/js/ipcHandler.js
+++ b/html/mainPage/js/ipcHandler.js
@@ -14,16 +14,15 @@ exports.setup = function (passedSharedVars) {
sharedVars.ipcRenderer.on('copyTeleportCommand', (event, arg) => {
console.log(sharedVars.allPackets)
const ipcMessage = JSON.parse(arg)
- let data = sharedVars.allPackets[ipcMessage.id].data
-
- let clipData = '/tp @p ' + ((data.flags & 0x01) ? '~' : '') + ((data.x === 0 && (data.flags & 0x01)) ? '' : data.x)
- + ((data.flags & 0x02) ? ' ~' : ' ') + ((data.y === 0 && (data.flags & 0x03)) ? '' : data.y)
- + ((data.flags & 0x04) ? ' ~' : ' ') + ((data.z === 0 && (data.flags & 0x04)) ? '' : data.z)
+ const data = sharedVars.allPackets[ipcMessage.id].data
+ let clipData = '/tp @p ' + ((data.flags & 0x01) ? '~' : '') + ((data.x === 0 && (data.flags & 0x01)) ? '' : data.x) +
+ ((data.flags & 0x02) ? ' ~' : ' ') + ((data.y === 0 && (data.flags & 0x03)) ? '' : data.y) +
+ ((data.flags & 0x04) ? ' ~' : ' ') + ((data.z === 0 && (data.flags & 0x04)) ? '' : data.z)
if (!(data.flags & 0x10) || !(data.flags & 0x08) || data.pitch != 0 || data.yaw !== 0) {
- clipData += ((data.flags & 0x10) ? ' ~' : ' ') + data.pitch
- + ((data.flags & 0x08) ? ' ~' : ' ') + data.yaw
+ clipData += ((data.flags & 0x10) ? ' ~' : ' ') + data.pitch +
+ ((data.flags & 0x08) ? ' ~' : ' ') + data.yaw
}
sharedVars.ipcRenderer.send('copyToClipboard', clipData)
@@ -33,4 +32,4 @@ exports.setup = function (passedSharedVars) {
const ipcMessage = JSON.parse(arg)
sharedVars.packetDom.addPacket(ipcMessage)
})
-}
\ No newline at end of file
+}
diff --git a/html/mainPage/js/main.js b/html/mainPage/js/main.js
index 1fb478c..ad4b4cc 100644
--- a/html/mainPage/js/main.js
+++ b/html/mainPage/js/main.js
@@ -31,7 +31,6 @@ function wrappedClusterizeUpdate (htmlArray) {
for (const item of htmlArray) {
if (!item[0]
.match(//)) {
-
newArray.push(item)
}
}
@@ -61,6 +60,7 @@ function toggleCheckbox (box, packetName, direction) {
}
updateFiltering()
+ updateFilteringStorage()
}
function updateFilterBox () {
@@ -73,7 +73,7 @@ function updateFilterBox () {
}
function updateFiltering () {
- sharedVars.allPacketsHTML.forEach(function(item, index, array) {
+ sharedVars.allPacketsHTML.forEach(function (item, index, array) {
if (!filteringLogic.packetFilteredByFilterBox(sharedVars.allPackets[index],
sharedVars.lastFilter,
sharedVars.hiddenPackets)) {
@@ -101,17 +101,19 @@ setInterval(updateFilterBox, 100)
// let dialogOpen = false Not currently used
const defaultHiddenPackets = {
- serverbound: ["position","position_look","look","keep_alive","entity_action"],
- clientbound: ["keep_alive","update_time","rel_entity_move","entity_teleport","map_chunk","update_light","update_view_position","entity_metadata","entity_update_attributes","unload_chunk","entity_velocity","entity_move_look","entity_head_rotation"]
-},
+ serverbound: ['position', 'position_look', 'look', 'keep_alive', 'entity_action'],
+ clientbound: ['keep_alive', 'update_time', 'rel_entity_move', 'entity_teleport', 'map_chunk', 'update_light', 'update_view_position', 'entity_metadata', 'entity_update_attributes', 'unload_chunk', 'entity_velocity', 'entity_move_look', 'entity_head_rotation']
+}
-sharedVars = {
+const sharedVars = {
allPackets: [],
allPacketsHTML: [],
- proxyCapabilities : {},
+ proxyCapabilities: {},
ipcRenderer: require('electron').ipcRenderer,
packetList: document.getElementById('packetlist'),
- hiddenPackets: Object.assign({}, defaultHiddenPackets),
+ hiddenPackets: localStorage.getItem('hiddenPackets')
+ ? JSON.parse(localStorage.getItem('hiddenPackets'))
+ : Object.assign({}, defaultHiddenPackets),
scripting: undefined,
lastFilter: ''
}
@@ -136,18 +138,13 @@ sharedVars.ipcHandler.setup(sharedVars)
// const sidebar = document.getElementById('sidebar-box')
-
-
-
-
-
-
-
-
-
// TODO: move to own file
const filteringPackets = document.getElementById('filtering-packets')
+function updateFilteringStorage () {
+ localStorage.setItem('hiddenPackets', JSON.stringify(sharedVars.hiddenPackets))
+}
+
function updateFilteringTab () {
for (const item of filteringPackets.children) {
const name = item.children[2].textContent
@@ -157,15 +154,17 @@ function updateFilteringTab () {
checkbox.indeterminate = false
let isShown = true
if (item.className.includes('serverbound') &&
- sharedVars.hiddenPackets['serverbound'].includes(name)) {
+ sharedVars.hiddenPackets.serverbound.includes(name)) {
isShown = false
} else if (item.className.includes('clientbound') &&
- sharedVars.hiddenPackets['clientbound'].includes(name)) {
+ sharedVars.hiddenPackets.clientbound.includes(name)) {
isShown = false
}
checkbox.checked = isShown
}
+
+ updateFilteringStorage()
}
const allServerboundPackets = []
@@ -178,9 +177,9 @@ function addPacketsToFiltering (packetsObject, direction, appendTo) {
if (packetsObject.hasOwnProperty(key)) {
console.log(!sharedVars.hiddenPackets[direction].includes(packetsObject[key]))
filteringPackets.innerHTML +=
- `
+ `
+ onclick="toggleCheckbox(this, ${JSON.stringify(packetsObject[key]).replace(/"/g, ''')}, '${direction}')"/>
${escapeHtml(key)}
${escapeHtml(packetsObject[key])}
`
@@ -190,22 +189,14 @@ function addPacketsToFiltering (packetsObject, direction, appendTo) {
}
}
-
-
-
-
-
-
addPacketsToFiltering(sharedVars.proxyCapabilities.serverboundPackets, 'serverbound', allServerboundPackets)
addPacketsToFiltering(sharedVars.proxyCapabilities.clientboundPackets, 'clientbound', allClientboundPackets)
-
-
// Update every 0.05 seconds
// TODO: Find a better way without updating on every packet (which causes lag)
window.setInterval(function () {
if (sharedVars.packetsUpdated) {
- const diff = (sharedVars.packetList.parentElement.scrollHeight - sharedVars.packetList.parentElement.offsetHeight) - sharedVars.packetList.parentElement.scrollTop;
+ const diff = (sharedVars.packetList.parentElement.scrollHeight - sharedVars.packetList.parentElement.offsetHeight) - sharedVars.packetList.parentElement.scrollTop
const wasScrolledToBottom = diff < 5 // If it was scrolled to the bottom or almost scrolled to the bottom
wrappedClusterizeUpdate(sharedVars.allPacketsHTML)
if (wasScrolledToBottom) {
@@ -220,7 +211,7 @@ window.setInterval(function () {
}, 50)
window.closeDialog = function () { // window. stops standardjs from complaining
- // dialogOpen = false
+ // dialogOpen = false
document.getElementById('dialog-overlay').className = 'dialog-overlay'
document.getElementById('dialog').innerHTML = ''
}
@@ -314,6 +305,7 @@ function hideAll (id) {
checkbox.readOnly = false
checkbox.indeterminate = false
updateFiltering()
+ updateFilteringStorage()
}
sharedVars.ipcRenderer.on('hideAllOfType', (event, arg) => { // Context menu
@@ -323,7 +315,7 @@ sharedVars.ipcRenderer.on('hideAllOfType', (event, arg) => { // Context menu
// Modified from W3Schools
window.openMenu = function (evt, MenuName, id) { // window. stops standardjs from complaining
- var i, tabcontent, tablinks
+ let i, tabcontent, tablinks
tabcontent = document.getElementsByClassName('tabcontent' + id)
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = 'none'
diff --git a/html/mainPage/js/packetDom.js b/html/mainPage/js/packetDom.js
index c3d4c32..6b23b90 100644
--- a/html/mainPage/js/packetDom.js
+++ b/html/mainPage/js/packetDom.js
@@ -66,7 +66,7 @@ function refreshPackets () {
} */
}
-function updateHidden() {
+function updateHidden () {
// TODO: make it work
/* hiddenPacketsAmount = (sharedVars.allPackets.length - sharedVars.allPacketsHTML.length);
document.getElementById("hiddenPackets").innerHTML = hiddenPacketsAmount + ' hidden packets';
@@ -98,4 +98,4 @@ exports.getTreeElement = function () {
exports.getTree = function () {
return tree
-}
\ No newline at end of file
+}
diff --git a/html/mainPage/js/scripting.js b/html/mainPage/js/scripting.js
index 9c879fc..8a6fab8 100644
--- a/html/mainPage/js/scripting.js
+++ b/html/mainPage/js/scripting.js
@@ -37,4 +37,4 @@ exports.downstreamHandler = function (meta, data, server, client) {
resetScriptEditor()
window.scriptEditor.on('change', exports.updateScript)
-}
\ No newline at end of file
+}
diff --git a/html/startPage/script.js b/html/startPage/script.js
index 59825de..625c552 100644
--- a/html/startPage/script.js
+++ b/html/startPage/script.js
@@ -12,7 +12,7 @@ if (localStorage.getItem('authConsentGiven') !== 'true') {
document.getElementById('consent-box').style.display = 'contents'
}
-var isLoading = false
+let isLoading = false
let connectAddress
let connectPort
@@ -21,7 +21,7 @@ let platform
let version
loadSetting('lastPlatform', 'platform', 'platform', 'java')
-var lastPlatform = platform
+let lastPlatform = platform
platformChange()
loadSettings(platform)
diff --git a/src/index.js b/src/index.js
index acaa739..f278a58 100644
--- a/src/index.js
+++ b/src/index.js
@@ -24,7 +24,7 @@ function makeMenu (direction, text, id) {
return
}
- let menuData = [
+ const menuData = [
{
icon: resourcesPath + `icons/${direction}.png`,
label: text,
@@ -66,14 +66,14 @@ function makeMenu (direction, text, id) {
if (text.split(' ')[1] === 'position' && direction === 'clientbound') {
menuData.splice(3, 0,
{
- label: 'Copy teleport as command',
- click: () => {
- BrowserWindow.getAllWindows()[0].send('copyTeleportCommand', JSON.stringify({
- // Packet ID from link URL
- id: id
- }))
- }
+ label: 'Copy teleport as command',
+ click: () => {
+ BrowserWindow.getAllWindows()[0].send('copyTeleportCommand', JSON.stringify({
+ // Packet ID from link URL
+ id: id
+ }))
}
+ }
)
}
diff --git a/src/packetHandler.js b/src/packetHandler.js
index db293ee..7b24d8d 100644
--- a/src/packetHandler.js
+++ b/src/packetHandler.js
@@ -8,13 +8,13 @@ let currentScript
let currentScriptModule
const server = {
- sendPacket: function(meta, data) {
+ sendPacket: function (meta, data) {
proxy.writeToServer(meta, data, true)
}
}
const client = {
- sendPacket: function(meta, data) {
+ sendPacket: function (meta, data) {
proxy.writeToClient(meta, data, true)
}
}
diff --git a/src/proxy/bedrock/proxy.js b/src/proxy/bedrock/proxy.js
index 050c161..bd07e37 100644
--- a/src/proxy/bedrock/proxy.js
+++ b/src/proxy/bedrock/proxy.js
@@ -22,7 +22,7 @@ function processPacket (text) {
let out = ''
let indentlevel = 0
- for (var i = 0; i < str.length; i++) {
+ for (let i = 0; i < str.length; i++) {
if (str.charAt(i) === ')' || str.charAt(i) === '}' || str.charAt(i) === ']') {
indentlevel -= 1
if (indentlevel < 0) {
diff --git a/src/proxy/java/proxy.js b/src/proxy/java/proxy.js
index f339818..f7fb5fd 100644
--- a/src/proxy/java/proxy.js
+++ b/src/proxy/java/proxy.js
@@ -5,11 +5,11 @@ const minecraftFolder = require('minecraft-folder-path')
const states = mc.states
-var realClient
-var realServer
-var toClientMappings
-var toServerMappings
-var storedCallback
+let realClient
+let realServer
+let toClientMappings
+let toServerMappings
+let storedCallback
exports.capabilities = {
modifyPackets: true,