Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

522
Vistas
Open ALL External links in Browser (NWjs)

I was trying to make my own standalone copy of Google Chat using NWjs, but I ran into some problems.

So, when you open a link in the NWjs window, it opens in another NWjs window. However, I would like to open it in the default system browser.

I tried using Tampermonkey, which didn't work, since I figured out how to add extensions to NWjs, and making my own extension didn't work either, so I found out about NWjs's inject_js_end and tried to use that.

But, I keep getting Uncaught TypeError: Failed to set the 'innerHTML' property on 'Element': This document requires 'TrustedHTML' assignment. error.

I assumed this was because CSP was blocking my jQuery code, so I modded CSP-Blocker for chrome but it didn't work.

package.json:

{
    "name": "Chat",
    "main": "index.html",
    "chromium-args": "--enable-logging=stderr --load-extension='./AntiCSP'",
    "inject_js_end": "script.js",
    "window": {
        "title": "Chat",
        "icon": "ico.png",
        "width": 1280,
        "height": 720,
        "resizable": true
    }
}

index.html:

<!DOCTYPE html>
<html>
    <head>
        <title>Loading...</title>
    </head>
    
    <body>
        <script>
window.location.replace("https://chat.google.com")
        </script>
    </body>
</html>

script.js

//jQuery here
console.log("[DEBUG]: Replace links to browser...")

$('a').click(function() {
    nw.Shell.openExternal($(this).prop("href"));
})

How can I force all links in the webpage to open in system browser? I am mostly a Python dev and I haven't found any working solutions yet.

EDIT: As Jaredcheeda pointed out, inject_js_end does only run once. Does anyone have other possible solutions I could use? Maybe Tampermonkey...?

EDIT2: Anyone have any ideas? I still don't have any ideas... 

EDIT3: I was maybe thinking of writing some kind of jQuery to replace all <a> tags with <script> tags that could open it in browser with nw.Shell.openExternal(), then loop it. Problem is, I don't know how to do that.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Correct answer: Use the official API

  • https://developers.google.com/chat/api/guides

Anything other than that will just be very hacky. The inject_js_end only runs once. What happens when two people are IMing and a new message is received containing a link, your function to hijack the click event and open in a default browser would need to be re-ran after every IM. You could try listening to navigation events and preventing them, but anything you do is just gonna be hacky at the end.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda