Skip to content

Instantly share code, notes, and snippets.

@JamesMGreene
Last active December 23, 2015 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesMGreene/6585659 to your computer and use it in GitHub Desktop.
Save JamesMGreene/6585659 to your computer and use it in GitHub Desktop.
A jQuery-based bookmarklet to clarify the JSHint Options documentation. Only works in IE9+.
(function($) {
var nonBooleanOptions = ['indent', 'maxparams', 'maxdepth', 'maxstatements', 'maxcomplexity', 'maxlen'];
function clarifyDocs() {
var $ = window.jQuery;
var selectorExceptions = $.map(nonBooleanOptions, function(e) {
return ':not(:contains("' + e + '"))';
}).join('');
var selector = '.content > table tr:has(> td.name' + selectorExceptions+ ') > td.desc > p:first-child';
$(selector).each(function() {
var $para = $(this);
$para.html('If set to <code>true</code>, t' + $para.html().slice(1));
});
}
/* Only run this on the JSHint Options documentation page */
var jshintDocsUrl = 'http://www.jshint.com/docs/options/';
if (window.location.href.slice(0, jshintDocsUrl.length) === jshintDocsUrl) {
/* Load jQuery */
if (typeof $ !== 'function' || !$().jquery) {
var js = document.createElement('script');
js.addEventListener('load', clarifyDocs);
js.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js';
document.head.appendChild(js);
}
else {
clarifyDocs();
}
}
else {
console.log('Not viewing the JSHint Options documentation page! Expected URL starts with: ' + jshintDocsUrl);
}
})(window.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment