elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Mensajes
Páginas: [1] 2
1  Programación / Programación General / socket.io (10) Actualizar codigo AYUDA en: 21 Enero 2021, 20:14 pm
Estoy intentado pasar este codigo a la ultima version de socket.io y no lo consigo.
Este es el codigo y marco los errores que me da:




Código
  1. // https://www.webrtc-experiment.com/
  2.  
  3. var fs = require('fs');
  4.  
  5. // don't forget to use your own keys!
  6. var options = {
  7.    // key: fs.readFileSync('fake-keys/privatekey.pem'),
  8.    // cert: fs.readFileSync('fake-keys/certificate.pem')
  9.    key: fs.readFileSync('C:/Users/TONI1/Desktop/WebRTC-Experiment-master/socketio-over-nodejs/fake-keys/privatekey.pem'),
  10.    cert: fs.readFileSync('C:/Users/TONI1/Desktop/WebRTC-Experiment-master/socketio-over-nodejs/fake-keys/certificate.pem')
  11. };
  12.  
  13. // HTTPs server
  14. var app = require('https').createServer(options, function(request, response) {
  15.    response.writeHead(200, {
  16.        'Content-Type': 'text/html'
  17.    });
  18.    var link = 'https://github.com/muaz-khan/WebRTC-Experiment/tree/master/socketio-over-nodejs';
  19.    response.write('<title>socketio-over-nodejs</title><h1><a href="'+ link + '">socketio-over-nodejs</a></h1><pre>var socket = io.connect("https://webrtcweb.com:9559/");</pre>');
  20.    response.end();
  21. });
  22.  
  23.  
  24. // socket.io goes below
  25.  
  26. var io = require('socket.io').listen(app, {     <-------------------- ERROR 1
  27.    log: true,
  28.    origins: '*:*'
  29. });
  30.  
  31. io.set('transports', [            <--------------------------------ERROR 2
  32.    // 'websocket',
  33.    'xhr-polling',
  34.    'jsonp-polling'
  35. ]);
  36.  
  37. var channels = {};
  38.  
  39. io.sockets.on('connection', function (socket) {
  40.    var initiatorChannel = '';
  41.    if (!io.isConnected) {
  42.        io.isConnected = true;
  43.    }
  44.  
  45.    socket.on('new-channel', function (data) {
  46.        if (!channels[data.channel]) {
  47.            initiatorChannel = data.channel;
  48.        }
  49.  
  50.        channels[data.channel] = data.channel;
  51.        onNewNamespace(data.channel, data.sender);
  52.    });
  53.  
  54.    socket.on('presence', function (channel) {
  55.        var isChannelPresent = !! channels[channel];
  56.        socket.emit('presence', isChannelPresent);
  57.    });
  58.  
  59.    socket.on('disconnect', function (channel) {
  60.        if (initiatorChannel) {
  61.            delete channels[initiatorChannel];
  62.        }
  63.    });
  64. });
  65.  
  66. function onNewNamespace(channel, sender) {
  67.    io.of('/' + channel).on('connection', function (socket) {
  68.        var username;
  69.        if (io.isConnected) {
  70.            io.isConnected = false;
  71.            socket.emit('connect', true);
  72.        }
  73.  
  74.        socket.on('message', function (data) {
  75.            if (data.sender == sender) {
  76.                if(!username) username = data.data.sender;
  77.  
  78.                socket.broadcast.emit('message', data.data);
  79.            }
  80.        });
  81.  
  82.        socket.on('disconnect', function() {
  83.            if(username) {
  84.                socket.broadcast.emit('user-left', username);
  85.                username = null;
  86.            }
  87.        });
  88.    });
  89. }
  90.  
  91. // run app
  92.  
  93. app.listen(process.env.PORT || 9559);
  94.  
  95. process.on('unhandledRejection', (reason, promise) => {
  96.  process.exit(1);
  97. });
  98.  
  99. console.log('Please open SSL URL: https://localhost:'+(process.env.PORT || 9559)+'/');
  100.  
2  Programación / Desarrollo Web / Re: Ayuda. getelementbyid() no encuentra el nodo. en: 2 Julio 2020, 16:31 pm
Exacto.

En tapermonkey funciona perfecto... pero necesito hacerlo en greasemonkey.

No consigo acceder al segundo iframe



Código:
var button = document.createElement('button');
button.innerHTML = 'Do Something';

var body = document.getElementsByTagName('body')[0];
body.appendChild(button);

button.addEventListener ('click', function() {
  
  
  
  contentWindow
  
var iframe = document.getElementsByTagName('iframe')[0];

var iframe2 = iframe.contentWindow.getElementsByTagName('iframe')[0];
  
      
alert(iframe2);

});

Me podrias poner un ejemplo de acceso a un embed?


3  Programación / Desarrollo Web / Re: Ayuda. getelementbyid() no encuentra el nodo. en: 1 Julio 2020, 19:12 pm
No entiendo eso de targetear el iframe...
Me puedes dar mas informacion para buscar en mi amigo google?
4  Programación / Desarrollo Web / Re: Ayuda. getelementbyid() no encuentra el nodo. en: 1 Julio 2020, 19:01 pm
Nada. no encuentra el nodo.

Use tu ejemplo adaptandolo y no encuentra el id.

Esta es la url que intento automatizar:


 https://vercanalestv1.com/ver-tve-1-la-1-online-en-directo-gratis-24h-por-internet/


Código:
// ==UserScript==
// @name         ScriptDePrueba
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Script de prueba
// @author       unsigned
// @match        https://vercanalestv1.com/ver-tve-1-la-1-online-en-directo-gratis-24h-por-internet/
// @grant        none
// ==/UserScript==
 
function gm_main(){
   // 1. Create the button
   var button = document.createElement("button");
   button.innerHTML = "Do Something";
 
   // 2. Append somewhere
   var body = document.getElementsByTagName("body")[0];
   body.appendChild(button);
 
   // 3. Add event handler
   button.addEventListener ("click", function() {
 
   alert(`Hola ${document.querySelector(".headerbar").innerHTML}`); // HEADERBAR ES LA CLASE DEL DIV
 
 
});
}
 
(function() {
    'use strict';
 
    window.onload = gm_main();
 
})();
5  Programación / Desarrollo Web / Re: Ayuda. getelementbyid() no encuentra el nodo. en: 1 Julio 2020, 13:35 pm
Estoy creando un boton para asegurarme que esta la pagina cargada.
Espero a que cargue por completo y luego presiono el boton, pero no encuentra el id


Código:
// 1. Create the button
var button = document.createElement("button");
button.innerHTML = "Do Something";

// 2. Append somewhere
var body = document.getElementsByTagName("body")[0];
body.appendChild(button);

// 3. Add event handler
button.addEventListener ("click", function() {
  
alert(document.getElementById("interContainer").innerHTML);


});


Tambien probe esto y nada :

Código:
  alert(document.getElementById("interContainer").children.length);
6  Programación / Desarrollo Web / Ayuda. getelementbyid() no encuentra el nodo. en: 1 Julio 2020, 12:50 pm
Buenas a todos.

Estoy intentando automatizar una pagina con greasemonkey, en la cual tengo que hacer un click.

Intendo obtener el div con getelementbyid() pero no lo encuentra y al mirar el inspector de codigo de firefox si esta el id.

Este es el codigo de la pagina que aparece en el inspector de codigo:


Código:
<div id="interContainer" style="left: 0px; top: 174px; visibility: visible;">

<div class="headerbar">

<a href="#" onclick="javascript:interstitialBox.closeit(); return false">

<img src="/pop/closeit.gif" style="border: 0" title="Close Box"></a>

</div>

</div>

Cualquier ayuda vendra bien
7  Programación / Scripting / Re: NODEJS (Obtener acceso a la cam, getUserMedia ) AYUDA en: 30 Octubre 2019, 17:07 pm
Encontre la solucion.

Los exploradores no confian en http, tiene que ser en https
8  Programación / Scripting / NODEJS (Obtener acceso a la cam, getUserMedia ) AYUDA en: 30 Octubre 2019, 15:31 pm

Este codigo me funciona en localhost, pero cuando intento entrar desde otro ordenador no funciona, no pide acceso a la camara. Aver si me podeis ayudar

El codigo pide acceso a la cam para luego enviar los frames por socket







Código:
<title>Streamer</title>

</head>

<body>

 

    holaaa

    <video autoplay></video>

 

 

    <script>

        // get video dom element

        const video = document.querySelector('video');

 

        // request access to webcam

        navigator.mediaDevices.getUserMedia({video: {width: 426, height: 240}}).then((stream) => video.srcObject = stream);

 

        // returns a frame encoded in base64

        const getFrame = () => {

            const canvas = document.createElement('canvas');

            canvas.width = video.videoWidth;

            canvas.height = video.videoHeight;

            canvas.getContext('2d').drawImage(video, 0, 0);

            const data = canvas.toDataURL('image/png');

            return data;

        }

        const WS_URL = "ws://192.168.0.112:3000";

        const FPS = 3;

        const ws = new WebSocket(WS_URL);

        ws.onopen = () => {

            console.log(`Connected to ${WS_URL}`);

            setInterval(() => {

                //ws.send(getFrame());

            }, 1000 / FPS);

        }

    </script>

</body>

</html>
9  Programación / PHP / Re: Busco consejo. ( Es buena idea usar php como cliente socket?) en: 19 Julio 2017, 20:16 pm
e leído que websocket de HTML5 es el sustituto de comet.
Que me decís?
10  Programación / PHP / Re: Busco consejo. ( Es buena idea usar php como cliente socket?) en: 18 Julio 2017, 01:51 am
Muchas gracias por la informacion.
Ya estoy viendo codigos sobre chats ajax/php...
Aver si me aclaro un poco.
Páginas: [1] 2
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines