Skip to content

Instantly share code, notes, and snippets.

@johnkpaul
Created April 13, 2012 17:14
Show Gist options
  • Save johnkpaul/2378436 to your computer and use it in GitHub Desktop.
Save johnkpaul/2378436 to your computer and use it in GitHub Desktop.
Change the default Javascript library on jsFiddle to jQuery
// ==UserScript==
// @match http://jsfiddle.net/*
// ==/UserScript==
// @author: John K. Paul @johnkpaul
// @license: http://www.opensource.org/licenses/MIT
// http://johnkpaul.tumblr.com/post/21030300518/changing-jsfiddles-default-library-to-jquery
(function(){
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ main +')();'));
document.body.appendChild(script);
//written in mootools out of respect to Piotr Zalewa :)
function main(){
var js_lib = document.id('js_lib'),
is_root = new URI(window.location).get('directory') === '/',
jq_opt_group = js_lib.getElement("[label=jQuery]"),
latest_jq_val = jq_opt_group.getElement(">").value;
if(is_root){
js_lib.value = latest_jq_val;
}
}
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment