Ayman Nedjmeddine
Ayman Nedjmeddine

Reputation: 12719

Injecting CSS or JS into Chrome on Android

Is there a way to inject (non-malicious) JavaScript (or CSS) statements into Chrome on Android whenever a matching URL is loaded?

Basically, I'd like to modify how some sites look.

One example would be m.facebook.com:
I'd like to inject something like:

#header: {position:fixed; margin-top:-2px}
#root:{margin-top:40px}

Unfortunately, Google doesn't extend the plugins API for the mobile platform!

Any thoughts?

Upvotes: 6

Views: 5368

Answers (1)

Anade
Anade

Reputation: 123

See how to create a bookmarklet, create one and put your JS code to it.

Example of the code:

javascript:(function(e){e.setAttribute("src","JS-URL-to-inject");document.getElementsByTagName("body")[0].appendChild(e);})(document.createElement("script"));void(0);

To execute the bookmarklet, follow instructions in the above link 1.

Upvotes: 2

Related Questions