Skip to content

Instantly share code, notes, and snippets.

@danielres
Last active December 13, 2015 17:58
Show Gist options
  • Save danielres/4951525 to your computer and use it in GitHub Desktop.
Save danielres/4951525 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name capybara serving assets
// @namespace http://studio.pixarea.com
// @description adds base tag to serve assets in pages generated by capybara's "save_and_open_page"
// @include file:///*/tmp/capybara/capybara-*.html
// @version 1
// @grant none
// ==/UserScript==
// Note: you need to enable GreaseMonkey for local files for this to work:
// type "about:config" in the Firefox address bar, and set extensions.greasemonkey.fileIsGreaseable = true
for( i = 0; (l = document.getElementsByTagName("link")[i]); i++ ) {
if( l.getAttribute("rel").indexOf("style") >= 0 ) l.href = l.href.replace("file:///cucumber_test_assets/","http://localhost:3000/assets/");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment