<commit_before>var latestMouse = {
    x: 0,
    y: 0,
};

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        console.log("[whiten] content script: on message", request);
        var result = "ok";
        if (request.cmd_id == "whiten-bg") {
            var elements = allElementsFromPoint(latestMouse.x, latestMouse.y);
            if (elements.length == 0) {
                console.log("[whiten] no elements found");
            }
            elements.forEach(function(element) {
                element.style.backgroundColor = "white";
                element.style.backgroundImage = "url('')";
            });
        } else if (request.cmd_id == "whiten-rm") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                element.style.backgroundColor = "red";
                $(element).animate({
                    opacity: 0,
                }, {
                    complete: function() {
                        element.remove();
                    }
                });
            } else {
                console.log("[whiten] no element found");
            }
        } else if (request.cmd_id == "whiten-rm-by-class") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                classes = $(element).attr("class").split(" ");
                for (i=0; i<classes.length; i++) {
                    elements = $("." + classes[i]);
                    elements.css("background-color", "red");
                    elements.animate({
                        opacity: 0,
                    }, {
                        complete: function() {
                            elements.remove();
                        }
                    });
                }
            }
        } else if (request.cmd_id == "whiten-hl") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                var original_color = element.style.backgroundColor;
                var original_border = element.style.border;
                element.style.border = "3px solid red";
                $(element).animate({
                    backgroundColor: "red",
                }, {
                    complete: function() {
                        $(element).animate({
                            backgroundColor: original_color,
                            border: original_border,
                        });
                    }
                });
            }
        } else if (request.cmd_id == "whiten-hl-by-class") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                classes = $(element).attr("class").split(" ");
                for (i=0; i<classes.length; i++) {
                    elements = $("." + classes[i]);
                    var original_color = elements.css("background-color");
                    var original_border = elements.css("border");
                    elements.css("border", "3px solid red");
                    elements.animate({
                        backgroundColor: "red",
                    }, {
                        complete: function() {
                            $(elements).animate({
                                backgroundColor: original_color,
                                border: original_border,
                            });
                        }
                    });
                } // end for loop<commit_msg>fix: class attribute may be null<commit_after>var latestMouse = {
    x: 0,
    y: 0,
};

chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        console.log("[whiten] content script: on message", request);
        var result = "ok";
        if (request.cmd_id == "whiten-bg") {
            var elements = allElementsFromPoint(latestMouse.x, latestMouse.y);
            if (elements.length == 0) {
                console.log("[whiten] no elements found");
            }
            elements.forEach(function(element) {
                element.style.backgroundColor = "white";
                element.style.backgroundImage = "url('')";
            });
        } else if (request.cmd_id == "whiten-rm") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                element.style.backgroundColor = "red";
                $(element).animate({
                    opacity: 0,
                }, {
                    complete: function() {
                        element.remove();
                    }
                });
            } else {
                console.log("[whiten] no element found");
            }
        } else if (request.cmd_id == "whiten-rm-by-class") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                classes = $(element).attr("class");
                classes = (classes == null) ? [] : classes.split(" ");
                for (i=0; i<classes.length; i++) {
                    elements = $("." + classes[i]);
                    elements.css("background-color", "red");
                    elements.animate({
                        opacity: 0,
                    }, {
                        complete: function() {
                            elements.remove();
                        }
                    });
                }
            }
        } else if (request.cmd_id == "whiten-hl") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                var original_color = element.style.backgroundColor;
                var original_border = element.style.border;
                element.style.border = "3px solid red";
                $(element).animate({
                    backgroundColor: "red",
                }, {
                    complete: function() {
                        $(element).animate({
                            backgroundColor: original_color,
                            border: original_border,
                        });
                    }
                });
            }
        } else if (request.cmd_id == "whiten-hl-by-class") {
            element = document.elementFromPoint(latestMouse.x, latestMouse.y);
            if (element) {
                classes = $(element).attr("class");
                classes = (classes == null) ? [] : classes.split(" ");
                for (i=0; i<classes.length; i++) {
                    elements = $("." + classes[i]);
                    var original_color = elements.css("background-color");
                    var original_border = elements.css("border");
                    elements.css("border", "3px solid red");
                    elements.animate({
                        backgroundColor: "red",
                    }, {
                        complete: function() {
                            $(elements).animate({
                                backgroundColor: original_color,
                                border: original_border,
                            });
                        }
                    });
                } // end for loop
{'fraction_non_alphanumeric': 0.12038435140700068, 'fraction_numerical': 0.0024708304735758407, 'mean_word_length': 1.1316559391456993, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7281657', 'n_tokens_mistral': 1753, 'n_tokens_neox': 1636, 'n_words': 320}