Last active
December 12, 2015 07:18
-
-
Save ishiduca/4735811 to your computer and use it in GitHub Desktop.
http-cookies 用の cookie_jar.cookies を生成する Generator と Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = | |
module.exports = { | |
domain: ('.pixiv.net www.pixiv.net i9.pixiv.net img.pixiv.net .pixiv.org').split(' ') | |
, path: ('/ /pro /profile /prototype /pro/file').split(' ') | |
, key: ('PHPSESSID node_session_id ID _id over18').split(' ') | |
, value: ('red <> blue <> black <> white <> yellow <> yelow hearts <> B&L <> abc=ABC;') | |
.split(' <> ') | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path') | |
, data = require(path.join( __dirname, 'data')) | |
; | |
var generator = | |
module.exports = function () { | |
return data.domain.reduce(function (jar, domain_) { | |
jar[domain_] = data.path.reduce(function (domain, path_) { | |
domain[path_] = data.key.reduce(function (pth, key_) { | |
pth[key_] = generate_cookie() | |
return pth; | |
}, {}); | |
return domain; | |
}, {}); | |
return jar; | |
}, {}); | |
}; | |
function generate_cookie () { | |
var cookie = { | |
value: data.value[ | |
Math.round(Math.random() * 10) % data.value.length ] | |
}; | |
var expires = generate_expires(); expires && (cookie.expires = expires); | |
flg() && (cookie.HttpOnly = ''); | |
flg() && (cookie.Secure= ''); | |
return cookie; | |
} | |
function generate_expires () { | |
if (flg()) | |
return (new Date( | |
Date.now() | |
+ (1000 * 60 * Math.round(Math.random() * 100)) * (flg() ? 1 : -1) | |
)).toUTCString(); | |
} | |
function flg () { return Math.round(Math.random() * 10) % 2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
のような構造体を吐く