This repository has been archived by the owner on Jun 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Inazuma110/develop
v0.0.1
- Loading branch information
Showing
28 changed files
with
1,436 additions
and
1,030 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
poke-rate-hub |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2018 Inazuma110 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,60 @@ | ||
# poke-rate-hub | ||
|
||
## Overview | ||
> Create Pokemon rating battle graph like GitHub! | ||
## Usage | ||
### Howto get savedataIdCode | ||
|
||
1. Goto page [Pokemon Global Link](https://3ds.pokemon-gl.com/) and login. | ||
1. savedataIdCode is A-326-2494-J<br> | ||
![image](https://user-images.githubusercontent.com/31335755/49682267-e4a84f80-faf4-11e8-9696-5b5e028842e9.png) | ||
|
||
## Warning | ||
You have to publish rating battle. | ||
### Howto publish rating battle.(Image is JP account) | ||
1. Go to your profile(mypage).<br> | ||
![image](https://user-images.githubusercontent.com/31335755/49682364-33a2b480-faf6-11e8-8e5f-6e17577216a5.png) | ||
1. Click settings of public scope.<br> | ||
![image](https://user-images.githubusercontent.com/31335755/49682374-6c428e00-faf6-11e8-8233-ab85986744a0.png) | ||
1. Publish Rating battle.<br> | ||
![image](https://user-images.githubusercontent.com/31335755/49682397-ba579180-faf6-11e8-95c7-80098c8c9569.png) | ||
|
||
## Example SavedataIdCode | ||
You can try PokeRateHub using these savedataIdCodes. | ||
- A-326-2494-J (Ultra Sun) | ||
- E-454-0005-X (Ultra Moon) | ||
- J-599-9902-I (Ultra Sun) | ||
- G-277-9551-T (Moon) (No battle history) | ||
|
||
|
||
## demo | ||
### SavedataIdCode: A-326-2494-J | ||
![image](https://user-images.githubusercontent.com/31335755/49682220-24bb0280-faf4-11e8-85ca-1d1f248b4003.png) | ||
|
||
## Next feature | ||
Check Issues | ||
|
||
## Contribute | ||
Fork and send Pull Request. | ||
I will welcome it!! | ||
|
||
## Build Setup | ||
|
||
``` bash | ||
# install dependencies | ||
npm install | ||
yarn install | ||
|
||
# serve with hot reload at localhost:8080 | ||
npm run dev | ||
yarn run dev | ||
|
||
# start api server | ||
node src/api/server.js # in project root | ||
|
||
# build for production with minification | ||
npm run build | ||
yarn run build | ||
|
||
# build for production and view the bundle analyzer report | ||
npm run build --report | ||
yarn run build --report | ||
``` | ||
|
||
For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Host": "3ds.pokemon-gl.com", | ||
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0", | ||
"Accept": "*/*", | ||
"Accept-Language": "ja,en-US;q=0.7,en;q=0.3", | ||
"Accept-Encoding": "gzip, deflate, br", | ||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | ||
"X-Requested-With": "XMLHttpRequest", | ||
"Referer": "", | ||
"Content-Length": "159", | ||
"Cookie": "region=0; language_id=1; site=1; JSESSIONID=8B716AD73AE9616941C50AC0DEAE8310; AWSELB=C95303410E583113FAF27D987FE57908F5BE8EE44BA8A0AD236B0D591F44F929CEDC6D81BBD1D19066C332A55EB39B7CE28E1F48F8415CBDE6FB8D2992031AF6D756E47174BEE8896177D6EA2DF4EDD6B9A4A42C42; _ga=GA1.2.1594122966.1541393827; _gid=GA1.2.1641740835.1541393827; NO_MEMBER_DATA=%7B%22language_id%22%3A1%2C%22site%22%3A1%2C%22region%22%3A0%7D; __ulfpc=201811051357063269; s_fid=10191B9F70C14FDA-0882A920BCB619D0; s_cc=true; s_sq=%5B%5BB%5D%5D; _gat=1", | ||
"Connection": "keep-alive" | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"languageId":1, | ||
"accountId":"", | ||
"savedataId":"", | ||
"battleType":"", | ||
"count":10000 | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import requests | ||
from time import sleep | ||
import json | ||
import sys | ||
|
||
dataFilePath = './src/api/data/'; | ||
url = "https://3ds.pokemon-gl.com/frontendApi/mypage/getGbuBattleList" | ||
|
||
with open(f'{dataFilePath}headers.json', 'r') as f: | ||
headers = json.load(f) | ||
|
||
with open(f'{dataFilePath}form.json', 'r') as f: | ||
payload = json.load(f) | ||
|
||
r = requests.post(url, headers=headers, data=payload) | ||
j = r.json() | ||
|
||
with open(f'{dataFilePath}battleHistory.json', 'w') as f: | ||
f.write(json.dumps(j, indent=2)) | ||
|
||
# print(json.dumps(j, indent=2)) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
|
||
const fs = require('fs'); | ||
const exec = require('child_process').exec; | ||
const req = require('request-promise'); | ||
// const puppeteer = require('puppeteer'); | ||
|
||
const dataFilePath = './src/api/data/'; | ||
|
||
let accountId, savedataId; | ||
|
||
const getValue = async(savedataIdCode) => { | ||
const url = `https://3ds.pokemon-gl.com/user/${savedataIdCode}/profile/`; | ||
const opt = { | ||
url: url, | ||
json: true, | ||
} | ||
|
||
let body = await req.get (opt, (e, res, b) => { | ||
return b; | ||
}); | ||
|
||
const accountIdRe = /USERS_ACCOUNT_ID='(.*?)'/g; | ||
accountId = body.match(accountIdRe)[0]; | ||
accountId = accountId.replace(accountIdRe, '$1'); | ||
|
||
const savedataIdRe = /USERS_SAVEDATA_ID='(.*?)'/g; | ||
savedataId = body.match(savedataIdRe)[0]; | ||
savedataId = savedataId.replace(savedataIdRe, '$1'); | ||
} | ||
|
||
const getBattleHistory = async(savedataIdCode) => { | ||
const url = "https://3ds.pokemon-gl.com/frontendApi/mypage/getGbuBattleList"; | ||
const referer = `https://3ds.pokemon-gl.com/user/${savedataIdCode}/battle/`; | ||
|
||
let headers = | ||
JSON.parse(fs.readFileSync(`${dataFilePath}headersTemplate.json`, 'utf-8')); | ||
headers['Referer'] = referer; | ||
|
||
let form = | ||
JSON.parse(fs.readFileSync(`${dataFilePath}payloadTemplate.json`, 'utf-8')); | ||
form['accountId'] = accountId; | ||
form['savedataId'] = savedataId; | ||
|
||
const arg1 = JSON.stringify(headers); | ||
const arg2 = JSON.stringify(form); | ||
|
||
|
||
fs.writeFileSync(`${dataFilePath}headers.json`, arg1); | ||
fs.writeFileSync(`${dataFilePath}form.json`, arg2); | ||
|
||
const res = exec('python3 ./src/api/getBattleHistory.py', | ||
(err, sout, serr) => { | ||
console.log(sout); | ||
console.log(serr); | ||
}); | ||
} | ||
|
||
const ss = async(savedataIdCode, ssPath) => { | ||
const puppeteer = require('puppeteer'); | ||
const browser = await puppeteer.launch({ | ||
args: [ | ||
'--no-sandbox', | ||
'--disable-setuid-sandbox' | ||
], | ||
// headless: false, | ||
}); | ||
const page = await browser.newPage(); | ||
await page.setViewport({ width: 1020, height: 980 }) | ||
await page.goto('localhost:8080'); | ||
await page.type('#savedateidcode', savedataIdCode); | ||
await page.click('#create'); | ||
|
||
await page.waitFor('#poke'); | ||
|
||
const clip = await page.evaluate(s => { | ||
const el = document.querySelector(s) | ||
|
||
const { width, height, top: y, left: x } = el.getBoundingClientRect() | ||
return { width, height, x, y } | ||
}, '#poke') | ||
|
||
let element = await page.$('#poke'); | ||
await page.screenshot({clip, path: ssPath}); | ||
|
||
browser.close(); | ||
} | ||
|
||
const cors = require('cors'); | ||
app.use(cors()); | ||
|
||
// http://localhost:3000/api/v1/battleHistory | ||
app.get('/api/v1/battleHistory', async(req, res) => { | ||
const savedataIdCode = await req.query.savedataIdCode; | ||
|
||
console.log(`GET Request: ${savedataIdCode}`); | ||
|
||
|
||
try{ | ||
await getValue(savedataIdCode); | ||
await getBattleHistory(savedataIdCode); | ||
}catch(err){ | ||
await res.json({'statusCode': '4444'}); | ||
return; | ||
} | ||
|
||
const battleHistory = | ||
await JSON.parse(fs.readFileSync(`${dataFilePath}battleHistory.json`)); | ||
|
||
|
||
await res.json(battleHistory); | ||
}); | ||
|
||
// http://localhost:3000/api/v1/ss | ||
app.get('/api/v1/ss', async(req, res) => { | ||
const savedataIdCode = await req.query.savedataIdCode; | ||
const ssPath = `./src/api/ss/${savedataIdCode}.png` | ||
|
||
console.log(`GET SS Request: ${savedataIdCode}`); | ||
console.log(); | ||
|
||
ss(savedataIdCode, ssPath); | ||
await res.json({'path': ssPath}); | ||
|
||
}) | ||
|
||
|
||
app.listen(3000, () => console.log('Listening on port 3000')); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.