phantomjs.rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +16 -0
- data/Rakefile +1 -0
- data/lib/phantomjs.rb +53 -0
- data/lib/phantomjs/version.rb +3 -0
- data/phantomjs.rb.gemspec +24 -0
- data/spec/phantomjs_spec.rb +13 -0
- data/spec/runner.js +2 -0
- data/vendor/phantomjs-1.4.1_OSX/ChangeLog +145 -0
- data/vendor/phantomjs-1.4.1_OSX/LICENSE.BSD +22 -0
- data/vendor/phantomjs-1.4.1_OSX/README.md +33 -0
- data/vendor/phantomjs-1.4.1_OSX/bin/Info.plist +12 -0
- data/vendor/phantomjs-1.4.1_OSX/bin/phantomjs +0 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/arguments.coffee +6 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/arguments.js +8 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.coffee +46 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/colorwheel.js +51 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/countdown.coffee +8 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/countdown.js +9 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.coffee +40 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/detectsniff.js +57 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/direction.coffee +29 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/direction.js +34 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.coffee +19 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/echoToFile.js +22 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/features.js +30 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/fibo.coffee +8 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/fibo.js +9 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/follow.coffee +54 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/follow.js +59 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/hello.coffee +2 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/hello.js +2 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.coffee +19 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/imagebin.js +22 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/injectme.coffee +23 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/injectme.js +25 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.coffee +13 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/ipgeocode.js +14 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.coffee +17 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/loadspeed.js +22 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/modernizr.js +1116 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/movies.coffee +13 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/movies.js +14 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/netlog.coffee +17 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/netlog.js +23 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.coffee +109 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/netsniff.js +131 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.coffee +12 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/outputEncoding.js +16 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.coffee +13 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/phantomwebintro.js +19 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/pizza.coffee +18 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/pizza.js +20 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/post.coffee +12 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/post.js +14 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.coffee +22 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/rasterize.js +27 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.coffee +48 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/render_multi_url.js +60 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.coffee +59 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/run-jasmine.js +77 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.coffee +62 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/run-qunit.js +74 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/scandir.coffee +15 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/scandir.js +21 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.coffee +17 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/seasonfood.js +19 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.coffee +35 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/simpleserver.js +40 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.coffee +17 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/sleepsort.js +24 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/technews.coffee +17 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/technews.js +16 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/tweets.coffee +30 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/tweets.js +36 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.coffee +18 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/unrandomize.js +24 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/useragent.coffee +11 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/useragent.js +14 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/version.coffee +5 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/version.js +5 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.coffee +48 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/waitfor.js +57 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/weather.coffee +48 -0
- data/vendor/phantomjs-1.4.1_OSX/examples/weather.js +57 -0
- data/vendor/phantomjs-1.4.1_OSX/lib/jquery.js +8374 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/ChangeLog +177 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/LICENSE.BSD +22 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/README.md +33 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/Info.plist +12 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/bin/phantomjs +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.coffee +7 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/arguments.js +9 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.coffee +46 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/colorwheel.js +51 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.coffee +8 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/countdown.js +9 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.coffee +41 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/detectsniff.js +58 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.coffee +30 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/direction.js +35 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.coffee +20 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/echoToFile.js +24 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/features.js +30 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.coffee +8 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/fibo.js +9 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.coffee +29 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/follow.js +34 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.coffee +2 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/hello.js +2 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.coffee +20 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/imagebin.js +23 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.coffee +23 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/injectme.js +25 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.coffee +13 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/ipgeocode.js +14 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.coffee +18 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/loadspeed.js +23 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/modernizr.js +1116 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.coffee +13 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/movies.js +14 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.coffee +18 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netlog.js +25 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.coffee +110 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/netsniff.js +132 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.coffee +12 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/outputEncoding.js +16 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.coffee +13 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/phantomwebintro.js +19 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.coffee +18 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/pizza.js +20 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.coffee +12 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/post.js +14 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/postserver.js +34 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printenv.js +10 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/printmargins.js +35 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.coffee +23 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/rasterize.js +28 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.coffee +50 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/render_multi_url.js +62 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.coffee +61 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-jasmine.js +79 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.coffee +64 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/run-qunit.js +76 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.coffee +16 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/scandir.js +22 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.coffee +17 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/seasonfood.js +19 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/server.js +43 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/serverkeepalive.js +34 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.coffee +38 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/simpleserver.js +42 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.coffee +20 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/sleepsort.js +25 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.coffee +17 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/technews.js +16 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.coffee +31 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/tweets.js +37 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.coffee +18 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/unrandomize.js +24 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.coffee +11 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/useragent.js +14 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.coffee +5 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/version.js +5 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.coffee +48 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/waitfor.js +57 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.coffee +49 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/examples/weather.js +58 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.la +28 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.prl +7 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtCore.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.la +28 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.prl +7 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtGui.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.la +28 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.prl +7 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtNetwork.so.4.8.0 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.la +28 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.prl +6 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9 +0 -0
- data/vendor/phantomjs-1.5.0-liunx-x86-dynamic/lib/libQtWebKit.so.4.9.0 +0 -0
- metadata +252 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
page = require('webpage').create()
|
2
|
+
|
3
|
+
page.onInitialized = ->
|
4
|
+
page.evaluate ->
|
5
|
+
userAgent = window.navigator.userAgent
|
6
|
+
platform = window.navigator.platform
|
7
|
+
window.navigator =
|
8
|
+
appCodeName: 'Mozilla'
|
9
|
+
appName: 'Netscape'
|
10
|
+
cookieEnabled: false
|
11
|
+
sniffed: false
|
12
|
+
|
13
|
+
window.navigator.__defineGetter__ 'userAgent', ->
|
14
|
+
window.navigator.sniffed = true
|
15
|
+
userAgent
|
16
|
+
|
17
|
+
window.navigator.__defineGetter__ 'platform', ->
|
18
|
+
window.navigator.sniffed = true
|
19
|
+
platform
|
20
|
+
|
21
|
+
if phantom.args.length is 0
|
22
|
+
console.log 'Usage: unsniff.js <some URL>'
|
23
|
+
phantom.exit()
|
24
|
+
else
|
25
|
+
address = phantom.args[0]
|
26
|
+
console.log 'Checking ' + address + '...'
|
27
|
+
page.open address, (status) ->
|
28
|
+
if status isnt 'success'
|
29
|
+
console.log 'FAIL to load the address'
|
30
|
+
else
|
31
|
+
window.setTimeout ->
|
32
|
+
sniffed = page.evaluate(->
|
33
|
+
navigator.sniffed
|
34
|
+
)
|
35
|
+
if sniffed
|
36
|
+
console.log 'The page tried to sniff the user agent.'
|
37
|
+
else
|
38
|
+
console.log 'The page did not try to sniff the user agent.'
|
39
|
+
phantom.exit()
|
40
|
+
, 1500
|
@@ -0,0 +1,57 @@
|
|
1
|
+
// Detect if a web page sniffs the user agent or not.
|
2
|
+
|
3
|
+
var page = require('webpage').create(),
|
4
|
+
sniffed,
|
5
|
+
address;
|
6
|
+
|
7
|
+
page.onInitialized = function () {
|
8
|
+
page.evaluate(function () {
|
9
|
+
|
10
|
+
(function () {
|
11
|
+
var userAgent = window.navigator.userAgent,
|
12
|
+
platform = window.navigator.platform;
|
13
|
+
|
14
|
+
window.navigator = {
|
15
|
+
appCodeName: 'Mozilla',
|
16
|
+
appName: 'Netscape',
|
17
|
+
cookieEnabled: false,
|
18
|
+
sniffed: false
|
19
|
+
};
|
20
|
+
|
21
|
+
window.navigator.__defineGetter__('userAgent', function () {
|
22
|
+
window.navigator.sniffed = true;
|
23
|
+
return userAgent;
|
24
|
+
});
|
25
|
+
|
26
|
+
window.navigator.__defineGetter__('platform', function () {
|
27
|
+
window.navigator.sniffed = true;
|
28
|
+
return platform;
|
29
|
+
});
|
30
|
+
})();
|
31
|
+
});
|
32
|
+
};
|
33
|
+
|
34
|
+
if (phantom.args.length === 0) {
|
35
|
+
console.log('Usage: unsniff.js <some URL>');
|
36
|
+
phantom.exit();
|
37
|
+
} else {
|
38
|
+
address = phantom.args[0];
|
39
|
+
console.log('Checking ' + address + '...');
|
40
|
+
page.open(address, function (status) {
|
41
|
+
if (status !== 'success') {
|
42
|
+
console.log('FAIL to load the address');
|
43
|
+
} else {
|
44
|
+
window.setTimeout(function () {
|
45
|
+
sniffed = page.evaluate(function () {
|
46
|
+
return navigator.sniffed;
|
47
|
+
});
|
48
|
+
if (sniffed) {
|
49
|
+
console.log('The page tried to sniff the user agent.');
|
50
|
+
} else {
|
51
|
+
console.log('The page did not try to sniff the user agent.');
|
52
|
+
}
|
53
|
+
phantom.exit();
|
54
|
+
}, 1500);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Get driving direction using Google Directions API.
|
2
|
+
|
3
|
+
page = require('webpage').create()
|
4
|
+
|
5
|
+
if phantom.args.length < 2
|
6
|
+
console.log 'Usage: direction.js origin destination'
|
7
|
+
console.log 'Example: direction.js "San Diego" "Palo Alto"'
|
8
|
+
phantom.exit(1)
|
9
|
+
else
|
10
|
+
origin = phantom.args[0]
|
11
|
+
dest = phantom.args[1]
|
12
|
+
page.open encodeURI('http://maps.googleapis.com/maps/api/directions/xml?origin=' + origin +
|
13
|
+
'&destination=' + dest + '&units=imperial&mode=driving&sensor=false'),
|
14
|
+
(status) ->
|
15
|
+
if status isnt 'success'
|
16
|
+
console.log 'Unable to access network'
|
17
|
+
else
|
18
|
+
steps = page.content.match(/<html_instructions>(.*)<\/html_instructions>/ig)
|
19
|
+
if not steps
|
20
|
+
console.log 'No data available for ' + origin + ' to ' + dest
|
21
|
+
else
|
22
|
+
for ins in steps
|
23
|
+
ins = ins.replace(/\</ig, '<').replace(/\>/ig, '>')
|
24
|
+
ins = ins.replace(/\<div/ig, '\n<div')
|
25
|
+
ins = ins.replace(/<.*?>/g, '')
|
26
|
+
console.log(ins)
|
27
|
+
console.log ''
|
28
|
+
console.log page.content.match(/<copyrights>.*<\/copyrights>/ig).join('').replace(/<.*?>/g, '')
|
29
|
+
phantom.exit()
|
@@ -0,0 +1,34 @@
|
|
1
|
+
// Get driving direction using Google Directions API.
|
2
|
+
|
3
|
+
var page = require('webpage').create(),
|
4
|
+
origin, dest, steps;
|
5
|
+
|
6
|
+
if (phantom.args.length < 2) {
|
7
|
+
console.log('Usage: direction.js origin destination');
|
8
|
+
console.log('Example: direction.js "San Diego" "Palo Alto"');
|
9
|
+
phantom.exit(1);
|
10
|
+
} else {
|
11
|
+
origin = phantom.args[0];
|
12
|
+
dest = phantom.args[1];
|
13
|
+
page.open(encodeURI('http://maps.googleapis.com/maps/api/directions/xml?origin=' + origin +
|
14
|
+
'&destination=' + dest + '&units=imperial&mode=driving&sensor=false'), function (status) {
|
15
|
+
if (status !== 'success') {
|
16
|
+
console.log('Unable to access network');
|
17
|
+
} else {
|
18
|
+
steps = page.content.match(/<html_instructions>(.*)<\/html_instructions>/ig);
|
19
|
+
if (steps == null) {
|
20
|
+
console.log('No data available for ' + origin + ' to ' + dest);
|
21
|
+
} else {
|
22
|
+
steps.forEach(function (ins) {
|
23
|
+
ins = ins.replace(/\</ig, '<').replace(/\>/ig, '>');
|
24
|
+
ins = ins.replace(/\<div/ig, '\n<div');
|
25
|
+
ins = ins.replace(/<.*?>/g, '');
|
26
|
+
console.log(ins);
|
27
|
+
});
|
28
|
+
console.log('');
|
29
|
+
console.log(page.content.match(/<copyrights>.*<\/copyrights>/ig).join('').replace(/<.*?>/g, ''));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
phantom.exit();
|
33
|
+
});
|
34
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# echoToFile.coffee - Write in a given file all the parameters passed on the CLI
|
2
|
+
fs = require 'fs'
|
3
|
+
|
4
|
+
if phantom.args.length < 2
|
5
|
+
console.log "Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>"
|
6
|
+
phantom.exit()
|
7
|
+
else
|
8
|
+
content = ""
|
9
|
+
f = null
|
10
|
+
i = 1
|
11
|
+
while i < phantom.args.length
|
12
|
+
content += phantom.args[i] + (if i == phantom.args.length - 1 then "" else " ")
|
13
|
+
++i
|
14
|
+
try
|
15
|
+
f = fs.open(phantom.args[0], "w")
|
16
|
+
f.writeLine content
|
17
|
+
catch e
|
18
|
+
console.log e
|
19
|
+
phantom.exit()
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// echoToFile.js - Write in a given file all the parameters passed on the CLI
|
2
|
+
var fs = require('fs');
|
3
|
+
|
4
|
+
if (phantom.args.length < 2) {
|
5
|
+
console.log("Usage: echoToFile.js DESTINATION_FILE <arguments to echo...>");
|
6
|
+
phantom.exit();
|
7
|
+
} else {
|
8
|
+
var content = '',
|
9
|
+
f = null;
|
10
|
+
for ( i= 1; i < phantom.args.length; ++i ) {
|
11
|
+
content += phantom.args[i] + (i === phantom.args.length-1 ? '' : ' ');
|
12
|
+
}
|
13
|
+
|
14
|
+
try {
|
15
|
+
f = fs.open(phantom.args[0], "w");
|
16
|
+
f.writeLine(content);
|
17
|
+
} catch (e) {
|
18
|
+
console.log(e);
|
19
|
+
}
|
20
|
+
|
21
|
+
phantom.exit();
|
22
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
var feature, supported = [], unsupported = [];
|
2
|
+
|
3
|
+
phantom.injectJs('modernizr.js');
|
4
|
+
console.log('Detected features (using Modernizr ' + Modernizr._version + '):');
|
5
|
+
for (feature in Modernizr) {
|
6
|
+
if (Modernizr.hasOwnProperty(feature)) {
|
7
|
+
if (feature[0] !== '_' && typeof Modernizr[feature] !== 'function' &&
|
8
|
+
feature !== 'input' && feature !== 'inputtypes') {
|
9
|
+
if (Modernizr[feature]) {
|
10
|
+
supported.push(feature);
|
11
|
+
} else {
|
12
|
+
unsupported.push(feature);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
console.log('');
|
19
|
+
console.log('Supported:');
|
20
|
+
supported.forEach(function (e) {
|
21
|
+
console.log(' ' + e);
|
22
|
+
});
|
23
|
+
|
24
|
+
console.log('');
|
25
|
+
console.log('Not supported:');
|
26
|
+
unsupported.forEach(function (e) {
|
27
|
+
console.log(' ' + e);
|
28
|
+
});
|
29
|
+
phantom.exit();
|
30
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# List following and followers from several accounts
|
2
|
+
|
3
|
+
users= [
|
4
|
+
'sencha'
|
5
|
+
'aconran'
|
6
|
+
'adityabansod'
|
7
|
+
'ambisinister'
|
8
|
+
'arnebech'
|
9
|
+
'ariyahidayat'
|
10
|
+
'arthurakay'
|
11
|
+
'bmoeskau'
|
12
|
+
'darrellmeyer'
|
13
|
+
'davidfoelber'
|
14
|
+
'DavidKaneda'
|
15
|
+
'donovanerba'
|
16
|
+
'edspencer'
|
17
|
+
'evantrimboli'
|
18
|
+
'ExtAnimal'
|
19
|
+
'jamieavins'
|
20
|
+
'jarrednicholls'
|
21
|
+
'jayrobinson'
|
22
|
+
'lojjic'
|
23
|
+
'luckymethod'
|
24
|
+
'merrells'
|
25
|
+
'mmullany'
|
26
|
+
'philogb'
|
27
|
+
'philstrong'
|
28
|
+
'rdougan'
|
29
|
+
'SubtleGradient'
|
30
|
+
'__ted__'
|
31
|
+
'tmaintz'
|
32
|
+
'WesleyMoy'
|
33
|
+
'whereisthysting'
|
34
|
+
]
|
35
|
+
|
36
|
+
follow = (user, callback) ->
|
37
|
+
page = require('webpage').create()
|
38
|
+
page.open 'http://mobile.twitter.com/' + user, (status) ->
|
39
|
+
if status is 'fail'
|
40
|
+
console.log user + ': ?'
|
41
|
+
else
|
42
|
+
data = page.evaluate -> document.querySelector('div.timeline-following').innerText
|
43
|
+
console.log user + ': ' + data
|
44
|
+
callback.apply()
|
45
|
+
|
46
|
+
process = () ->
|
47
|
+
if (users.length > 0)
|
48
|
+
user = users[0]
|
49
|
+
users.splice(0, 1)
|
50
|
+
follow(user, process)
|
51
|
+
else
|
52
|
+
phantom.exit()
|
53
|
+
|
54
|
+
process()
|
@@ -0,0 +1,59 @@
|
|
1
|
+
// List following and followers from several accounts
|
2
|
+
|
3
|
+
var users = ['sencha',
|
4
|
+
'aconran',
|
5
|
+
'adityabansod',
|
6
|
+
'ambisinister',
|
7
|
+
'arnebech',
|
8
|
+
'ariyahidayat',
|
9
|
+
'arthurakay',
|
10
|
+
'bmoeskau',
|
11
|
+
'darrellmeyer',
|
12
|
+
'davidfoelber',
|
13
|
+
'DavidKaneda',
|
14
|
+
'donovanerba',
|
15
|
+
'edspencer',
|
16
|
+
'evantrimboli',
|
17
|
+
'ExtAnimal',
|
18
|
+
'jamieavins',
|
19
|
+
'jarrednicholls',
|
20
|
+
'jayrobinson',
|
21
|
+
'lojjic',
|
22
|
+
'luckymethod',
|
23
|
+
'merrells',
|
24
|
+
'mmullany',
|
25
|
+
'philogb',
|
26
|
+
'philstrong',
|
27
|
+
'rdougan',
|
28
|
+
'SubtleGradient',
|
29
|
+
'__ted__',
|
30
|
+
'tmaintz',
|
31
|
+
'WesleyMoy',
|
32
|
+
'whereisthysting'];
|
33
|
+
|
34
|
+
function follow(user, callback) {
|
35
|
+
var page = require('webpage').create();
|
36
|
+
page.open('http://mobile.twitter.com/' + user, function (status) {
|
37
|
+
if (status === 'fail') {
|
38
|
+
console.log(user + ': ?');
|
39
|
+
} else {
|
40
|
+
var data = page.evaluate(function () {
|
41
|
+
return document.querySelector('div.timeline-following').innerText;
|
42
|
+
});
|
43
|
+
console.log(user + ': ' + data);
|
44
|
+
}
|
45
|
+
callback.apply();
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
function process() {
|
50
|
+
if (users.length > 0) {
|
51
|
+
var user = users[0];
|
52
|
+
users.splice(0, 1);
|
53
|
+
follow(user, process);
|
54
|
+
} else {
|
55
|
+
phantom.exit();
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
process();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Upload an image to imagebin.org
|
2
|
+
|
3
|
+
page = require('webpage').create()
|
4
|
+
|
5
|
+
if phantom.args.length isnt 1
|
6
|
+
console.log 'Usage: imagebin.coffee filename'
|
7
|
+
phantom.exit()
|
8
|
+
else
|
9
|
+
fname = phantom.args[0]
|
10
|
+
page.open 'http://imagebin.org/index.php?page=add', ->
|
11
|
+
page.uploadFile 'input[name=image]', fname
|
12
|
+
page.evaluate ->
|
13
|
+
document.querySelector('input[name=nickname]').value = 'phantom'
|
14
|
+
document.querySelector('input[name=disclaimer_agree]').click()
|
15
|
+
document.querySelector('form').submit()
|
16
|
+
|
17
|
+
window.setTimeout ->
|
18
|
+
phantom.exit()
|
19
|
+
, 3000
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// Upload an image to imagebin.org
|
2
|
+
|
3
|
+
var page = require('webpage').create(),
|
4
|
+
fname;
|
5
|
+
|
6
|
+
if (phantom.args.length !== 1) {
|
7
|
+
console.log('Usage: imagebin.js filename');
|
8
|
+
phantom.exit();
|
9
|
+
} else {
|
10
|
+
fname = phantom.args[0];
|
11
|
+
page.open("http://imagebin.org/index.php?page=add", function () {
|
12
|
+
page.uploadFile('input[name=image]', fname);
|
13
|
+
page.evaluate(function () {
|
14
|
+
document.querySelector('input[name=nickname]').value = 'phantom';
|
15
|
+
document.querySelector('input[name=disclaimer_agree]').click()
|
16
|
+
document.querySelector('form').submit();
|
17
|
+
});
|
18
|
+
window.setTimeout(function () {
|
19
|
+
phantom.exit();
|
20
|
+
}, 3000);
|
21
|
+
});
|
22
|
+
}
|