first commit

This commit is contained in:
s.golasch
2023-08-01 12:47:58 +02:00
commit b1439a55bb
65 changed files with 3085 additions and 0 deletions

103
__websocket.js Normal file
View File

@@ -0,0 +1,103 @@
const cookies = require('/Users/asciidisco/.alexis/cookies.json')
const request = require('request')
const WebSocket = require('faye-websocket')
let DEVICE_SERIAL = ''
let DEVICE_TYPE = null
let data = ''
let is_connected = false
const do_connect = (url, device_type, headers) => {
is_connected = true
let ws = new WebSocket.Client(url)
ws.on('open', function(event) {
console.log('open');
});
ws.on('message', function(event) {
console.log('message', event.data.toString())
});
ws.on('close', function(event) {
console.log('close', event.code, event.reason)
ws = null;
});
}
cookies.forEach(cookie => {
if (cookie.name === 'ubid-acbde') DEVICE_SERIAL = cookie.value
Object.keys(cookie).forEach(key => {
if (key == 'name') return
data += key == 'value' ? cookie.name + '=' + cookie.value : key + '=' + cookie[key]
data += ';'
})
})
DEVICE_SERIAL += '-' + Date.now()
let http_headers = {
'Pragma': 'no-cache',
'Accept-Encoding': 'identity',
'Accept-Language': 'de',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0',
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Cache-Control': 'no-cache',
'X-Requested-With': 'XMLHttpRequest',
'Connection': 'keep-alive',
'Referer': 'https://layla.amazon.de/spa/index.html',
'Cookie': data,
}
let ws_headers = {
'Accept-Language': 'de',
'Referer': 'https://layla.amazon.de/spa/index.html',
'Cookie': data,
'Host': 'dp-gw-na.amazon.de',
'Origin': 'https://layla.amazon.de',
'Pragma': 'no-cache',
'Accept-Encoding': 'identity',
'Upgrade': 'websocket',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36',
}
request({headers: http_headers, url: 'https://layla.amazon.de/api/cards?limit=100'}, (err, res, body) => {
const cards = JSON.parse(body)
cards.cards.forEach(card => {
const parts = card.id.split('#')
if (parts.pop() == 'BOGUS') {
DEVICE_TYPE = parts[2]
if (!is_connected) do_connect(`wss://dp-gw-na.amazon.de/?x-amz-device-type=${DEVICE_TYPE}&x-amz-device-serial=${DEVICE_SERIAL}`, DEVICE_TYPE, ws_headers)
}
})
})
/*var ws = new WebSocket.Client('wss://dp-gw-na.amazon.de/?x-amz-device-type={DEVICE_TYPE}&x-amz-device-serial={DEVICE_SERIAL}', [], {
proxy: {
origin: 'https://layla.amazon.de',
headers: {'User-Agent': 'node'}
}
})*/
/*client.on('connectFailed', function(error) {
console.log('Connect Error: ' + error.toString());
});
client.on('connect', function(connection) {
console.log('WebSocket Client Connected');
connection.on('error', function(error) {
console.log("Connection Error: " + error.toString());
});
connection.on('close', function() {
console.log('echo-protocol Connection Closed');
});
connection.on('message', function(message) {
if (message.type === 'utf8') {
console.log("Received: '" + message.utf8Data + "'");
}
});
});
client.connect('wss://dp-gw-na.amazon.de/?x-amz-device-type=ALEGCNGL9K0HM&x-amz-device-serial=260-2954207-0537040-1503305987401', null, ['https://layla.amazon.de', headers]);
setInterval(function () {}, 1000)*/