-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.js
39 lines (35 loc) · 1.2 KB
/
utils.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
var jsdom = require('jsdom');
var request = require('request');
var blockchainUrl = 'https://blockchain.info';
var discusFishUrl = blockchainUrl + '/address/1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY';
function sendRequest(url, callback) {
console.log('Send request: ' + url);
request(url, function(err, response, body) {
if( err || !response || response.statusCode !== 200 ) {
console.log('Response error: ' + response.statusCode);
sendRequest(url, callback);
} else
jsdom.env({
html: body,
scripts: ['./jquery-1.11.1.min.js'],
done: function(err, window) {
if( err ) {
console.log('Error: ' + err);
sendRequest(url, callback);
} else {
console.log('Success');
callback(window.jQuery);
}
}
});
});
}
function getPageElements($) {
return $('#tx_container').find('.txdiv');
}
module.exports = {
blockchainUrl: blockchainUrl,
discusFishUrl: discusFishUrl,
sendRequest: sendRequest,
getPageElements: getPageElements
};