Skip to content

Commit 8215fb9

Browse files
committed
add: more headers for waf bypass
1 parent 144479b commit 8215fb9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/client.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ module.exports = class Client {
158158
if (!this.isOpen) return;
159159

160160
protocol.parseWSPacket(str).forEach((packet) => {
161+
console.dir(packet, { depth: null });
161162
if (global.TW_DEBUG) console.log('§90§30§107 CLIENT §0 PACKET', packet);
162163
if (typeof packet === 'number') { // Ping
163164
this.#ws.send(protocol.formatWSPacket(`~h~${packet}`));
@@ -228,8 +229,14 @@ module.exports = class Client {
228229
if (clientOptions.DEBUG) global.TW_DEBUG = clientOptions.DEBUG;
229230

230231
const server = clientOptions.server || 'data';
231-
this.#ws = new WebSocket(`wss://${server}.tradingview.com/socket.io/websocket?type=chart`, {
232+
this.#ws = new WebSocket(`wss://${server}.tradingview.com/socket.io/websocket?from=chart&type=chart`, {
232233
origin: 'https://www.tradingview.com',
234+
headers: {
235+
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
236+
'Accept-Language': 'en-US,en;q=0.9',
237+
'Cache-Control': 'no-cache',
238+
Pragma: 'no-cache',
239+
},
233240
});
234241

235242
if (clientOptions.token) {

0 commit comments

Comments
 (0)