0% found this document useful (0 votes)
57 views

Script

The document contains code to hijack websockets and listen for messages to trigger a notification. It defines functions to create an ASCII box, extract data from messages, play a sound, and display notifications. The code hijacks the WebSocket constructor to intercept new connections, listen for "activateRain" messages, play a sound, and display a notification with sample text and settings.

Uploaded by

simo mühler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Script

The document contains code to hijack websockets and listen for messages to trigger a notification. It defines functions to create an ASCII box, extract data from messages, play a sound, and display notifications. The code hijacks the WebSocket constructor to intercept new connections, listen for "activateRain" messages, play a sound, and display a notification with sample text and settings.

Uploaded by

simo mühler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

(function (w) {

'use strict';

const log = w.console.log.bind();

// NOTE: Creates a ascii box


const box = (a, b = 0) => {
let d, c = '';
a.forEach(e => b = e.length > b ? e.length : b);
d = '+'.padEnd(b, '=') + '+';
a.forEach(e => c += '|' + e.padEnd(b - 1, ' ') + '|\n');
return d + '\n' + c + d;
};

///////////////////////////////////////////////////////////////////////////

const initMessage = box([


' Gamdom Rain Notify:', '',
' Ver: ' + GM_info.script.version,
' By ' + GM_info.script.author, '',
], 40);

const NData = { // Notification data


title: "Gamdom Rain Notify:",
text: "its raining :D",
highlight: true,
timeout: 5000
};

///////////////////////////////////////////////////////////////////////////

const CoinAudioData = GM_getResourceURL('CoinAudioData')


.replace('application', 'audio/mp3');

const CoinSound = new Audio(CoinAudioData); // Load Audio

const notificate = () => {


CoinSound.play();
GM_notification(NData);
};

///////////////////////////////////////////////////////////////////////////

const extractData = (a, b = false) => {


try {
b = JSON.parse(a.split(',').slice(1).join());
} finally {
return b;
}
};

const manageMessages = (a) => {


var b = extractData(a.data);
if(b[0] == 'activateRain') notificate();
};

///////////////////////////////////////////////////////////////////////////
/* NOTE: HijackWebsocket is imported (and modified)
* from https://github.com/Pytness/Hijack-Websocket
*/

const HijackWebsocket = () => {

const WS = w.WebSocket;
w.WebSocket = function (...argv) {
let hws = new WS(...argv);
hws.addEventListener('message', manageMessages);
log('Intercepted new WebSocket conection', 'info');
return hws;
};

log('WebSocket constructor hijacked', 'ok');

w.WebSocket.prototype = WS.prototype;
w.WebSocket.__proto__ = WS.__proto__;

w.WebSocket = Function.prototype.call.apply(Function.prototype.bind,
[w.WebSocket]);

log('Hijacked WebSocket secured', 'ok');


log('Waiting for WebSocket creation...', 'info');
};

///////////////////////////////////////////////////////////////////////////

const init = () => {


// NOTE: Log on console Script info
log(initMessage);

// NOTE: Hijack the WebSocket constructor


HijackWebsocket();
};

init();

}(unsafeWindow));

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy