Johansrk
Johansrk

Reputation: 5250

Howto inject local css into webpage

I would like to test out CSS on a webpage that I don't have direct access to. Does anyone know how to achieve this ?

So I write my CSS, and on save, that code is used on the webpage. Of cause this will only happen on my local machine

Upvotes: 0

Views: 477

Answers (1)

Dave Salomon
Dave Salomon

Reputation: 3287

You could use a simple Bookmarklet, similar to how various jQuery Injectors work.

http://mcdlr.com/css-inject/ might do the trick. For something a bit more dynamic (which takes a URL to a CSS file), check out this jsfiddle I've whipped up! It shouldn't be too hard to modify to pass in inline styles, etc.. so should be a good starting point.

javascript:var%20csshref=prompt('enter%20css%20url');var%20s=document.createElement('link');s.setAttribute('href',csshref);s.setAttribute('type','text/css');s.setAttribute('rel','stylesheet');document.getElementsByTagName('body')[0].appendChild(s);void(s);

Re your comment...

You can just use F12 Dev Tools. Chrome, Firefox and IE are all quite good now. (My preference is Chrome).

Upvotes: 1

Related Questions