Last active
December 23, 2015 05:18
-
-
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+.
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
(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