<commit_before>$(document).ready(function() {
    $("#destroyH").click(function() {
        chrome.tabs.query({}, function(tabs) {
            for (var i = 0; i < tabs.length; i++) {
                chrome.tabs.sendMessage(
                    tabs[i].id,
                    "destroyH",
                    function(response) {
                        $("#destroyH").text("Destroying H");
                    });
            }
        });
    });

    $("#destroyImg").click(function() {
        chrome.tabs.query({}, function(tabs) {
            for (var i = 0; i < tabs.length; i++) {
                chrome.tabs.sendMessage(
                    tabs[i].id,
                    "destroyImg",
                    function(response) {
                        $("#destroyImg").text("Destroying Img");
                    });
            }
        });
    });
});<commit_msg>Run only on current tab. Centralise method to run functions on active tab<commit_after>$(document).ready(function() {
    $("#destroyH").click(function() {
        runOnActiveTab(function(tab) {
            chrome.tabs.sendMessage(
                tab.id,
                "destroyH",
                function(response) {
                    $("#destroyH").text("Destroying H");
                });
        });
    });

    $("#destroyImg").click(function() {
        runOnActiveTab(function(tab) {
            chrome.tabs.sendMessage(
                tab.id,
                "destroyImg",
                function(response) {
                    $("#destroyImg").text("Destroying Img");
                });
        });


    });
});

function runOnActiveTab(functionOnTab) {
    var tabId;
    chrome.tabs.query({
        currentWindow: true,
        active: true
    }, function(tabs) {
        functionOnTab(tabs[0]);
    });
}
{'fraction_non_alphanumeric': 0.15418746533555186, 'fraction_numerical': 0.0016638935108153079, 'mean_word_length': 1.358169934640523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3463061', 'n_tokens_mistral': 496, 'n_tokens_neox': 464, 'n_words': 73}