Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // examples for test:
  3. // resolver.url - https://pctest-live-front.playbattlegrounds.com
  4. // appUrl - https://pctest-live-front.playbattlegrounds.com/app/jk-pc-pc-1911-99/index-steam.jk-pc-pc-1911-99.html
  5. // rootUrl - (comes from appUrl page in script tag broConfiguration.uri) https://pctest-live-cfentry.playbattlegrounds.com/publicproxy
  6. // fetch is node-fetch
  7.  
  8. const call = `${rootUrl}/${apiName}/${methodName}`;
  9.  
  10. const agent = new http.Agent({
  11.     keepAlive: true
  12. });
  13.  
  14. // Don't know if CORS stuff is necessary, or if correct game user-agent is necessary (it seems to be for websocket api), referer and origin are necessary though
  15. const commonHeaders = {
  16.     'Referer': appUrl,
  17.     'Origin': resolver.url,
  18.     'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.86 Safari/537.36',
  19.     'Access-Control-Request-Method': 'POST',
  20.     'Access-Control-Request-Headers': 'accept, origin, content-type',
  21. };
  22. const preflight = new fetch.Request(call, {
  23.     method: 'options',
  24.     agent,
  25.     headers: Object.assign({}, commonHeaders, {
  26.         'Access-Control-Request-Method': 'POST',
  27.         'Access-Control-Request-Headers': 'Content-Type',
  28.     }),
  29. });
  30. /** @type {fetch.Response} */
  31. const pfres = await fetch(preflight);
  32.  
  33. // don't think invokerId matters for publicproxy api
  34. const body = [invokerId++,null,apiName,methodName,...parameters];
  35.  
  36. const req = new fetch.Request(call, {
  37.     method: 'post',
  38.     agent,
  39.     body: JSON.stringify(body),
  40.     headers: Object.assign({}, commonHeaders),
  41. });
  42.  
  43. const res = await fetch(req);
  44. if (res.ok) {
  45.     const result = await res.json()
  46.  
  47. // apiName: 'PublicProxyApi'
  48. // methodName: 'GetMissionSystemData'
  49. // parameters: ['steam.7656...'] (replace with steam id, no authentication so I don't think it matters whose it is)
  50.  
  51. // apiName: 'PublicProxyApi'
  52. // methodName: 'GetBattlePassDatas'
  53. // parameters: ['steam.7656...'] (replace with steam id, no authentication so I don't think it matters whose it is)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement