-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathextensionsjson.html
345 lines (344 loc) · 16.2 KB
/
extensionsjson.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<!DOCTYPE html>
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<title>Extension Extractor — Fx File Utilities</title>
<link rel="stylesheet" href="styles.css" type="text/css">
</head>
<body>
<nav>
<ul>
<li id="logo">Fx File Utilities</li>
<li><a href="scrounger.html" title="Scrounge URLs from session history files">Session History</a></li>
<li><a href="bookbackreader.html" title="Save JSON or Export HTML from bookmark backup files">Bookmark Backup</a></li>
<li><a href="searchjson.html" title="Read out search engine details">Search Engines</a></li>
<li><span id="current">Extensions</span></li>
</ul>
</nav>
<header>
<h1>Firefox Extension Extractor</h1>
</header>
<article>
<div id="main">
<p><em>Firefox stores information on built-in and added-on extensions in the extensions.json file. This page provides a brief summary table showing what it found.</em></p>
<h2>Step 1: Load File</h2>
<p>Drag and drop extensions.json onto the empty text box. This file is not sent to the network, it is only read within this page in Firefox.</p>
<div id="uploaddiv">
<textarea id="drop_zone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event);" style="width:80%" autocomplete="false" placeholder="Drop file here"></textarea>
<div style="position:absolute; right:0; top:0; width:calc(20% - 18px); cursor: pointer;" onclick="document.querySelector('#btnBrowse').click();";>
<p style="margin-top:2em; text-align:center;">Or open using: <br><br><input type="file" id="btnBrowse" onchange="loadFile(this);" style="width: 80px"></p>
</div>
</div>
<p><em>Note: To try a different file, reload this page (Windows: Ctrl+r. Mac: Command+r). Or click the reload button in the address bar.</em></p>
<h2>Step 2: Generate Table / Save File</h2>
<p>Date format: <select id="selDateFmt">
<option value="tls" selected>toLocaleString()</option>
<option value="ymd">yyyy-mm-dd</option>
<option value="dmy">dd/mm/yyyy</option>
<option value="mdy">mm/dd/yyyy</option>
</select> <label><input type="checkbox" id="chkPerms"> List Permissions</label> <button onclick="showDetails()" id="btnParse" disabled>Generate Table</button> <button onclick="SaveTable()" id="btnSave" disabled>Save Table</button></p>
<div id="output">
</div>
</div><!-- #main -->
</article>
<footer>
<p>Copyright © 2022 Jefferson Scher (<a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>). FileSaver.js © 2016 Eli Grey (<a href="https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md">MIT License</a>; <a href="https://github.com/eligrey/FileSaver.js/tree/1.3.2">v1.3.2</a>). MDN code samples © Mozilla Contributors or Public Domain (<a href="https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses">License</a>). No claim to your data! Updated 2022-01-23. [<a href="extensionsjson_20191229.html">12/29/2019 version</a>]</p>
</footer>
<script type="text/javascript">
// Clean up form controls on reload (i.e., not bypassing cache)
document.getElementById('drop_zone').value = '';
document.getElementById('btnParse').setAttribute('disabled', 'disabled');
document.getElementById('btnSave').setAttribute('disabled', 'disabled');
function readfile(f){
// Add notation below textarea
if (document.getElementById('fileinfo')) document.getElementById('fileinfo').remove();
document.getElementById('drop_zone').insertAdjacentHTML('afterend', '<p id="fileinfo">File name: <span>'+f.name+'</span>; Size: '+f.size+'; last modified <span>'+new Date(f.lastModified).toLocaleString()+'</span></p>');
// Use a FileReader to pull the contents out of the file and drop it into the textarea element
var reader = new FileReader();
reader.onload = function(evt) { // handle result of the file read
document.getElementById('drop_zone').value = evt.target.result;
};
reader.readAsText(f);
}
var baseurl = 'https://addons.mozilla.org/api/v4/addons/search/?app=firefox&guid=';
var arrExts = [], arrLookup = [];
var listPerms = false;
function showDetails(){
var txt = document.getElementById('drop_zone').value;
try {
var oFile = JSON.parse(txt);
} catch (err) {
console.log('Not reading data due to failure parsing JSON: ' + err.toString());
return;
}
arrExts = oFile.addons; // Array of objects
var sType = '', arrOut = [], sTemp = '';
listPerms = document.getElementById('chkPerms').checked;
for (var i=0; i<arrExts.length; i++){
// Build description
if (arrExts[i].rootURI.indexOf('resource://search-extensions/') > -1) sType = 'SearchXPI';
else sType = arrExts[i].type.charAt(0).toUpperCase() + arrExts[i].type.slice(1);
sTemp = '<tr sortby="' + sType + '|' + !arrExts[i].active + '"><td><strong>' + arrExts[i].defaultLocale.name + '</strong>';
if (sType == 'Theme') sTemp += ' (theme)';
sTemp += '<br>Version: ' + arrExts[i].version + '</td><td>';
if (arrExts[i].hasOwnProperty('installDate')){
sTemp += fmtD(arrExts[i].installDate) + '</td><td>';
} else {
sTemp += '--</td><td>';
}
if (arrExts[i].hasOwnProperty('updateDate')){
sTemp += fmtD(arrExts[i].updateDate) + '</td><td>';
} else {
sTemp += '--</td><td>';
}
sTemp += sType + '<br>';
if (arrExts[i].active){
sTemp += 'Enabled</td>';
} else {
if (arrExts[i].appDisabled) {
sTemp += 'Disabled by Firefox</td>';
} else {
sTemp += 'Disabled</td>';
}
}
sTemp += '<td id="ext_' + i + '">' + arrExts[i].id + '<br>';
if (arrExts[i].location == 'app-builtin'){
sTemp += 'Built-in (' + arrExts[i].rootURI + ')';
} else if (arrExts[i].location == 'app-system-defaults' || arrExts[i].location == 'app-system-addons') {
sTemp += 'System Add-on (features)';
} else if (arrExts[i].location == 'winreg-app-global' || arrExts[i].location == 'winreg-app-user') {
sTemp += 'Sideloaded through Windows Registry (' + arrExts[i].path + ')';
} else {
arrLookup.push(i);
}
if (listPerms){
sTemp += '</td><td></td></tr>';
} else {
sTemp += '</td></tr>';
}
arrOut.push(sTemp);
}
document.getElementById('btnSave').removeAttribute('disabled');
// Sort array to group by type; 23 Jan 2022 case insensitive
arrOut.sort((a, b) => a.localeCompare(b, undefined, {sensitivity: 'base'}));
// Write out the contents
var out = document.getElementById('output');
var strOut = '<style>table {border:1px solid #000; border-collapse: collapse;} tr.recom {background-color: #f0fff0;} tr.spons {background-color: #f0f8ff;} ' +
'tr[sortby*="true"] {background-color: #eee;} th, td {border:1px solid #000; padding: 3px; text-align: left; vertical-align: top;} ' +
'td p {margin: 0 0 6px; } .hostslist {max-height: 6em; overflow: hidden; transition: all 250ms ease-in-out 750ms;} ' +
'.hostslist:hover {max-height: 99em; overflow: hidden;}</style>\n' +
'<h2>Highlights of extensions.json</h2>\n';
if (listPerms){
strOut += '<table><thead><th>Name and Version</th><th>Installed</th><th>Updated</th><th>Type & Status</th><th style="width:30%">ID and Source</th><th style="width:20%">Permissions</th></thead>\n<tbody>';
} else {
strOut += '<table><thead><th>Name and Version</th><th>Installed</th><th>Updated</th><th>Type & Status</th><th style="width:40%">ID and Source</th></thead>\n<tbody>';
}
out.innerHTML = strOut + arrOut.join('\n') + '</tbody></table>\n';
window.setTimeout(function(){addAMOLinks(0);}, 1000);
}
var mo = ['01','02','03','04','05','06','07','08','09','10','11','12'];
function fmtD(strDate){
if (strDate == '') return '';
var d = new Date(strDate);
switch (document.getElementById('selDateFmt').value){
case 'ymd':
return d.getFullYear() + '-' + mo[d.getMonth()] + '-' + ('0' + d.getDate()).slice(-2) + ' ' + d.toLocaleTimeString();
case 'dmy':
return ('0' + d.getDate()).slice(-2) + '/' + mo[d.getMonth()] + '/' + d.getFullYear() + ' ' + d.toLocaleTimeString();
case 'mdy':
return mo[d.getMonth()] + '/' + ('0' + d.getDate()).slice(-2) + '/' + d.getFullYear() + ' ' + d.toLocaleTimeString();
case 'tls':
default:
return d.toLocaleString().replace(', ', '<br>');
}
}
// From https://github.com/mozilla/gecko/blob/central/browser/locales/en-US/chrome/browser/browser.properties
permDesc = {
"bookmarks": "Read and modify bookmarks",
"browserSettings": "Read and modify browser settings",
"browsingData": "Clear recent browsing history, cookies, and related data",
"clipboardRead": "Get data from the clipboard",
"clipboardWrite": "Input data to the clipboard",
"devtools": "Extend developer tools to access your data in open tabs",
"dns": "Access IP address and hostname information",
"downloads": "Download files and read and modify the browser’s download history",
"downloads.open": "Open files downloaded to your computer",
"find": "Read the text of all open tabs",
"geolocation": "Access your location",
"history": "Access browsing history",
"management": "Monitor extension usage and manage themes",
"nativeMessaging": "Exchange messages with programs other than Firefox",
"notifications": "Display notifications to you",
"pkcs11": "Provide cryptographic authentication services",
"privacy": "Read and modify privacy settings",
"proxy": "Control browser proxy settings",
"sessions": "Access recently closed tabs",
"tabs": "Access browser tabs",
"tabHide": "Hide and show browser tabs",
"topSites": "Access browsing history",
"unlimitedStorage": "Store unlimited amount of client-side data",
"webNavigation": "Access browser activity during navigation"
}
function addAMOLinks(counter){
// Look up ID via the Add-ons site API and grab the source page URL
if (arrExts[counter].location == 'app-builtin' ||
arrExts[counter].location == 'app-system-defaults' ||
arrExts[counter].location == 'app-system-addons' ||
arrExts[counter].location == 'winreg-app-global' ||
arrExts[counter].location == 'winreg-app-user') { // already handled
if (counter + 1 < arrExts.length) addAMOLinks(counter + 1);
} else {
url = baseurl + encodeURIComponent(arrExts[counter].id) + '&extcount=' + counter;
var request = new XMLHttpRequest();
request.onreadystatechange = function(evt) {
if (request.readyState==4) {
if (request.status==200) {
console.log(request.responseText);
var respObj = JSON.parse(request.responseText);
if (respObj.errdesc){
alert(respObj.errdesc);
return false;
}
var count = parseInt(request.responseURL.slice(request.responseURL.lastIndexOf('=') + 1));
if (respObj.results.length > 0){
document.getElementById('ext_' + count).insertAdjacentHTML('beforeend', '<a href="' + respObj.results[0].url + '" target="_blank">' + respObj.results[0].url + '</a>');
if (respObj.results[0].promoted !== null){
if (respObj.results[0].promoted.category.toLowerCase() == 'recommended'){
document.getElementById('ext_' + count).parentNode.className = 'recom';
document.getElementById('ext_' + count).insertAdjacentHTML('beforeend', ' <em>Recommended</em>');
}
if (respObj.results[0].promoted.category.toLowerCase() == 'sponsored'){
document.getElementById('ext_' + count).parentNode.className = 'spons';
document.getElementById('ext_' + count).insertAdjacentHTML('beforeend', ' <em>Verified</em>');
}
}
if (listPerms){
var oFiles = respObj.results[0].current_version.files;
var sPerms = '';
for (var ndx in oFiles) {
oFile = oFiles[ndx];
var arrHosts = [];
var arrAPIs1 = [];
var arrAPIs2 = [];
var sAllHosts = '';
for (var j=0; j<oFile.permissions.length; j++){
if ((oFile.permissions[j] == '<all_urls>' || oFile.permissions[j].indexOf('://*/') > -1)) {
if (sAllHosts == '') sAllHosts = '<p><b style="background:#ff8;">Access your data for all websites</b></p>\n';
} else {
if (oFile.permissions[j].indexOf('/') > -1){
sHost = oFile.permissions[j].replace(/</g, '<').replace(/>/g, '>');
sHost = sHost.replace(/:\/\/([\d\w\.\-\*]*)\//, '://<b>$1</b>/');
if (!arrHosts.includes(sHost)) arrHosts.push(sHost);
} else {
// TODO: parse for interesting ones
if (permDesc[oFile.permissions[j]] !== undefined){
if (!arrAPIs1.includes(permDesc[oFile.permissions[j]])) arrAPIs1.push(permDesc[oFile.permissions[j]]);
} else {
if (!arrAPIs2.includes(oFile.permissions[j].replace(/</g, '<').replace(/>/g, '>'))) arrAPIs2.push(oFile.permissions[j].replace(/</g, '<').replace(/>/g, '>'));
}
}
}
}
}
sPerms += sAllHosts;
if (arrHosts.length > 0){
arrHosts.sort();
sPerms += '<p class="hostslist">' + 'Access your data for: ' + arrHosts.join(', ') + '</p>\n';
}
if (arrAPIs1.length > 0){
sPerms += '<p><b>' + arrAPIs1.join('</b></p><p><b>') + '</b></p>\n';
}
if (arrAPIs2.length > 0){
arrAPIs2.sort();
sPerms += '<p><i>' + 'Other API permissions:</i> ' + arrAPIs2.join(', ') + '</p>\n';
}
document.getElementById('ext_' + count).nextElementSibling.insertAdjacentHTML('beforeend', sPerms);
}
} else {
document.getElementById('ext_' + count).insertAdjacentHTML('beforeend', 'From: ' + arrExts[count].sourceURI + ' ("' + arrExts[count].location + '")');
if (listPerms){
document.getElementById('ext_' + count).nextElementSibling.insertAdjacentHTML('beforeend', ' ');
}
}
request = null;
if (count + 1 < arrExts.length) addAMOLinks(count + 1);
}
}
}
request.open("get", url, true);
request.send();
}
}
function SaveTable(){
var dt = new Date().toISOString();
var fn = 'extensions_json(' + dt.slice(0, dt.indexOf('T')) + ').html';
saveAs(
new Blob(
['<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>Extensions List</title></head><body>'+document.getElementById('output').innerHTML+'<p>Extracted using <a href="https://www.jeffersonscher.com/ffu/extensionsjson.html">https://www.jeffersonscher.com/ffu/extensionsjson.html</a></p></body></html>']
, {type: 'text/html;charset=UTF-8'}
)
, fn
);
}
// copied/adapted from https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop
function drop_handler(ev) {
ev.preventDefault();
// If dropped items aren't files, reject them
var dt = ev.dataTransfer;
if (dt.items) {
// Use DataTransferItemList interface to access the file(s) (break after first file opened)
for (var i=0; i < dt.items.length; i++) {
if (dt.items[i].kind == "file") {
readfile(dt.items[i].getAsFile());
document.getElementById('btnParse').removeAttribute('disabled');
break;
}
}
} else { // ** NOT TESTED **
// Use DataTransfer interface to access the file(s) (break after first file opened)
for (var i=0; i < dt.files.length; i++) {
readfile(dt.files[i]);
document.getElementById('btnParse').removeAttribute('disabled');
break;
}
}
}
function dragover_handler(ev) {
console.log("dragOver");
// Prevent default select and drag behavior
ev.preventDefault();
}
function dragend_handler(ev) {
console.log("dragEnd");
// Remove all of the drag data
var dt = ev.dataTransfer;
if (dt.items) {
// Use DataTransferItemList interface to remove the drag data
for (var i = 0; i < dt.items.length; i++) {
dt.items.remove(i);
}
} else {
// Use DataTransfer interface to remove the drag data
ev.dataTransfer.clearData();
}
}
function loadFile(inp){
if (inp.files.length == 0) return;
if (inp.files.length > 1){
inp.insertAdjacentHTML('afterend', '<br><em>First file used</em>');
}
readfile(inp.files[0]);
document.getElementById('btnParse').removeAttribute('disabled');
}
</script>
<script type="text/javascript" src="ffu.js"></script>
<script type="text/javascript" src="FileSaver.min.js"></script>
<style>
#output {border-top:2px solid #000; font-family:sans-serif; font-size: 16px;}
#output:not(:empty) {border-bottom:2px solid #000;}
#output table {margin-bottom: 30px;}
@media screen { }
</style>
</body>
</html>