Skip to content

Instantly share code, notes, and snippets.

@TuckerWhitehouse
Forked from thomaspark/bootswatchlet.js
Last active April 28, 2021 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TuckerWhitehouse/7828718 to your computer and use it in GitHub Desktop.
Save TuckerWhitehouse/7828718 to your computer and use it in GitHub Desktop.
javascript: (function (w) {
if (!w.jQuery) {
alert('jQuery is required.');
return;
}
if ($('#bootswatch').length) {
alert('Bookmaklet already loaded.');
return;
}
var $link = $('<link>', {
rel: 'stylesheet',
id: 'bootswatch'
}).appendTo('head');
var $select = $('<select>', {
css: {
top: 8,
right: 8,
position: 'fixed',
zIndex: 999999
},
html: '<option value="null">Bootswatch</option>'
}).appendTo('body');
$select.on('change', function (e) {
var value = $select.val();
value && $link.attr('href', value);
});
$.ajax({
url: 'http://api.bootswatch.com/3/'
}).done(function (data, status, xhr) {
data.themes.forEach(function (val, key) {
$select.append('<option value="' + val.cssCdn + '">' + val.name + '</option>');
});
});
})(window);
@pritdeveloper
Copy link

better version it autoload jquery
javascript:(function(){var e=document.createElement("script");e.src="//code.jquery.com/jquery-latest.min.js";e.setAttribute("async","true");document.documentElement.firstChild.appendChild(e)})();(function(e){if(!e.jQuery){alert("jQuery is required.");return}if($("#prit-bootswatch").length){alert("Bookmaklet already loaded.");return}var t=$("",{rel:"stylesheet",id:"prit-bootswatch"}).appendTo("head");var n=$("",{css:{top:8,right:8,position:"fixed",zIndex:999999},html:'Bootswatch'}).appendTo("body");n.on("change",function(e){var r=n.val();r&&t.attr("href",r)});$.ajax({url:"//api.bootswatch.com/3/"}).done(function(e,t,r){e.themes.forEach(function(e,t){n.append(''+e.name+"")})})})(window);

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