Skip to content

Instantly share code, notes, and snippets.

@cecekpawon
Created January 11, 2016 03:26
Show Gist options
  • Save cecekpawon/58ea11808f0c0b8ff160 to your computer and use it in GitHub Desktop.
Save cecekpawon/58ea11808f0c0b8ff160 to your computer and use it in GitHub Desktop.
hljs.user.js
(function () {
// ==UserScript==
// @name highlight.js bundle
// @namespace http://blog.thrsh.net
// @author daYOda (THRSH)
// @description Save & load highlight.js download bundle
// @version 1.0
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// @match https://highlightjs.org/download*
// @run-at document-start
// ==/UserScript==
if ($) {
$(document).ready(function(){
var key = "hljsbundle", hljsbundle = JSON.parse(localStorage.getItem(key)) || {};
$("#download-form input[type='checkbox']")
.each(function(){
var propname = $(this).prop("name");
if (!hljsbundle.hasOwnProperty(propname)) {
hljsbundle[propname] = $(this).prop("checked") ? 1 : 0;
}
$(this)
.prop("checked", (hljsbundle[propname] === 1))
.click(function(){
hljsbundle[propname] = $(this).prop("checked") ? 1 : 0;
localStorage.setItem(key, JSON.stringify(hljsbundle));
});
});
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment