-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathsource.html
262 lines (244 loc) · 11.8 KB
/
source.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<!--
ExtAnalysis - Browser Extension Analysis Framework
Copyright (C) 2019 - 2022 Tuhinshubhra
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{file_name}} Source | ExtAnalysis</title>
<link id="pageStyle" rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/style.css') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for('static',filename='css/bttn.css') }}">
<link href="{{ url_for('static',filename='images/favicon.png') }}" rel="icon"/>
<link rel="stylesheet" href="{{ url_for('static',filename='css/codemirror.css') }}">
<link rel="stylesheet" href="{{ url_for('static',filename='css/material.css') }}">
<script type="text/javascript" src="{{ url_for('static',filename='js/fontawesome.min.js') }}"></script>
<link href="{{ url_for('static',filename='css/fontawesome.min.css') }}" rel="stylesheet" type="text/css" />
<style>
@font-face {
font-family: "ocraextended";
src: url("{{ url_for('static',filename='fonts/ocraextended.ttf') }}") format('truetype');
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: "Roboto";
src: url("{{ url_for('static',filename='fonts/Roboto-Regular.ttf') }}") format('truetype');
font-weight: 400;
font-style: normal;
}
/* Roboto italic */
@font-face {
font-family: "Roboto";
src: url("{{ url_for('static',filename='fonts/Roboto-Italic.ttf') }}") format('truetype');
font-weight: 400;
font-style: italic;
}
/* Roboto bold */
@font-face {
font-family: "Roboto";
src: url("{{ url_for('static',filename='fonts/Roboto-Bold.ttf') }}") format('truetype');
font-weight: 700;
font-style: normal;
}
</style>
</head>
<body>
<div class="noscript" id="noscript">
<img src="{{ url_for('static',filename='images/error.png') }}">
<h1>ExtAnalysis needs javascript enabled to work!</h1>
</div>
<div class="wrapper">
<!--
<h2>ExtAnalysis</h2>
<h6>Browser Extension Analysis Toolkit!</h6>
-->
<div class="logo-placeholder"><a href='/'><img src="{{ url_for('static',filename='images/logo.png') }}" class="logo" id="logo"></a></div>
<a href="#" id="lightSwitchOn" onclick="lightsOn()" class="dmode day" title="Enable Light Mode"><img src="{{ url_for('static',filename='images/light.svg') }}" style="width:27px;"></a>
<a href="#" id="lightSwitchOff" onclick="lightsOff()" class="dmode night" title="Enable Dark Mode"><img src="{{ url_for('static',filename='images/dark.svg') }}" style="width:27px;"></a>
<div class="container" id="container">
<div class="file_info">
<div class="file_image">
{{file_icon | safe}}
</div>
<div class="file_body">
<div class="file_name">Showing File: {{file_name}}</div>
<div class="file_attrs">
<div class="file_location">
<div class="file_icon">
<i class="fas fa-folder"></i>
</div>
{{file_location}}
</div>
<div class="file_type">
<div class="file_icon">
<i class="fas fa-file"></i>
</div>
{{file_type}} File
</div>
<div class="file_size">
<div class="file_icon">
<i class="fas fa-weight"></i>
</div>
{{file_size}}
</div>
</div>
</div>
</div>
<textarea class="source_code" id="editor">
{{file_source}}
</textarea>
<div class="editor_buttons">
<button class="format_button" onclick="formatSelection()"><i class="fas fa-hat-wizard"></i> Beautify Selected Code</button>
<button class="format_button" onclick="autoFormatSelection()"><i class="fas fa-magic"></i> Beautify Full Code</button>
</div>
</div>
</div>
<script type="text/javascript" src="{{ url_for('static',filename='js/jquery.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static',filename='js/main.js') }}"></script>
<script src="{{ url_for('static',filename='js/codemirror.js') }}"></script>
<script src="{{ url_for('static',filename='js/javascript.js') }}"></script>
<script src="{{ url_for('static',filename='js/htmlmixed.js') }}"></script>
<script src="{{ url_for('static',filename='js/css.js') }}"></script>
<script src="{{ url_for('static',filename='js/xml.js') }}"></script>
<script src="{{ url_for('static',filename='js/beautify.js') }}"></script>
<div class="footer">
<p>coded with <i class="fas fa-heart" style="color: #FF5722 !important;"></i> and <i class="fas fa-headphones" style="color: #28b78d !important;"></i> by r3dhax0r <a href="https://twitter.com/r3dhax0r" target="_blank"><button class="bttn-simple bttn-xs bttn-primary">Follow me on <i class="fab fa-twitter"></i></button></a> also <a href="https://github.com/Tuhinshubhra/ExtAnalysis" target="_blank"><button class="bttn-simple bttn-xs bttn-royal">Star This Project on <i class="fab fa-github-alt"></i></button></a></p>
</div>
</body>
<script>
code_mode = '{{file_type}}'
if (code_mode === 'html'){code_type = 'htmlmixed'} else if (code_mode === 'json'){code_type = 'javascript'} else if (code_mode === 'css'){code_type = 'css'} else {code_type = 'javascript'}
var codemirror = CodeMirror.fromTextArea(document.getElementById('editor'), {
mode: code_type,
theme: "material",
lineNumbers: true,
readOnly: false
});
function getSelectedRange() {
return { from: codemirror.getCursor(true), to: codemirror.getCursor(false) };
}
function autoFormatSelection() {
if (code_type === 'javascript'){
var currentValue = codemirror.getValue();
var newval = js_beautify(currentValue);
codemirror.setValue(newval);
}
totalLines = codemirror.lineCount();
codemirror.autoFormatRange({line:0, ch:0}, {line:totalLines});
}
function formatSelection() {
var range = getSelectedRange();
codemirror.autoFormatRange(range.from, range.to);
}
(function() {
CodeMirror.extendMode("css", {
commentStart: "/*",
commentEnd: "*/",
newlineAfterToken: function(type, content) {
return /^[;{}]$/.test(content);
}
});
CodeMirror.extendMode("javascript", {
commentStart: "/*",
commentEnd: "*/",
// FIXME semicolons inside of for
newlineAfterToken: function(type, content, textAfter, state) {
if (this.jsonMode) {
return /^[\[,{]$/.test(content) || /^}/.test(textAfter);
} else {
if (content == ";" && state.lexical && state.lexical.type == ")") return false;
return /^[;{}]$/.test(content) && !/^;/.test(textAfter);
}
}
});
CodeMirror.extendMode("xml", {
commentStart: "<!--",
commentEnd: "-->",
newlineAfterToken: function(type, content, textAfter) {
return type == "tag" && />$/.test(content) || /^</.test(textAfter);
}
});
// Comment/uncomment the specified range
CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
var cm = this, curMode = CodeMirror.innerMode(cm.getMode(), cm.getTokenAt(from).state).mode;
cm.operation(function() {
if (isComment) { // Comment range
cm.replaceRange(curMode.commentEnd, to);
cm.replaceRange(curMode.commentStart, from);
if (from.line == to.line && from.ch == to.ch) // An empty comment inserted - put cursor inside
cm.setCursor(from.line, from.ch + curMode.commentStart.length);
} else { // Uncomment range
var selText = cm.getRange(from, to);
var startIndex = selText.indexOf(curMode.commentStart);
var endIndex = selText.lastIndexOf(curMode.commentEnd);
if (startIndex > -1 && endIndex > -1 && endIndex > startIndex) {
// Take string till comment start
selText = selText.substr(0, startIndex)
// From comment start till comment end
+ selText.substring(startIndex + curMode.commentStart.length, endIndex)
// From comment end till string end
+ selText.substr(endIndex + curMode.commentEnd.length);
}
cm.replaceRange(selText, from, to);
}
});
});
// Applies automatic mode-aware indentation to the specified range
CodeMirror.defineExtension("autoIndentRange", function (from, to) {
var cmInstance = this;
this.operation(function () {
for (var i = from.line; i <= to.line; i++) {
cmInstance.indentLine(i, "smart");
}
});
});
// Applies automatic formatting to the specified range
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
var cm = this;
var outer = cm.getMode(), text = cm.getRange(from, to).split("\n");
var state = CodeMirror.copyState(outer, cm.getTokenAt(from).state);
var tabSize = cm.getOption("tabSize");
var out = "", lines = 0, atSol = from.ch == 0;
function newline() {
out += "\n";
atSol = true;
++lines;
}
for (var i = 0; i < text.length; ++i) {
var stream = new CodeMirror.StringStream(text[i], tabSize);
while (!stream.eol()) {
var inner = CodeMirror.innerMode(outer, state);
var style = outer.token(stream, state), cur = stream.current();
stream.start = stream.pos;
if (!atSol || /\S/.test(cur)) {
out += cur;
atSol = false;
}
if (!atSol && inner.mode.newlineAfterToken &&
inner.mode.newlineAfterToken(style, cur, stream.string.slice(stream.pos) || text[i+1] || "", inner.state))
newline();
}
if (!stream.pos && outer.blankLine) outer.blankLine(state);
if (!atSol) newline();
}
cm.operation(function () {
cm.replaceRange(out, from, to);
for (var cur = from.line + 1, end = from.line + lines; cur <= end; ++cur)
cm.indentLine(cur, "smart");
cm.setSelection(from, cm.getCursor(false));
});
});
})();
</script>
</html>