Skip to content

Instantly share code, notes, and snippets.

@brutuscat
Last active April 5, 2019 22:30
Show Gist options
  • Save brutuscat/1fded05d2a15fd5040d16604c3488948 to your computer and use it in GitHub Desktop.
Save brutuscat/1fded05d2a15fd5040d16604c3488948 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('#toc ~ #content-text > div > h1').removeAttr('class');
$('#toc ~ #content-text > div > h1 > span').removeAttr('class');
$('#toc ~ #content-text > div > h2').removeAttr('class');
$('#toc ~ #content-text > div > h2 > span').removeAttr('class');
$('#toc .h3, #toc .h4, #toc .h5, #toc .h6').remove();
$('#toc .h1 > span, #toc .h2 > span').removeAttr('class');
$('#toc ~ #content-text > table').prev().remove();
var startsWithEnglish = /^English/;
$('table tr:nth-child(1) td:nth-child(1):contains("English")')
.filter(function () {
return startsWithEnglish.test($.trim($(this).text()));
})
.parent()
.addClass('v-theader');
embedYoutubeLinks();
});
function embedYoutubeLinks() {
var ytLinks = $('#content-text a[href*="https://youtu"], #content-text a[href*="https://www.youtu"]');
ytLinks.each(function(){
var ytUri = $(this).text();
var videoId = url('?v', ytUri) || url('1', ytUri);
var iframe = document.createElement('iframe');
iframe.src = 'https://www.youtube.com/embed/' + videoId +'? cc_lang_pref=cat&hl=cat&modestbranding=1&rel=0&cc_lang_pref=cat&hl=cat&modestbranding=1&rel=0';
iframe.width = 560;
iframe.height = 315;
iframe.frameborder = 0;
iframe.allow = "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture";
iframe.toggleAttribute("allowfullscreen");
$(this).replaceWith(iframe);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment