This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.html
87 lines (84 loc) · 3.81 KB
/
log.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DataSync Log Reader</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.2.2/jszip.min.js" integrity="sha256-gy5W5/rXWluWXFRvMWFFMVhocfpBe7Tf4SW2WMfjs4E=" crossorigin="anonymous"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
}
body {
background: #202124;
display: flex;
justify-content: center;
align-items: center;
}
input[type="file"] {
opacity: 0;
cursor: pointer;
position: fixed;
width: 100%;
height: 100%;
}
h3 {
font-family: sans-serif;
border-radius: 10px;
border: 1px solid white;
padding: 8px 14px;
color: white;
}
</style>
</head>
<body>
<h3>Select a file</h3>
<input type="file" id="file" name="file"/>
<script>
const devtools={isOpen:false,orientation:undefined};const threshold=160;const emitEvent=(isOpen,orientation)=>{window.dispatchEvent(new CustomEvent('devtoolschange',{detail:{isOpen,orientation}}));};setInterval(()=>{const widthThreshold=window.outerWidth-window.innerWidth>threshold;const heightThreshold=window.outerHeight-window.innerHeight>threshold;const orientation=widthThreshold?'vertical':'horizontal';if(!(heightThreshold&&widthThreshold)&&((window.Firebug&&window.Firebug.chrome&&window.Firebug.chrome.isInitialized)||widthThreshold||heightThreshold)){if(!devtools.isOpen||devtools.orientation!==orientation){emitEvent(true,orientation);}
devtools.isOpen=true;devtools.orientation=orientation;}else{if(devtools.isOpen){emitEvent(false,undefined);}
devtools.isOpen=false;devtools.orientation=undefined;}},500);window.devtools=devtools;
document.querySelector('#file').addEventListener('change', (evt) => {
const file = evt.target.files[0];
JSZip.loadAsync(file).then(async (zip) => {
console.clear();
localStorage.clear();
await zip.file('local-storage.json').async("string").then(file => {
const json = JSON.parse(file);
let newJson = {};
Object.keys(json).forEach((key) => {
localStorage.setItem(key, json[key]);
try {
newJson[key] = JSON.parse(json[key]);
} catch (e) {
newJson[key] = json[key];
}
});
console.log('localStorage', newJson);
});
await zip.file('console.txt').async("string").then(file => {
for (const line of file.trim().split('\n')) {
const parts = [];
parts.push(new Date(line.substring(1, line.indexOf(']'))).toTimeString().split(' ')[0]);
line.substr(line.indexOf(']') + 2).split(', ').forEach((part) => {
try {
parts.push(JSON.parse(part));
} catch (e) {
parts.push(isNaN(parseInt(part)) ? part : parseInt(part));
}
});
console.log(...parts);
}
});
if (!devtools.isOpen) {
alert('Parsing done, open the dev console');
}
}).catch((e) => {
alert('Error reading the file.');
console.log(e);
});
});
</script>
</body>
</html>