<commit_before>function loadScript(url, callback) {
    // Adding the script tag to the head as suggested before
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;

    // Then bind the event to the callback function.
    // There are several events for cross browser compatibility.
    script.onreadystatechange = callback;
    script.onload = callback;

    // Fire the loading
    head.appendChild(script);
}

function highlightCode() {
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.innerHTML = 'hljs.initHighlighting()';

    head.appendChild(script);
}

var files = ["java", "sql", "c", "c++", "cxx", "cpp", "py", "sh", "pl", "js", "css"];

var xhr = new XMLHttpRequest();
xhr.open('GET', document.location, false);
xhr.send(null);

content_type = xhr.getResponseHeader("content-type");
pos = content_type.indexOf("html");

extension =
    return filename.split('.').pop();

if (files.indexOf(extension) >= 0) {

    chrome.storage.sync.get({
        theme: 'default',
    }, function(items) {
        var code = document.body.textContent;
        document.write("<pre><code>" + code + "</code></pre>");

        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/' + items.theme + '.min.css';
        document.getElementsByTagName('head')[0].appendChild(link);

        loadScript('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js', highlightCode);
    });

}<commit_msg>Highlights text files that are supported by highlight.js<commit_after>function loadScript(url, callback) {
    // Adding the script tag to the head as suggested before
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = url;

    // Then bind the event to the callback function.
    // There are several events for cross browser compatibility.
    script.onreadystatechange = callback;
    script.onload = callback;

    // Fire the loading
    head.appendChild(script);
}

function highlightCode() {
    var head = document.getElementsByTagName('head')[0];
    var script = document.createElement('script');
    script.innerHTML = 'hljs.initHighlighting()';

    head.appendChild(script);
}

//var files = ["s", "asm", "java", "sql", "c", "c++", "cxx", "cpp", "h", "py", "sh", "pl", "js", "css"];

var xhr = new XMLHttpRequest();
xhr.open('GET', document.location, false);
xhr.send(null);

content_type = xhr.getResponseHeader("content-type");
html_pos = content_type.indexOf("html");
text_pos = content_type.indexOf("text");

//extension = window.location.href.split('.').pop();

if (text_pos != -1 && html_pos == -1) {

    chrome.storage.sync.get({
        theme: 'default',
    }, function(items) {
        var code = document.body.textContent;
        document.write("<pre style=\"white-space: pre-wrap; white-space: -moz-pre-wrap;white-space: -pre-wrap;white-space: -o-pre-wrap;word-wrap: break-word;\"><code>" + code + "</code></pre>");

        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.href = 'https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/styles/' + items.theme + '.min.css';
        document.getElementsByTagName('head')[0].appendChild(link);

        loadScript('https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.8.0/highlight.min.js', highlightCode);
    });

}
{'fraction_non_alphanumeric': 0.17200766913174473, 'fraction_numerical': 0.005751848808545604, 'mean_word_length': 3.5879396984924625, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6911867', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1110, 'n_words': 242}