title: Replace the directory of an image src, using Javascript
body: <p>I'd like to replace the directory of an image <code>src</code>, changing <code>.*pinterest.com/192/</code> to <code>.*pinterest.com/550/</code>.</p>
  
  <p>I had been trying to modify this code to change the directory name instead of just removing the "_b" part of the filename.</p>
  
  <pre><code>document.getElementById("chrome")
  .addEventListener("DOMNodeInserted", function (a) {
  if (a.target.tagName &amp;&amp; a.target.tagName == "DIV" &amp;&amp; /entry\s?/.test(a.target.className)) {
      var b = a.target.getElementsByTagName("img");
      for (var c in b) {
          var d = b[c];
          if (/.*pinterest\.com.*_b\.\w+$/.test(d.src)) {
              d.style.width = d.style.height = "inherit";
              d.src = d.src.replace(/_b\.(\w+)$/, ".$1")
          }
      }
  }
  }, false)
  </code></pre>