Tampermonkey / tampermonkey

Tampermonkey is the most popular userscript manager, with over 10 million users. It's available for Chrome, Microsoft Edge, Safari, Opera Next, and Firefox.
GNU General Public License v3.0
4.24k stars 418 forks source link

I cant use a WebSocket to send an authentication token #1556

Closed Julianty123 closed 2 years ago

Julianty123 commented 2 years ago

Hello, I am trying to open a connection with WebSocket to send my email, my password and the generated token when i complete the captcha for log in Habbo (I still don't know how to do it), but the connection always fails, I appreciate if you can help me since its my first time using Tampermonkey. https://www.habbo.es/api/public/captcha

Expected Behavior

Open the connection

Actual Behavior

WebSocket connection to 'ws://127.0.0.1:8090/' failed:

Specifications

Script

// ==UserScript==
// @name         Get Token
// @namespace    token
// @version      0.0.1
// @description  try to take over the world!
// @author       Julianty
// @match        https://www.habbo.es/api/public/captcha*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const urlParams = new URLSearchParams(window.location.search);
    console.log(urlParams.get("token"));
    var socket = new WebSocket("ws://127.0.0.1:8090");
    socket.onopen = () =>{
        if(urlParams.has("token") && urlParams.get("token") !== ""){
            socket.send(urlParams.get("token"));
        }
    }
})();
derjanb commented 2 years ago

Duplicate of #1483