-
-
Save Lukas238/d0b8c1c8317f2eb2a8326c89c9e79ebe to your computer and use it in GitHub Desktop.
Bootswatch bookmarklet - Updated 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(e%2Ca%2Cg%2Ch%2Cf%2Cc%2Cb%2Cd)%7Bif(!(f%3De.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc%3Da.createElement(%22script%22)%3Bc.type%3D%22text%2Fjavascript%22%3Bc.src%3D%22%2F%2Fajax.googleapis.com%2Fajax%2Flibs%2Fjquery%2F%22%2Bg%2B%22%2Fjquery.min.js%22%3Bc.onload%3Dc.onreadystatechange%3Dfunction()%7Bif(!b%26%26(!(d%3Dthis.readyState)%7C%7Cd%3D%3D%22loaded%22%7C%7Cd%3D%3D%22complete%22))%7Bh((f%3De.jQuery).noConflict(1)%2Cb%3D1)%3Bf(c).remove()%7D%7D%3Ba.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window%2Cdocument%2C%221.3.2%22%2Cfunction(%24%2CL)%7Bif(%24(%22.bootswatcher%22)%5B0%5D)%7B%24(%22.bootswatcher%22).remove()%7Delse%7Bvar%20%24e%3D%24('%3Cselect%20class%3D%22bootswatcher%22%3E%3Coption%3Ecerulean%3C%2Foption%3E%3Coption%3Ecosmo%3C%2Foption%3E%3Coption%3Ecyborg%3C%2Foption%3E%3Coption%3Edarkly%3C%2Foption%3E%3Coption%3Eflatly%3C%2Foption%3E%3Coption%3Ejournal%3C%2Foption%3E%3Coption%3Elitera%3C%2Foption%3E%3Coption%3Elumen%3C%2Foption%3E%3Coption%3Elux%3C%2Foption%3E%3Coption%3Emateria%3C%2Foption%3E%3Coption%3Eminty%3C%2Foption%3E%3Coption%3Epulse%3C%2Foption%3E%3Coption%3Esandstone%3C%2Foption%3E%3Coption%3Esimplex%3C%2Foption%3E%3Coption%3Esketchy%3C%2Foption%3E%3Coption%3Eslate%3C%2Foption%3E%3Coption%3Esolar%3C%2Foption%3E%3Coption%3Espacelab%3C%2Foption%3E%3Coption%3Esuperhero%3C%2Foption%3E%3Coption%3Eunited%3C%2Foption%3E%3Coption%3Eyeti%3C%2Foption%3E%3C%2Fselect%3E')%3Bvar%20l%3D1%2BMath.floor(Math.random()*%24e.children().length)%3B%24e.css(%7B%22z-index%22%3A%2299999%22%2Cposition%3A%22fixed%22%2Ctop%3A%225px%22%2Cright%3A%225px%22%2Copacity%3A%220.5%22%2Ccolor%3A%22%23000%22%7D).hover(function()%7B%24(this).css(%22opacity%22%2C%221%22)%7D%2Cfunction()%7B%24(this).css(%22opacity%22%2C%220.5%22)%7D).change(function()%7Bif(!%24(%22link.bootswatcher%22)%5B0%5D)%7B%24(%22head%22).append('%3Clink%20rel%3D%22stylesheet%22%20class%3D%22bootswatcher%22%3E')%7D%24(%22link.bootswatcher%22).attr(%22href%22%2C%22%2F%2Fstackpath.bootstrapcdn.com%2Fbootswatch%2F4.5.2%2F%22%2B%24(this).find(%22%3Aselected%22).text().toLowerCase()%2B%22%2Fbootstrap.min.css%22)%7D).find(%22option%3Anth-child(%22%2Bl%2B%22)%22).attr(%22selected%22%2C%22selected%22).end().trigger(%22change%22)%3B%24(%22body%22).append(%24e)%7D%3B%7D)%3B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: (function (e, a, g, h, f, c, b, d) { | |
if (!(f = e.jQuery) || g > f.fn.jquery || h(f)) { | |
c = a.createElement('script'); | |
c.type = 'text/javascript'; | |
c.src = '//ajax.googleapis.com/ajax/libs/jquery/' + g + '/jquery.min.js'; | |
c.onload = c.onreadystatechange = function () { | |
if (!b && (!(d = this.readyState) || d == 'loaded' || d == 'complete')) { | |
h((f = e.jQuery).noConflict(1), (b = 1)); | |
f(c).remove(); | |
} | |
}; | |
a.documentElement.childNodes[0].appendChild(c); | |
} | |
})(window, document, '1.3.2', function ($, L) { | |
if ($('.bootswatcher')[0]) { | |
$('.bootswatcher').remove(); | |
} else { | |
var $e = $( | |
'<select class="bootswatcher"><option>cerulean</option><option>cosmo</option><option>cyborg</option><option>darkly</option><option>flatly</option><option>journal</option><option>litera</option><option>lumen</option><option>lux</option><option>materia</option><option>minty</option><option>pulse</option><option>sandstone</option><option>simplex</option><option>sketchy</option><option>slate</option><option>solar</option><option>spacelab</option><option>superhero</option><option>united</option><option>yeti</option></select>' | |
); | |
var l = 1 + Math.floor(Math.random() * $e.children().length); | |
$e.css({ | |
'z-index': '99999', | |
position: 'fixed', | |
top: '5px', | |
right: '5px', | |
opacity: '0.5', | |
color: '#000' | |
}) | |
.hover( | |
function () { | |
$(this).css('opacity', '1'); | |
}, | |
function () { | |
$(this).css('opacity', '0.5'); | |
} | |
) | |
.change(function () { | |
if (!$('link.bootswatcher')[0]) { | |
$('head').append('<link rel="stylesheet" class="bootswatcher">'); | |
} | |
$('link.bootswatcher').attr( | |
'href', | |
'//stackpath.bootstrapcdn.com/bootswatch/4.5.2/' + | |
$(this).find(':selected').text().toLowerCase() + | |
'/bootstrap.min.css' | |
); | |
}) | |
.find('option:nth-child(' + l + ')') | |
.attr('selected', 'selected') | |
.end() | |
.trigger('change'); | |
$('body').append($e); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment