diff --git a/apps.js b/apps.js index 3b5120d..98ce5b8 100755 --- a/apps.js +++ b/apps.js @@ -122,6 +122,11 @@ var appinfo = { url: 'http://wordpress.org', priority: 1 }, + 'WP Engine': { + icon: 'wpengine.ico', + url: 'http://wpengine.com', + priority: 1 + }, 'WPML': { icon: 'WPML.ico', url: 'http://wpml.org/', diff --git a/apps/wpengine.ico b/apps/wpengine.ico new file mode 100644 index 0000000..36808ff Binary files /dev/null and b/apps/wpengine.ico differ diff --git a/detector.js b/detector.js index 0b5f5c6..2b044ea 100755 --- a/detector.js +++ b/detector.js @@ -14,6 +14,20 @@ var name; var r; + function ready() { + // convert to array + var jsonString = JSON.stringify(_apps); + + // send back to background page + var meta = document.getElementById('chromesniffer_meta'); + meta.content = jsonString; + + // notify background page + var done = document.createEvent('Event'); + done.initEvent('ready', true, true); + meta.dispatchEvent(done); + } + // 1: detect by meta tags, the first matching group will be version var metas = doc.getElementsByTagName("meta"); var meta_tests = { @@ -443,14 +457,36 @@ } } - // convert to array - var jsonString = JSON.stringify(_apps); - // send back to background page - var meta = document.getElementById('chromesniffer_meta'); - meta.content = jsonString; + // 10: detect based on other files on the server + + var xhr_tests = { + 'WP Engine': { + 'uri': '/wp-content/mu-plugins/wpengine-common/changelog.txt', + 'require': 'WordPress' + } + } + + for (var t in xhr_tests) { + if (_apps[xhr_tests[t].require]) { + var request = new XMLHttpRequest; + + request.open("HEAD", window.location.origin + xhr_tests[t].uri); + + request.addEventListener( + "load", + function() { + if (request.status == 200) { + _apps[t] = -1; + + ready(); + } + }, + false + ); + + request.send(); + } + } - //Notify Background Page - var done = document.createEvent('Event'); - done.initEvent('ready', true, true); - meta.dispatchEvent(done); + ready(); })();