Skip to content

Instantly share code, notes, and snippets.

@jkozera
Last active August 5, 2020 17:24
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 jkozera/f3bbfdbeb1ffdcc08ef7a02acdfc625b to your computer and use it in GitHub Desktop.
Save jkozera/f3bbfdbeb1ffdcc08ef7a02acdfc625b to your computer and use it in GitHub Desktop.
(() => {
function patchControls($, old$) {
var checkbox = $('<input type="checkbox" id="tests-checkbox"><label for="tests-checkbox">Tests</label></input>');
checkbox.insertAfter(jQuery('.file-types.excludes h4'));
checkbox.click(() => {
$('.file-types.excludes input:text')[0].value = checkbox.is(':checked') ? '**/tests/**' : '';
old$('.search-action.codicon-search-refresh').click();
});
}
function patchJQ(old$, jqjs) {
var attempt = 0;
var interval = setInterval(() => {
if (!window.jQuery) {
console.log('Trying eval().');
eval(jqjs);
console.log('Attempt #' + (++attempt) + ': window.jQuery = ' + window.jQuery);
}
if (!window.jQuery) return;
clearInterval(interval);
window.$ = old$;
patchControls(window.jQuery, old$);
}, 3);
}
fetch('https://code.jquery.com/jquery-latest.min.js').then((r) => { return r.text(); }).then(patchJQ.bind(this, window.$));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment