Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WPEngine detection #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down
Binary file added apps/wpengine.ico
Binary file not shown.
54 changes: 45 additions & 9 deletions detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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();
})();