From 6b1289c0340982bd06ffc0ae67d82151c5354596 Mon Sep 17 00:00:00 2001 From: GuPan Date: Sun, 10 Jun 2018 23:55:03 +0900 Subject: [PATCH] feat: add fetchWXBox --- .gitignore | 1 + dist/index.js | 30 +++++++++++++++++++++++++++--- dist/index.js.map | 2 +- src/index.js | 27 ++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c556aed..dd898b8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules *.sublime-workspace *.sublime-project +package-lock.json diff --git a/dist/index.js b/dist/index.js index e199ce1..a0d1116 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,4 +1,4 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o p').textContent info.timestamp = Date.now() info.wxid = doc.querySelector('.card_detail_title > p').textContent info.name = doc.querySelector('.card_detail_title > h3').firstChild.textContent @@ -489,6 +489,15 @@ function toInfo(doc, id) { /* fetch */ function fetchById (tar, i) { let url = `http://${domain}/products/wixoss/card/card_detail.php?card_id=${i}` + return fetchByUrl(tar, url, i) +} + +function fetchByWXId(tar, wx_id) { + let url = `http://${domain}/products/wixoss/card/card_list.php?card=card_detail&card_no=${wx_id}` + return fetchByUrl(tar, url, undefined) +} + +function fetchByUrl(tar, url, i) { return $fetch(url) .then(res => res.text()) .then(html => { @@ -530,6 +539,21 @@ function fetchRange(min, max) { }) } +// fetchWXBox("WDK02", 1, 20) +function fetchWXBox(prefix, min, max) { + let tar = new Tar() + let promises = [] + for (let i = min; i <= max; i ++) { + const wx_id = `${prefix}-${('00' + i).slice(-3)}`; + promises.push(fetchByWXId(tar, wx_id)) + } + return Promise.all(promises) + .then(() => { + let name = ('000' + min).slice(-4) + '-' + ('000' + max).slice(-4) + downloadTar(tar, name) + }) +} + function downloadTar(tar, name) { let blob = new Blob([tar.out], { type: 'application/octet-stream' }) let url = URL.createObjectURL(blob) @@ -540,8 +564,8 @@ function downloadTar(tar, name) { } window.fetchRange = fetchRange +window.fetchWXBox = fetchWXBox },{"tar-js":2}]},{},[4]) - //# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map index ab4ae03..fff877d 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["node_modules/browser-pack/_prelude.js","node_modules/tar-js/lib/header.js","node_modules/tar-js/lib/tar.js","node_modules/tar-js/lib/utils.js","src/index.js"],"names":[],"mappings":"AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o this.out.length) {\n\t\t\tthis.out = utils.extend(this.out, this.written, input.length, blockSize);\n\t\t}\n\n\t\tthis.out.set(input, this.written);\n\n\t\t// to the nearest multiple of recordSize\n\t\tthis.written += input.length + (recordSize - (input.length % recordSize || recordSize));\n\n\t\t// make sure there's at least 2 empty records worth of extra space\n\t\tif (this.out.length - this.written < recordSize * 2) {\n\t\t\tthis.out = utils.extend(this.out, this.written, recordSize * 2, blockSize);\n\t\t}\n\n\t\tif (typeof callback === 'function') {\n\t\t\tcallback(this.out);\n\t\t}\n\n\t\treturn this.out;\n\t};\n\n\tTar.prototype.clear = function () {\n\t\tthis.written = 0;\n\t\tthis.out = utils.clean(blockSize);\n\t};\n\n Tar.utils = utils;\n\n\tTar.stringToUint8 = utils.stringToUint8;\n\tTar.uint8ToBase64 = utils.uint8ToBase64;\n Tar.base64ToUint8 = utils.base64ToUint8;\n\t\n\tmodule.exports = Tar;\n}());\n","/*\n * tar-js\n * MIT (c) 2011 T. Jameson Little\n */\n\n(function () {\n\t\"use strict\";\n\n\tvar lookup = [\n\t\t\t'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',\n\t\t\t'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\n\t\t\t'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',\n\t\t\t'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',\n\t\t\t'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',\n\t\t\t'o', 'p', 'q', 'r', 's', 't', 'u', 'v',\n\t\t\t'w', 'x', 'y', 'z', '0', '1', '2', '3',\n\t\t\t'4', '5', '6', '7', '8', '9', '+', '/'\n\t\t];\n\tfunction clean(length) {\n\t\tvar i, buffer = new Uint8Array(length);\n\t\tfor (i = 0; i < length; i += 1) {\n\t\t\tbuffer[i] = 0;\n\t\t}\n\t\treturn buffer;\n\t}\n\n\tfunction extend(orig, length, addLength, multipleOf) {\n\t\tvar newSize = length + addLength,\n\t\t\tbuffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf);\n\n\t\tbuffer.set(orig);\n\n\t\treturn buffer;\n\t}\n\n\tfunction pad(num, bytes, base) {\n\t\tnum = num.toString(base || 8);\n\t\treturn \"000000000000\".substr(num.length + 12 - bytes) + num;\n\t}\t\n\t\n\tfunction stringToUint8 (input, out, offset) {\n\t\tvar i, length;\n\n\t\tout = out || clean(input.length);\n\n\t\toffset = offset || 0;\n\t\tfor (i = 0, length = input.length; i < length; i += 1) {\n\t\t\tout[offset] = input.charCodeAt(i);\n\t\t\toffset += 1;\n\t\t}\n\n\t\treturn out;\n\t}\n\n\tfunction uint8ToBase64(uint8) {\n\t\tvar i,\n\t\t\textraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes\n\t\t\toutput = \"\",\n\t\t\ttemp, length;\n\n\t\tfunction tripletToBase64 (num) {\n\t\t\treturn lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];\n\t\t};\n\n\t\t// go through the array every three bytes, we'll deal with trailing stuff later\n\t\tfor (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {\n\t\t\ttemp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);\n\t\t\toutput += tripletToBase64(temp);\n\t\t}\n\n\t\t// this prevents an ERR_INVALID_URL in Chrome (Firefox okay)\n\t\tswitch (output.length % 4) {\n\t\t\tcase 1:\n\t\t\t\toutput += '=';\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\toutput += '==';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\tfunction base64ToUint8(input) {\n\t\tvar base64 = input.match(/^([^=]+)/)[1],\n\t\t\textraBytes = input.match(/(=*)$/)[1].length,\n\t\t\ti = 0, length = base64.length, temp, offset = 0,\n\t\t\tret = clean(base64.length * .75 + extraBytes);\n\n\t\twhile (i < length) {\n\t\t\ttemp = 0;\n\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A') << 18;\n\t\t\ti += 1;\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A') << 12;\n\t\t\ti += 1;\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A') << 6;\n\t\t\ti += 1;\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A');\n\t\t\ti += 1;\n\n\t\t\tret[offset] = temp >> 16 & 0xFF;\n\t\t\toffset += 1;\n\t\t\tret[offset] = temp >> 8 & 0xFF;\n\t\t\toffset += 1;\n\t\t\tret[offset] = temp & 0xFF;\n\t\t\toffset += 1;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tmodule.exports.clean = clean;\n\tmodule.exports.pad = pad;\n\tmodule.exports.extend = extend;\n\tmodule.exports.stringToUint8 = stringToUint8;\n\tmodule.exports.uint8ToBase64 = uint8ToBase64;\n\tmodule.exports.base64ToUint8 = base64ToUint8;\n}());\n","'use strict'\n\nconst domain = 'www.takaratomy.co.jp'\nconst Tar = require('tar-js')\n\n/* utils */\nconst toArr = obj => {\n if (!obj) return []\n if (typeof obj === 'string') return []\n return Array.prototype.slice.call(obj,0)\n}\nconst $fetch = (...arg) => {\n return fetch(arg).then(res => {\n if (res.ok) return res\n return Promise.reject(res)\n })\n}\nconst stringToUint8 = str => {\n return (new TextEncoder()).encode(str)\n}\n\n/* parser */\nfunction toCardType(str) {\n let map = {\n 'ルリグ': 'LRIG',\n 'アーツ': 'ARTS',\n 'シグニ': 'SIGNI',\n 'スペル': 'SPELL',\n }\n return map[str] || str\n}\nfunction toColor(str) {\n let map = {\n '白': 'WHITE',\n '黒': 'BLACK',\n '赤': 'RED',\n '青': 'BLUE',\n '緑': 'GREEN',\n '無': 'COLORLESS',\n }\n return map[str] || str\n}\nfunction toCardText(el) {\n let text = toArr(el.childNodes).map(node => {\n if (node.nodeType === node.TEXT_NODE) {\n return node.nodeValue.replace(/^\\s+/,'').replace(/\\s+$/,'')\n }\n if (node.nodeName === 'IMG') {\n return node.alt\n }\n if (node.nodeName === 'BR') {\n return '\\n'\n }\n return node.textContent\n }).join('')\n return text\n}\nfunction toFaq(el) {\n let faq = {}\n faq.q = el.querySelector('.card_ruleFAQ_q').textContent.replace(/^\\s+/,'').replace(/\\s+$/,'')\n faq.a = el.querySelector('.card_ruleFAQ_a').textContent.replace(/^\\s+/,'').replace(/\\s+$/,'')\n return faq\n}\n\n\nfunction toInfo(doc, id) {\n let info = {}\n info.pid = id\n info.timestamp = Date.now()\n info.wxid = doc.querySelector('.card_detail_title > p').textContent\n info.name = doc.querySelector('.card_detail_title > h3').firstChild.textContent\n info.kana = doc.querySelector('.card_detail_kana').textContent.slice(1,-1)\n info.rarity = doc.querySelector('.card_rarity').textContent.replace(/\\s/g,'')\n\n let trs = doc.querySelectorAll('.card_date_box tr')\n // info.cardType = toCardType(trs[0].children[1].textContent)\n info.cardType = trs[0].children[1].textContent\n info.class = trs[0].children[3].textContent\n // info.color = toColor(trs[1].children[1].textContent)\n info.color = trs[1].children[1].textContent\n info.level = trs[1].children[3].textContent\n info.growCost = trs[2].children[1].textContent\n info.cost = trs[2].children[3].textContent\n info.limit = trs[3].children[1].textContent\n info.power = trs[3].children[3].textContent\n info.limiting = trs[4].children[1].textContent\n\n // guard, limiting or coin\n let key = trs[4].children[2].textContent\n let value = trs[4].children[3].textContent\n if (key === 'ガード') {\n info.guard = value\n info.timing = '-'\n } else if (key === '使用タイミング') {\n info.guard = '-'\n info.timing = value\n } else if (key === 'コイン') {\n info.guard = '-'\n info.timing = '-'\n info.coin = value\n } else {\n console.warn(`${info.pid}: unknown key \"${key}\"!`)\n }\n\n let el = doc.querySelector('.card_skill')\n info.cardSkill = el? toCardText(el) : ''\n\n info.cardTexts = toArr(doc.querySelectorAll('.card_text:not(.card_skill)')).map(toCardText)\n\n // info.imgUrl = domain + doc.querySelector('.card_img > img').getAttribute('src')\n info.imgUrl = doc.querySelector('.card_img > img').getAttribute('src')\n info.illust = (doc.querySelector('.card_img').textContent.match(/Illust (.*)$/) || [])[1] || ''\n if (!info.illust) console.warn(`${info.pid}: no illust!`)\n\n info.faqs = toArr(doc.querySelectorAll('.card_FAQ > p')).map(toFaq)\n\n return info\n}\n\n/* fetch */\nfunction fetchById (tar, i) {\n let url = `http://${domain}/products/wixoss/card/card_detail.php?card_id=${i}`\n return $fetch(url)\n .then(res => res.text())\n .then(html => {\n let dom = (new DOMParser()).parseFromString(html,'text/html')\n if (!dom) throw 'Failed to parse DOM!'\n\n // json\n let info = toInfo(dom, i)\n let json = JSON.stringify(info, null, '\\t')\n let name = ('000' + i).slice(-4) + '_' + info.wxid\n tar.append(`${name}.json`, stringToUint8(json))\n console.log(`${name}.json done!`)\n\n // html\n html = html.replace('','\\r\\n')\n tar.append(`${name}.html`, stringToUint8(html))\n console.log(`${name}.html done!`)\n\n // image\n return $fetch(info.imgUrl)\n .then(res => res.arrayBuffer())\n .then(buffer => {\n tar.append(`${name}.jpg`, new Uint8Array(buffer))\n console.log(`${name}.jpg done!`)\n })\n })\n}\n\nfunction fetchRange(min, max) {\n let tar = new Tar()\n let promises = []\n for (let i = min; i <= max; i++) {\n promises.push(fetchById(tar, i))\n }\n return Promise.all(promises)\n .then(() => {\n let name = ('000' + min).slice(-4) + '-' + ('000' + max).slice(-4)\n downloadTar(tar, name)\n })\n}\n\nfunction downloadTar(tar, name) {\n let blob = new Blob([tar.out], { type: 'application/octet-stream' })\n let url = URL.createObjectURL(blob)\n let link = document.createElement('a')\n link.href = url\n link.download = `${name}.tar`\n link.click()\n}\n\nwindow.fetchRange = fetchRange\n"]} \ No newline at end of file +{"version":3,"sources":["node_modules/browser-pack/_prelude.js","node_modules/tar-js/lib/header.js","node_modules/tar-js/lib/tar.js","node_modules/tar-js/lib/utils.js","src/index.js"],"names":[],"mappings":"AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACzHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"index.js","sourcesContent":["(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=\"function\"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=\"function\"==typeof require&&require,i=0;i this.out.length) {\n\t\t\tthis.out = utils.extend(this.out, this.written, input.length, blockSize);\n\t\t}\n\n\t\tthis.out.set(input, this.written);\n\n\t\t// to the nearest multiple of recordSize\n\t\tthis.written += input.length + (recordSize - (input.length % recordSize || recordSize));\n\n\t\t// make sure there's at least 2 empty records worth of extra space\n\t\tif (this.out.length - this.written < recordSize * 2) {\n\t\t\tthis.out = utils.extend(this.out, this.written, recordSize * 2, blockSize);\n\t\t}\n\n\t\tif (typeof callback === 'function') {\n\t\t\tcallback(this.out);\n\t\t}\n\n\t\treturn this.out;\n\t};\n\n\tTar.prototype.clear = function () {\n\t\tthis.written = 0;\n\t\tthis.out = utils.clean(blockSize);\n\t};\n\n Tar.utils = utils;\n\n\tTar.stringToUint8 = utils.stringToUint8;\n\tTar.uint8ToBase64 = utils.uint8ToBase64;\n Tar.base64ToUint8 = utils.base64ToUint8;\n\t\n\tmodule.exports = Tar;\n}());\n","/*\n * tar-js\n * MIT (c) 2011 T. Jameson Little\n */\n\n(function () {\n\t\"use strict\";\n\n\tvar lookup = [\n\t\t\t'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',\n\t\t\t'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',\n\t\t\t'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',\n\t\t\t'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',\n\t\t\t'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',\n\t\t\t'o', 'p', 'q', 'r', 's', 't', 'u', 'v',\n\t\t\t'w', 'x', 'y', 'z', '0', '1', '2', '3',\n\t\t\t'4', '5', '6', '7', '8', '9', '+', '/'\n\t\t];\n\tfunction clean(length) {\n\t\tvar i, buffer = new Uint8Array(length);\n\t\tfor (i = 0; i < length; i += 1) {\n\t\t\tbuffer[i] = 0;\n\t\t}\n\t\treturn buffer;\n\t}\n\n\tfunction extend(orig, length, addLength, multipleOf) {\n\t\tvar newSize = length + addLength,\n\t\t\tbuffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf);\n\n\t\tbuffer.set(orig);\n\n\t\treturn buffer;\n\t}\n\n\tfunction pad(num, bytes, base) {\n\t\tnum = num.toString(base || 8);\n\t\treturn \"000000000000\".substr(num.length + 12 - bytes) + num;\n\t}\t\n\t\n\tfunction stringToUint8 (input, out, offset) {\n\t\tvar i, length;\n\n\t\tout = out || clean(input.length);\n\n\t\toffset = offset || 0;\n\t\tfor (i = 0, length = input.length; i < length; i += 1) {\n\t\t\tout[offset] = input.charCodeAt(i);\n\t\t\toffset += 1;\n\t\t}\n\n\t\treturn out;\n\t}\n\n\tfunction uint8ToBase64(uint8) {\n\t\tvar i,\n\t\t\textraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes\n\t\t\toutput = \"\",\n\t\t\ttemp, length;\n\n\t\tfunction tripletToBase64 (num) {\n\t\t\treturn lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F];\n\t\t};\n\n\t\t// go through the array every three bytes, we'll deal with trailing stuff later\n\t\tfor (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {\n\t\t\ttemp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]);\n\t\t\toutput += tripletToBase64(temp);\n\t\t}\n\n\t\t// this prevents an ERR_INVALID_URL in Chrome (Firefox okay)\n\t\tswitch (output.length % 4) {\n\t\t\tcase 1:\n\t\t\t\toutput += '=';\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\toutput += '==';\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\treturn output;\n\t}\n\n\tfunction base64ToUint8(input) {\n\t\tvar base64 = input.match(/^([^=]+)/)[1],\n\t\t\textraBytes = input.match(/(=*)$/)[1].length,\n\t\t\ti = 0, length = base64.length, temp, offset = 0,\n\t\t\tret = clean(base64.length * .75 + extraBytes);\n\n\t\twhile (i < length) {\n\t\t\ttemp = 0;\n\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A') << 18;\n\t\t\ti += 1;\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A') << 12;\n\t\t\ti += 1;\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A') << 6;\n\t\t\ti += 1;\n\t\t\ttemp |= lookup.indexOf(base64.charAt(i) || 'A');\n\t\t\ti += 1;\n\n\t\t\tret[offset] = temp >> 16 & 0xFF;\n\t\t\toffset += 1;\n\t\t\tret[offset] = temp >> 8 & 0xFF;\n\t\t\toffset += 1;\n\t\t\tret[offset] = temp & 0xFF;\n\t\t\toffset += 1;\n\t\t}\n\n\t\treturn ret;\n\t}\n\n\tmodule.exports.clean = clean;\n\tmodule.exports.pad = pad;\n\tmodule.exports.extend = extend;\n\tmodule.exports.stringToUint8 = stringToUint8;\n\tmodule.exports.uint8ToBase64 = uint8ToBase64;\n\tmodule.exports.base64ToUint8 = base64ToUint8;\n}());\n","'use strict'\n\nconst domain = 'www.takaratomy.co.jp'\nconst Tar = require('tar-js')\n\n/* utils */\nconst toArr = obj => {\n if (!obj) return []\n if (typeof obj === 'string') return []\n return Array.prototype.slice.call(obj,0)\n}\nconst $fetch = (...arg) => {\n return fetch(arg).then(res => {\n if (res.ok) return res\n return Promise.reject(res)\n })\n}\nconst stringToUint8 = str => {\n return (new TextEncoder()).encode(str)\n}\n\n/* parser */\nfunction toCardType(str) {\n let map = {\n 'ルリグ': 'LRIG',\n 'アーツ': 'ARTS',\n 'シグニ': 'SIGNI',\n 'スペル': 'SPELL',\n }\n return map[str] || str\n}\nfunction toColor(str) {\n let map = {\n '白': 'WHITE',\n '黒': 'BLACK',\n '赤': 'RED',\n '青': 'BLUE',\n '緑': 'GREEN',\n '無': 'COLORLESS',\n }\n return map[str] || str\n}\nfunction toCardText(el) {\n let text = toArr(el.childNodes).map(node => {\n if (node.nodeType === node.TEXT_NODE) {\n return node.nodeValue.replace(/^\\s+/,'').replace(/\\s+$/,'')\n }\n if (node.nodeName === 'IMG') {\n return node.alt\n }\n if (node.nodeName === 'BR') {\n return '\\n'\n }\n return node.textContent\n }).join('')\n return text\n}\nfunction toFaq(el) {\n let faq = {}\n faq.q = el.querySelector('.card_ruleFAQ_q').textContent.replace(/^\\s+/,'').replace(/\\s+$/,'')\n faq.a = el.querySelector('.card_ruleFAQ_a').textContent.replace(/^\\s+/,'').replace(/\\s+$/,'')\n return faq\n}\n\n\nfunction toInfo(doc, id) {\n let info = {}\n info.pid = id || doc.querySelector('.card_detail_title > p').textContent\n info.timestamp = Date.now()\n info.wxid = doc.querySelector('.card_detail_title > p').textContent\n info.name = doc.querySelector('.card_detail_title > h3').firstChild.textContent\n info.kana = doc.querySelector('.card_detail_kana').textContent.slice(1,-1)\n info.rarity = doc.querySelector('.card_rarity').textContent.replace(/\\s/g,'')\n\n let trs = doc.querySelectorAll('.card_date_box tr')\n // info.cardType = toCardType(trs[0].children[1].textContent)\n info.cardType = trs[0].children[1].textContent\n info.class = trs[0].children[3].textContent\n // info.color = toColor(trs[1].children[1].textContent)\n info.color = trs[1].children[1].textContent\n info.level = trs[1].children[3].textContent\n info.growCost = trs[2].children[1].textContent\n info.cost = trs[2].children[3].textContent\n info.limit = trs[3].children[1].textContent\n info.power = trs[3].children[3].textContent\n info.limiting = trs[4].children[1].textContent\n\n // guard, limiting or coin\n let key = trs[4].children[2].textContent\n let value = trs[4].children[3].textContent\n if (key === 'ガード') {\n info.guard = value\n info.timing = '-'\n } else if (key === '使用タイミング') {\n info.guard = '-'\n info.timing = value\n } else if (key === 'コイン') {\n info.guard = '-'\n info.timing = '-'\n info.coin = value\n } else {\n console.warn(`${info.pid}: unknown key \"${key}\"!`)\n }\n\n let el = doc.querySelector('.card_skill')\n info.cardSkill = el? toCardText(el) : ''\n\n info.cardTexts = toArr(doc.querySelectorAll('.card_text:not(.card_skill)')).map(toCardText)\n\n // info.imgUrl = domain + doc.querySelector('.card_img > img').getAttribute('src')\n info.imgUrl = doc.querySelector('.card_img > img').getAttribute('src')\n info.illust = (doc.querySelector('.card_img').textContent.match(/Illust (.*)$/) || [])[1] || ''\n if (!info.illust) console.warn(`${info.pid}: no illust!`)\n\n info.faqs = toArr(doc.querySelectorAll('.card_FAQ > p')).map(toFaq)\n\n return info\n}\n\n/* fetch */\nfunction fetchById (tar, i) {\n let url = `http://${domain}/products/wixoss/card/card_detail.php?card_id=${i}`\n return fetchByUrl(tar, url, i)\n}\n\nfunction fetchByWXId(tar, wx_id) {\n let url = `http://${domain}/products/wixoss/card/card_list.php?card=card_detail&card_no=${wx_id}`\n return fetchByUrl(tar, url, undefined)\n}\n\nfunction fetchByUrl(tar, url, i) {\n return $fetch(url)\n .then(res => res.text())\n .then(html => {\n let dom = (new DOMParser()).parseFromString(html,'text/html')\n if (!dom) throw 'Failed to parse DOM!'\n\n // json\n let info = toInfo(dom, i)\n let json = JSON.stringify(info, null, '\\t')\n let name = ('000' + i).slice(-4) + '_' + info.wxid\n tar.append(`${name}.json`, stringToUint8(json))\n console.log(`${name}.json done!`)\n\n // html\n html = html.replace('','\\r\\n')\n tar.append(`${name}.html`, stringToUint8(html))\n console.log(`${name}.html done!`)\n\n // image\n return $fetch(info.imgUrl)\n .then(res => res.arrayBuffer())\n .then(buffer => {\n tar.append(`${name}.jpg`, new Uint8Array(buffer))\n console.log(`${name}.jpg done!`)\n })\n })\n}\n\nfunction fetchRange(min, max) {\n let tar = new Tar()\n let promises = []\n for (let i = min; i <= max; i++) {\n promises.push(fetchById(tar, i))\n }\n return Promise.all(promises)\n .then(() => {\n let name = ('000' + min).slice(-4) + '-' + ('000' + max).slice(-4)\n downloadTar(tar, name)\n })\n}\n\n// fetchWXBox(\"WDK02\", 1, 20)\nfunction fetchWXBox(prefix, min, max) {\n let tar = new Tar()\n let promises = []\n for (let i = min; i <= max; i ++) {\n const wx_id = `${prefix}-${('00' + i).slice(-3)}`;\n promises.push(fetchByWXId(tar, wx_id))\n }\n return Promise.all(promises)\n .then(() => {\n let name = ('000' + min).slice(-4) + '-' + ('000' + max).slice(-4)\n downloadTar(tar, name)\n })\n}\n\nfunction downloadTar(tar, name) {\n let blob = new Blob([tar.out], { type: 'application/octet-stream' })\n let url = URL.createObjectURL(blob)\n let link = document.createElement('a')\n link.href = url\n link.download = `${name}.tar`\n link.click()\n}\n\nwindow.fetchRange = fetchRange\nwindow.fetchWXBox = fetchWXBox\n"],"preExistingComment":"//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJub2RlX21vZHVsZXMvdGFyLWpzL2xpYi9oZWFkZXIuanMiLCJub2RlX21vZHVsZXMvdGFyLWpzL2xpYi90YXIuanMiLCJub2RlX21vZHVsZXMvdGFyLWpzL2xpYi91dGlscy5qcyIsInNyYy9pbmRleC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTtBQ0FBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QU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CBuYW1lKVxuICB9KVxufVxuXG5mdW5jdGlvbiBkb3dubG9hZFRhcih0YXIsIG5hbWUpIHtcbiAgbGV0IGJsb2IgPSBuZXcgQmxvYihbdGFyLm91dF0sIHsgdHlwZTogJ2FwcGxpY2F0aW9uL29jdGV0LXN0cmVhbScgfSlcbiAgbGV0IHVybCA9IFVSTC5jcmVhdGVPYmplY3RVUkwoYmxvYilcbiAgbGV0IGxpbmsgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50KCdhJylcbiAgbGluay5ocmVmID0gdXJsXG4gIGxpbmsuZG93bmxvYWQgPSBgJHtuYW1lfS50YXJgXG4gIGxpbmsuY2xpY2soKVxufVxuXG53aW5kb3cuZmV0Y2hSYW5nZSA9IGZldGNoUmFuZ2VcbndpbmRvdy5mZXRjaFdYQm94ID0gZmV0Y2hXWEJveFxuIl19"} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 868dd6c..e47a195 100644 --- a/src/index.js +++ b/src/index.js @@ -65,7 +65,7 @@ function toFaq(el) { function toInfo(doc, id) { let info = {} - info.pid = id + info.pid = id || doc.querySelector('.card_detail_title > p').textContent info.timestamp = Date.now() info.wxid = doc.querySelector('.card_detail_title > p').textContent info.name = doc.querySelector('.card_detail_title > h3').firstChild.textContent @@ -120,6 +120,15 @@ function toInfo(doc, id) { /* fetch */ function fetchById (tar, i) { let url = `http://${domain}/products/wixoss/card/card_detail.php?card_id=${i}` + return fetchByUrl(tar, url, i) +} + +function fetchByWXId(tar, wx_id) { + let url = `http://${domain}/products/wixoss/card/card_list.php?card=card_detail&card_no=${wx_id}` + return fetchByUrl(tar, url, undefined) +} + +function fetchByUrl(tar, url, i) { return $fetch(url) .then(res => res.text()) .then(html => { @@ -161,6 +170,21 @@ function fetchRange(min, max) { }) } +// fetchWXBox("WDK02", 1, 20) +function fetchWXBox(prefix, min, max) { + let tar = new Tar() + let promises = [] + for (let i = min; i <= max; i ++) { + const wx_id = `${prefix}-${('00' + i).slice(-3)}`; + promises.push(fetchByWXId(tar, wx_id)) + } + return Promise.all(promises) + .then(() => { + let name = ('000' + min).slice(-4) + '-' + ('000' + max).slice(-4) + downloadTar(tar, name) + }) +} + function downloadTar(tar, name) { let blob = new Blob([tar.out], { type: 'application/octet-stream' }) let url = URL.createObjectURL(blob) @@ -171,3 +195,4 @@ function downloadTar(tar, name) { } window.fetchRange = fetchRange +window.fetchWXBox = fetchWXBox