freddylindstrom
freddylindstrom

Reputation: 431

Edit CSS in browser cache

I am building an app on top of webkit, I need to modify a CSS file (edit a selector), which I can do once the page is loaded using Javascript. In my particular scenario I may load the page many times and I would like to mutate the CSS in the cache (using Javascript, as opposed to hacking webkit). Any ideas?

Upvotes: 0

Views: 103

Answers (1)

graste
graste

Reputation: 357

Without entirely understanding your use case I see at least three cheap and fast methods to override some styles:

  • use one of the many bookmarklets out there (e.g. this one by Paul Irish) to play around injecting styles or
  • use a short snippet of javascript ondomready to inject a stylesheet with selectors and styles into the head of the document (similar to the bookmarklet above) or
  • define a specific enough CSS selector and simply include an inline style element in your document (which I would not suggest)

All three methods are basically the same. Depending on what you have, are able to edit or want to achieve either method may be more suitable.

User stylesheets or extensions like Stylebot for Google Chrome may be another possibility to look into.

Weird stuff like loading referenced stylesheets via javascript's XHR, get the content of the file, modify or inject stuff and reapply the styles to the current document are possible as well but probably not what you're looking for.

Upvotes: 1

Related Questions