Skip to content

Instantly share code, notes, and snippets.

@bewest
Last active December 12, 2015 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bewest/4706257 to your computer and use it in GitHub Desktop.
Save bewest/4706257 to your computer and use it in GitHub Desktop.
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
carelink.minimed.com FALSE / FALSE 0 JSESSIONID wdjGRT4Yp55cBXBLqW0jR8h9qPv3F82GJFC9xqLM8Jqdy4h2Mp8p!130490120!-1305453239
carelink.minimed.com FALSE / FALSE 0 bhCookieSess 1
#!/bin/bash
UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14"
JAR="cl.cookies"
default_url="https://carelink.minimed.com/patient/entry.jsp"
url=${1-"${default_url}"}
curl -A "${UA}" -c "${JAR}" -b "${JAR}" -L -v $url
#####
# EOF
console.log("HELLO WORLD!");
/*
cl = require('./script.js');
screen = {
colorDepth: 16,
};
navigator = {
};
document = { cookie : "bhCookieSess=1" };
self = {
location: { href: "",
replace: function(uri) {
console.log(uri);
console.log(document.cookie);
}
}
};
console.log( cl.bhawkTest( ));
*/
zombie = require("zombie");
UA="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14";
function handle_page(e, browser, status) {
console.log('handle_page', this, arguments);
console.log(browser.html( ));
console.log('exit?');
}
function loaded(e, browser) {
console.log("LOADED", this, arguments);
console.log(this.dump( ));
var browser = this;
console.log(this.html( ));
// browser.evaluate('document.onload( );');
// this.wait(browser, handle_page);
console.log('exit?');
return browser;
return "OK";
}
function hand_shake(e, browser) {
console.log("hand_shake", this, arguments);
console.log(browser.location.href);
/*
console.log('');
*/
// browser.wait( ).then(null, loaded);
console.log(browser.dump( ));
console.log(browser.html( ));
browser.log(browser.resources);
return browser.wait(do_handshake);
}
function do_handshake(window) {
console.log('XXX: do_handshake:', this, arguments);
console.log('document', window.document);
// console.log('document.window', window.document.window.window);
var w = window.document.window.window;
// console.log('window', w);
console.log('just before test', w.location.href, w.screen);
// w.bhawkTest( );
window.evaluate("navigator.language = 'en-us'; self = window; bhawkTest( );");
// window.evaluate("navigator.language = 'en-us'; bhawkTest( );");
// window.wait(loaded.bind(window));
console.log('just finished test', w.location.href, window.cookies);
return "OK";
}
function debug( ) {
console.log("debug", this, arguments);
return "OK";
}
browser = new zombie.Browser({userAgent: UA});
// default_url="https://carelink.minimed.com/patient/entry.jsp?bhcp=1";
var default_url="https://carelink.minimed.com/patient/entry.jsp";
// browser.visit(default_url, { debug: true }, hand_shake);
browser.on('done', debug);
browser.visit(default_url, { debug: true })
.then(function( ) {
return do_handshake(browser);
})
// .then(debug)
.then(function( ) {
browser.wait(loaded.bind(browser));
return browser;
})
.then(function( ) {
console.log("XXX: ALL DONE");
})
;
/*
.then(function( ) {
console.log("XXX: ALL DONE");
console.log(this, arguments);
console.log(browser.cookies);
console.log(browser.dump( ));
console.log("XXX: ALL DONE");
});
*/
console.log('browser', browser);
console.log("DONE");
HELLO WORLD!
browser { _cache: {},
_cookies: [Object],
_eventloop: [Object],
_storages: [Object],
_interact: [Object],
_xhr: [Object],
_events: [Object],
referer: undefined,
name: 'nodejs',
debug: true,
headers: {},
htmlParser: [Object],
loadCSS: true,
maxWait: '5s',
proxy: null,
runScripts: true,
silent: false,
site: undefined,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14',
waitFor: '0.5s',
errors: [],
resources: [Object],
windows: [Object],
_credentials: [Object] }
DONE
Zombie: 302 => https://carelink.minimed.com/patient/main/login.do
Zombie: 302 => https://carelink.minimed.com/patient/entry.jsp
Zombie: GET https://carelink.minimed.com/patient/entry.jsp => 200
debug { _cache: {},
_cookies: [Object],
_eventloop: [Object],
_storages: [Object],
_interact: [Object],
_xhr: [Object],
_events: [Object],
referer: undefined,
name: 'nodejs',
debug: true,
headers: {},
htmlParser: [Object],
loadCSS: true,
maxWait: '5s',
proxy: null,
runScripts: true,
silent: false,
site: undefined,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14',
waitFor: '0.5s',
errors: [],
resources: [Object],
windows: [Object],
_credentials: [Object],
response: [Object] } {}
XXX: do_handshake: { ArrayBuffer: [Function: ArrayBuffer],
Int8Array: [Object],
Uint8Array: [Object],
Uint8ClampedArray: [Object],
Int16Array: [Object],
Uint16Array: [Object],
Int32Array: [Object],
Uint32Array: [Object],
Float32Array: [Object],
Float64Array: [Object],
DataView: [Function: DataView],
global: [Circular],
process: [Object],
GLOBAL: [Circular],
root: [Circular],
Buffer: [Object],
setTimeout: [Function],
setInterval: [Function],
clearTimeout: [Function],
clearInterval: [Function],
console: [Getter],
zombie: [Object],
UA: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14',
browser: [Object] } { '0': [Object] }
document { _childNodes: [Object],
_ownerDocument: [Circular],
_attributes: [Object],
_nodeName: '#document',
_childrenList: null,
_version: 32,
_nodeValue: null,
_parentNode: null,
_readonly: false,
_tagName: '#document',
_contentType: 'text/html',
_doctype: null,
_implementation: [Object],
_documentElement: [Object],
_ids: {},
_attached: true,
_referrer: undefined,
_cookie: undefined,
_URL: 'https://carelink.minimed.com/patient/entry.jsp',
_documentRoot: 'https://carelink.minimed.com/patient',
_queue: [Object],
readyState: 'complete',
createWindow: [Function],
_listeners: [Object],
_parentWindow: [Object],
window: [Object] }
just before test https://carelink.minimed.com/patient/entry.jsp { width: 1280, height: 800, left: 0, top: 0 }
just finished test https://carelink.minimed.com/patient/entry.jsp?bhcp=1 [Function]
XXX: ALL DONE
debug { _cache: {},
_cookies: [Object],
_eventloop: [Object],
_storages: [Object],
_interact: [Object],
_xhr: [Object],
_events: [Object],
referer: undefined,
name: 'nodejs',
debug: false,
headers: {},
htmlParser: [Object],
loadCSS: true,
maxWait: '5s',
proxy: null,
runScripts: true,
silent: false,
site: undefined,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14',
waitFor: '0.5s',
errors: [],
resources: [Object],
windows: [Object],
_credentials: [Object],
response: [Object] } {}
LOADED { _cache: {},
_cookies: [Object],
_eventloop: [Object],
_storages: [Object],
_interact: [Object],
_xhr: [Object],
_events: [Object],
referer: undefined,
name: 'nodejs',
debug: false,
headers: {},
htmlParser: [Object],
loadCSS: true,
maxWait: '5s',
proxy: null,
runScripts: true,
silent: false,
site: undefined,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14',
waitFor: '0.5s',
errors: [],
resources: [Object],
windows: [Object],
_credentials: [Object],
response: [Object] } { '0': undefined }
Zombie: 1.4.1
URL: https://carelink.minimed.com/patient/entry.jsp?bhcp=1
History:
1: https://carelink.minimed.com/patient/entry.jsp?bhcp=1
JSESSIONID=1xVfRPpLs9s24LbTTlQNpCxDjJqh2LTLnTJFXGnPBxhDC4JvzdLR!2068862828!804625618; Domain=carelink.minimed.com; Path=/
locale=en_US; Expires=Sat, 03 Aug 2013 11:43:41 GMT; Domain=carelink.minimed.com; Path=/
s_cc=true; Domain=minimed.com; Path=/
s_nr=1359978222853; Expires=Wed, 06 Mar 2013 11:43:42 GMT; Domain=minimed.com; Path=/
s_sq=%5B%5BB%5D%5D; Domain=minimed.com; Path=/
Cookies:
true
true
true
true
true
Storage:
Eventloop:
The time: Mon Feb 04 2013 03:43:42 GMT-0800 (PST)
Timers: 0
Processing: 0
Waiting: 0
Document:
<!DOCTYPE HTML><html lang="en-US"><head>
<title>Medtronic CareLink Therapy Management Software for Diabetes</title>
<style type="text/css" media="all">
@import url( /stylesheets/welcome.css );
@import url( /stylesheets/en/welcome.css );
@import url( /stylesheets/locations.css );
</style>
<script type="text/javascript" src="/javascript/locales.js"></script>
<script type="text/javascript">
var newwin;
...
true
<html lang="en-US"><head>
<title>Medtronic CareLink Therapy Management Software for Diabetes</title>
<style type="text/css" media="all">
@import url( /stylesheets/welcome.css );
@import url( /stylesheets/en/welcome.css );
@import url( /stylesheets/locations.css );
</style>
<script type="text/javascript" src="/javascript/locales.js"></script>
<script type="text/javascript">
var newwin;
var newwinFeatures = "height=500,location=no,menubar=no,resizeable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no,width=440";
function popupExplanation(href) {
newwin = window.open(href, "explanation", newwinFeatures);
newwin.focus();
return this;
}
</script>
</head>
<body onload="document.login.j_username.focus();"><img src="https://b.medtronic.com/b/ss/medtronicdiabetescarelinkprodus/1/H.15.1/s34085272855591?[AQB]&amp;ndh=1&amp;t=4/1/2013%203%3A43%3A42%201%20480&amp;ce=UTF-8&amp;ns=medtronic&amp;cdp=2&amp;pageName=patient/entry.jsp&amp;g=https%3A//carelink.minimed.com/patient/entry.jsp%3Fbhcp%3D1&amp;cc=USD&amp;ch=Main&amp;events=event20&amp;c12=New&amp;v12=New&amp;c13=patient/entry.jsp&amp;c17=3%3A30AM&amp;v17=3%3A30AM&amp;c18=Monday&amp;v18=Monday&amp;c19=Weekday&amp;v19=Weekday&amp;j=1.6&amp;k=Y&amp;[AQE]" width="1" height="1" border="0" alt="" /></body></html>
exit?
function bhawkTest() {
var bhcd = screen.colorDepth;
var bhsh = screen.height;
var bhsw = screen.width;
var d = new Date();
var bhtz = Math.round((0 - d.getTimezoneOffset())/15) / 4.0;
var bhlu = navigator.language ? navigator.language.toLowerCase():'xx';
var hashIndex = self.location.href.indexOf("#");
if (hashIndex == -1) {
hash = "";
} else {
hash = self.location.href.substring(hashIndex);
hash = "&bhhash=1" + hash;
}
var rs = "bhcd="+bhcd+"&bhsh="+bhsh+"&bhsw="+bhsw+"&bhtz="+bhtz+"&bhlu="+bhlu;
if (document.cookie.indexOf("bhCookieSess=1") != -1) {
document.cookie = "bhResults="+rs+"; path=/";
if (document.cookie.indexOf("bhResults") != -1)
self.location.replace("https://carelink.minimed.com/patient/entry.jsp?bhcp=1"+hash);
else self.location.replace("https://carelink.minimed.com/patient/entry.jsp?bhcp=1&"+rs+"&bhqs=1"+hash);
}
else self.location.replace("https://carelink.minimed.com/patient/entry.jsp?bhcp=1&"+rs+"&bhqs=1"+hash);
}
// -->
exports.bhawkTest = bhawkTest;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment