forked from johnmichel/Library-Detector-for-Chrome
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib_detect.js
40 lines (36 loc) · 1.06 KB
/
lib_detect.js
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
/**
description: Injected into document by inject.js to create a meta element with
any recognized JS libraries.
**/
(function() {
/**
* Returns library, version pairs in format:
* libraryName:version,libraryName:version...
*/
var encodeLibraries = function(libraries) {
var encoded = [];
for (var i=0; i<libraries.length; i++) {
encoded.push(libraries[i].name + ':' + libraries[i].version);
}
return encoded.join(',');
};
var detectLibraries = function() {
var tests = d41d8cd98f00b204e9800998ecf8427e_LibraryDetectorTests;
var libraries = [];
for (var i in tests) {
var result = tests[i].test(window);
if (result === false) continue;
libraries.push({
name: i,
version: result.version
});
}
return libraries;
};
if (window === top) {
var libs = detectLibraries();
if (libs.length > 0) {
document.getElementById('d41d8cd98f00b204e9800998ecf8427e_lib_detect').content = encodeLibraries(libs);
}
}
})();