How to inject external javascript code in phone browser
Asked Answered
T

3

5

I would like to inject an external javascript code into a certain webpage in a mobile phone browser such as chrome or opera mini. On computers, we can do this directly in the console or through extensions such as Scripty. Unfortunately, phone browsers don't show consoles nor do they have extensions. Please how can I achieve this?

Tannenwald answered 26/12, 2021 at 11:7 Comment(0)
C
4

You can use eruda. It's a console for mobile browsers. It also has many plugins such as eruda-touches which visualizes all current touches and their positions. Personally, I made a bookmark using chrome browser on my phone to implement this console directly in any page when i search for its name. Watch this youtube video for more details.

Checker answered 26/12, 2021 at 12:7 Comment(0)
P
4

You can use the address-bar to run javascript in that page.

(Tested in Chrome)

Like this:

Step0 Step1 Step2

Since all the codes will be in one line, make sure you use semicolons properly.

Purebred answered 26/12, 2021 at 12:11 Comment(3)
Didn't work for me in 2024.Creed
Works in Chrome and Kiwi. Please make sure not to tap on the one with the search icon. You should be tapping the one with the globe icon (Yes, chromous swapped the globe and the search options recently for JavaScript injected like this for security reasons). Also, if you are copy pasting, you'll have to manually add "javascript:" before the code text in the address bar. (Because chromium strips away "JavaScript:" from the beginning for security reasons when pasted).Purebred
It worked fine indeed after tapping on globe icon.Creed
A
2

If you are using android, then you can use chrome inspect to access console on phone browser using a computer.

  1. First you should connect your phone to your computer via USB and authorize it.
  2. In Chrome on your computer open the following link chrome://inspect
  3. There you can see opened tabs on your mobile device, and open their console.
Acquittal answered 26/12, 2021 at 12:9 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.