From f62f800befbddda9c9c9c0c191384831538427cc Mon Sep 17 00:00:00 2001 From: Cedric Hoelzl Date: Thu, 2 Jul 2020 11:18:38 +0200 Subject: [PATCH] manual api --- manual.js | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 manual.js diff --git a/manual.js b/manual.js new file mode 100644 index 0000000..66dad51 --- /dev/null +++ b/manual.js @@ -0,0 +1,83 @@ +const http = require('https'); +const fetch = require('node-fetch'); + +const track_url = 'https://t.17track.net/restapi/track'; + +var cnvrt = function(v) { + var str = ''; + for (var i = 0; i < v.length; i++) { + str += v.charCodeAt(i).toString(16); + } + return str; +}; +function acc(a, b) { + var c = 1315423911 ^ b << 16; + for (var i = a.length - 1; i >= 0; i--) { + c ^= (c << 5) + a.charCodeAt(i) + (c >> 2); + } + return Math.abs(c & 2147483647); +}; +function atb(a) { + var b = a; + while (b['length'] < 0x8) { + b = '0' + b; + } + return b; +}; +var token = function(data) { + var classes = ["navbar navbar-default yq-header", "nav navbar-toolbar navbar-right navbar-toolbar-right yq-navbar-toolbar", "yq-dropdown-menu-media-apps", "yq-navbar-menuIcon-24 yq-head-apps", "dropdown-menu yq-moreapp-container", "list-group yq-list-group-moreapp clearfix", "hide yq-dropdown-menu-media-msg", "yq-head-msg yq-navbar-menuIcon-24", "yq-msg-nomsg vertical-align panel text-center hide", "yq-msg-network-err vertical-align panel text-center hide", "dropdown-menu dropdown-menu-media yq-dropdown-menu-media-user", "dropdown-menu-footer yq-user-footer clearfix", "margin-horizontal-10 yq-input-container", "dropdown-menu dropdown-menu-media yq-track-dropdown", "yq-more-track-container clearfix", "yq-tools-small", "navbar-brand-logo hidden-xs yq-default-logo", "navbar-brand-logo visible-xs yq-default-logo", "tab-content yq-panel-tracklist scrollable is-enabled scrollable-vertical", "yq-panel-gad", "modal-dialog yq-modal-dialog"]; + var rnd = Math.round((Math.random()* classes.length)); + + var res = []; + var value = "yq-"; + var key = "Last-Event-ID"; + if (classes.length > rnd) { + value = classes[rnd]; + } + value += '/' + Date.now().toString(16) + '/18c/true'; + + res[0]= cnvrt(value.split('').reverse().join('')); + res[1] = rnd.toString(16); + res[2] = rnd.toString(16).length; + res[3] = 2; + res[4] = atb(acc(value, rnd).toString(16)); + res[5] = atb(acc(data,data.length).toString(16)); + return res.join('') +}; + + + +async function get_tracking(trck_ids, guid){ + + var data = { "data": [],"guid":guid,"timeZoneOffset":-120 }; + for(var id of trck_ids){ + data.data.push({num:id,fc:0,sc:0}); + } + var keyid = token(JSON.stringify(data)); + + const opts = { + method: 'POST', + body: JSON.stringify(data), + headers: { + 'Accept': 'application/json, text/javascript, */*; q=0.01', + 'Accept-Language': 'en-US,en;q=0.5', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'X-Requested-With': 'XMLHttpRequest', + 'Referer': 'https://t.17track.net/en', + 'Connection': 'keep-alive', + 'DNT': 1, + 'Cookie': 'v5_TranslateLang=en; v5_AppIconsVersion=1; Last-Event-ID='+keyid, + 'Cache-Control': 'no-cache', + }, + agent: new http.Agent({ + keepAlive: true + }) + }; + return fetch(track_url, opts) + .then(res => res.json()); +} + +get_tracking(['9999999999999'],'').then(res=>{ + console.log(res.dat); +}); +