Skip to content

Commit

Permalink
spoof callPhantom
Browse files Browse the repository at this point in the history
  • Loading branch information
Bei Zhang committed Sep 16, 2014
1 parent 58e6656 commit 2b7b246
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
16 changes: 16 additions & 0 deletions 2.detectCallPhantom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Detect callPhantom</title>
</head>
<body>
<script>
if (window.callPhantom || window._phantom) {
console.log("PhantomJS environment detected.");
} else {
console.log("PhantomJS environment not detected.");
}
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions 2.spoofCallPhantom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
page.onInitialized = function () {
page.evaluate(function () {
var p = window.callPhantom;
delete window._phantom;
delete window.callPhantom;
Object.defineProperty(window, "myCallPhantom", {
get: function () {
return p;
},
set: function () {
}, enumerable: false});
setTimeout(function () {
window.myCallPhantom();
}, 1000);
});
};

page.onCallback = function (obj) {
console.log('profit!');
};
1 change: 0 additions & 1 deletion load.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ page.onConsoleMessage = function (msg) {

page.onLoadFinished = function () {
page.evaluate(new Function(injectedJs));
phantom.exit(0);
};

page.open(system.args[1], function (status) {
Expand Down

0 comments on commit 2b7b246

Please sign in to comment.