Skip to content

Instantly share code, notes, and snippets.

@mathiasbynens
Created September 8, 2011 12:25
Show Gist options
  • Save mathiasbynens/1203270 to your computer and use it in GitHub Desktop.
Save mathiasbynens/1203270 to your computer and use it in GitHub Desktop.
Userscript that enables sensible defaults for jsFiddle.
// ==UserScript==
// @name Sensible defaults for jsFiddle.
// @author Mathias Bynens <http://mathiasbynens.be/>
// @link http://mths.be/bde
// @match http://jsfiddle.net/*
// ==/UserScript==
// Ignore existing fiddles
if (window.location.pathname == '/') {
// Insert JS before </body> and don’t use any libraries by default
[].forEach.call(document.querySelectorAll('#js_wrap option[value="b"], #js_lib option[value="11"]'), function(el) {
el.selected = true;
});
// Don’t use the “normalized” CSS (it’s more like a reset anyway)
document.getElementById('id_normalize_css').checked = false;
}
@oskarkrawczyk
Copy link

Sensible defaults? :-)

Btw. Normalized CSS == reset.css

@mathiasbynens
Copy link
Author

“Normalize” makes it sound as if http://necolas.github.com/normalize.css/ is used, IMHO :)

@oskarkrawczyk
Copy link

We'll change the wording the the future versions of JsFiddle, so there's no confusion

@mathiasbynens
Copy link
Author

Thanks Oskar, that’d be great!

@studgeek
Copy link

Is this used in greasemonkey or can it somehow be added in gist? Seems like the former?
Which means its no good for sharing jsfiddle/gists unless I get recipients to install GM and this userscript :/ Which means we really need jsfiddle to fix this - https://github.com/jsfiddle/jsfiddle-docs-alpha/issues/44. Thanks.

@mathiasbynens
Copy link
Author

I was asked how to disable the sidebar by default. You could add this to the userscript:

document.getElementById('sidebar').style.cssText = 'display: none; min-height: 525px;';
document.getElementById('content').style.marginLeft = '13px';

…or just use unsafeWindow.Layout.sidebar.hide(); (probably combined with the unsafeWindow polyfill).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment