-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpanel.js
54 lines (47 loc) · 1.67 KB
/
panel.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
chrome.devtools.panels.create(
"Meteor Console",
"meteor.png",
"meteor_console.html",
function(panel) {
panel.onShown.addListener(function(win) {
win.document.getElementById("run_eval").focus();
win.MeteorConsole_getOrigin = function(callback) {
chrome.devtools.inspectedWindow.eval('document.location.origin', function(result, isException) {
callback(result);
});
};
var _checkOrigin = function(origin, callback) {
chrome.devtools.inspectedWindow.eval('document.location.origin', function(result, isException) {
if (!isException && result === origin && callback) {
callback(true);
} else if (callback) {
callback();
}
});
};
var checkCrashText;
win.MeteorConsole_getCrashMessage = function(origin, callback) {
clearInterval(checkCrashText);
_checkOrigin(origin, function(ok) {
if (!ok) return callback();
chrome.devtools.inspectedWindow.eval('var xhr = new XMLHttpRequest();' +
'xhr.onload = function() {' +
'MeteorConsole_CrashText = this.responseText;' +
'};' +
'xhr.open("post", "", true);' +
'xhr.timeout = 1000;' +
'xhr.send();'
);
});
checkCrashText = setInterval(function() {
chrome.devtools.inspectedWindow.eval('MeteorConsole_CrashText', function(result, isException) {
if (!isException && callback && result.match(/^Your app is crashing/)) {
clearInterval(checkCrashText);
callback(result);
}
});
}, 100);
};
});
}
);