19

I know about Workspaces recently introduced in DevTools but that is not that i need. For example: page uses jquery that is loaded from CDN, i modify jquery library code, press ctrl-s, reload page -> modifications are lost. Or i want to debug some site i don't have an ability to change files of.

I don't want only save changes as in save CSS - while browsing, how can I save the css files from inside chrome dev or firebug to local directory, i want them to persist between page reloads.

Community
  • 1
  • 1
vladimir
  • 191
  • 1
  • 5
  • Hey people, thanks for all the answers. Unfortunately, neither of the answers that depend on nothing but Chrome itself works for me for some reason. I have to assume it's a bug in my particular Chrome version or something like that. I'll give a `+1` to all of the answers since all of them suggest one or another useful approach to solving or working around the problem. I'll give the bounty to the answer that was already present because it does seem to fit the original question better. Sorry I can't actually test them and do better. – Septagram Mar 27 '14 at 14:42

10 Answers10

6

You got most of it, but here's the slight change:

Make a change in the Styles pane (or in Sources), then click over to Sources, and when your modified file is open, hit ctrl-s.

Then you can right-click the asset in the Sources list and hit Save As... and save the new modified file to disk.

enter image description here

There is no way to save a modified remote file without persisting it to disk and expect it to be changed on reload.

Paul Irish
  • 47,354
  • 22
  • 98
  • 132
  • 5
    Maybe I didn't say it clear enough. I save file as, edit it, save again, reload the page. Result: original (not modified) file is loaded from server. Expected result: file from disk is loaded instead. Is it possible? – vladimir Sep 04 '13 at 05:09
6

Workspaces allow you to edit files mapped to a local directory - but naturally, a pre-requisite is to be serving local files.

If you're playing with files you don't have direct/convenient access to (for whatever reason), I recommend setting up a tampering proxy like Burp. In a nutshell, you would be able to modify the server response and perform on-the-fly search and replace like cdn.example.com/jquery-library.js to localhost:8080/jquery-library.js in the html body. All you have to do afterwards is set up a local server (trivial) and edit the local instance of the script!

This is a handy pattern to preview local changes against production content, as long as it's not used in lieu of a test environment.

Oleg
  • 24,465
  • 8
  • 61
  • 91
3

It is possible, but quite tricky:

  • open resources and right clik to the folder with styles\resources (fo not forget to click "allow" on the dialog that appears below the adress bar)
  • then right click on the concrete resource and choose "save as" (save it to the working directory that you specified in the prev step)
  • then right click to the same resource and choose "Map to file system resource" (write the same name as in prev. step, e.g. all.css but not all.css?id=234234234, just in case)
  • modify the styles in the dev tools.
  • refresh the page (and realise that all you modifications doesn't applied)
  • open resources, find your workspace folder and your resource in it (e.g. all.css)
  • right click on that resource and choose "local modifications"
  • in opened console click to "apply original content" and realise that you styles has been applied =) It's quit a tricky way and the better idea is to use something like fiddler to replace resources to local files.
Mikita Manko
  • 1,133
  • 9
  • 9
3

You could try it this way (for jquery):

-load the page first time and on the sources tab put a breakpoint on line number 1 -then reload the page modify the file and save ( you can see that the page has paused due to the breakpoint ) -press the play button and the page will start to load. The modifications you made will work. The downside of this solution is that once you refresh again the page, the modifications will be lost.

Hope that helps!

chyupa
  • 179
  • 2
  • 9
2

As far as I can tell, there's no way to do this in Chrome's DevTools. You should look through the documentation about saving and making local changes. The only thing that seems to persist through reloads is snippets... but it doesn't seem like that's what you want.

If ever a solution for this is made... I want it. For now, it seems the best you can do is content scripts and the like.

uber5001
  • 3,864
  • 4
  • 23
  • 44
2

I don't know if this qualifies as an answer, but it is what I am doing, and the closer that I have get to what you want.

I load the page in the browser, and the I do save as in a local file. Note that I am saving the full page, with HTML, js and CSS.

Now, if I want to modify the a CSS, I edit the HTML and direct these file (or files) to my development files.

I reload the page, and now I can work as you want (saving and reloading what I have saved).

Of course that means that you have full access to the files, and most probably they are local, but I don't think that you are really willing to edit the real web files on line.

When I am finished modifying the files, it's just a matter of syncing my dev files with the web files .

vals
  • 61,425
  • 11
  • 89
  • 138
2

Just a tip, under Firefox i use Greasemonkey. I dont know if you know this tool, but it allows to run javascript scripts over a webpage for a website. Then, with an adapted javascript you can change css dynamically.

A little get started for greasemonkey: http://www.webmonkey.com/2010/02/get_started_with_greasemonkey/

For chrome it is tampermonkey : http://tampermonkey.net/faq.php

Xavier S.
  • 1,147
  • 13
  • 33
2

Note, Utilizes jQuery library (not required)

Try, at console

function restyle() {
  $("*").css("color", "blue"); /* development elements, css, js */
  $("head").append("<script>console.log(\"restyle\")</script>"); /* js */
  var t = document.querySelectorAll("*"); /* modified document */
  var outer = document.documentElement.outerHTML; /* modified document */
  var inner = document.documentElement.innerHTML; /* modified document */
  return $.ajax() /* `pseudo` `reload` */
  .done(function(data) { /* original document */
  document.documentElement.innerHTML = outer; /* `psuudo` `document` `reload` */
  console.log(data, inner, outer, $(t)) /* options, `callbacks` */
  /* $.each($(t), function(index, value) { console.log(value) }); */
  })
};
restyle();
guest271314
  • 1
  • 15
  • 104
  • 177
2

I use my apache in debug mode with eclipse so the cahnges are reflected to the site as soon as I save the page.

sampopes
  • 2,646
  • 1
  • 22
  • 34
0

See https://stackoverflow.com/a/31585725/52817:

The Resource Override extension allows you to do exactly that:

  • create a file rule for the url you want to replace
  • edit the js/css/etc in the extension
  • reload as often as you want :)

You can even add a tab to the dev tools.

Community
  • 1
  • 1
laktak
  • 57,064
  • 17
  • 134
  • 164