tintinweb / electron-inject

Inject javascript into closed source electron applications e.g. to enable developer tools for debugging.
332 stars 37 forks source link

Fails to enable devtools or inject js into slack #15

Open CodeF53 opened 2 years ago

CodeF53 commented 2 years ago

Test Procedure

The following is the contents of test.js

setInterval(()=>{console.log("test")}, 100)

If it is successfully injected, we should see test logged to the console 10 times every second

To ensure the process runs correctly, I run the following to make sure slack has no background instances

taskkill -im slack.exe -f

Running the following command leads to slack successfully launching, with a perfect trace of what is being logged into the devtools console.

python -m electron_inject -d -t 600 -r ./test.js - C:\ProgramData\F53\slack\app-4.27.154\slack.exe

Pressing F12 in this new slack window does not open devtools, despite us having the -d argument

Running the /slackdevtools in any slack chat shows them manually.\ Looking at the console we just opened, test is not being logged 10 times every second

Possibly relevant Info

Python 3.10.1\ electron-inject 0.7\ all installed python packages\ Windows 10 Enterprise N build 19044.1826\ Slack 4.27.154

CodeF53 commented 2 years ago

I have a different OS on my laptop (Manjaro Linux).

Running the same procedure on it gives me a different result.

python -m electron_inject -d -t 600 -r /home/f53/Projects/SlackMod/inject.js - /usr/lib/slack/slack

system info

Python 3.10.5\ electron-inject 0.7\ all installed python packages\ I still dont know my way around linux well enoiugh to give much more info

Kein commented 1 year ago

Python 3.8.5 x64 Electron-inject: 0.7 Windows 10 x64 Slack: Production 4.32.122 64-bit

Running python -m electron_inject --enable-devtools-hotkeys -d -t 60 - c:\CoolDood\AppData\Local\slack\app-4.32.122\slack.exe

Does not enable dev tools. The terminal has some logging info going on but that is.

mnn commented 11 months ago

Yep, doesn't work with Slack at all. Script is not injected, keys don't work.

Python 3.10.10 electron-inject 0.7 Manjaro Slack 4.32.122

Probable cause:

[__init__.py -               inject() ][    INFO] injecting hotkeys script into 54D02EB3556E5B88E6981F034B2CB656
[102485:1107/070126.237769:ERROR:devtools_http_handler.cc(766)] Rejected an incoming WebSocket connection from the http://localhost:33859 origin. Use the command line flag --remote-allow-orig
ins=http://localhost:33859 to allow connections from this origin or --remote-allow-origins=* to allow all origins.
[__init__.py -               inject() ][   ERROR] Handshake status 403 Forbidden -+-+- {'content-length': '241', 'content-type': 'text/html'} -+-+- b'Rejected an incoming WebSocket connection
 from the http://localhost:33859 origin. Use the command line flag --remote-allow-origins=http://localhost:33859 to allow connections from this origin or --remote-allow-origins=* to allow all
 origins.'

Edit:

running it like this seems to somewhat work - at least the script (not the keys).

python -m electron_inject -d -t 60 -r test.js - /usr/bin/slack '--remote-allow-origins=*' 2>&1 | tee ei_slack.log