<commit_before>(function () {
    var global = (function() {
        return this;
    })(), D = Deferred;

    var isEnabled = false;

    var requestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame;

    var UNKNOWN_URL = "*UNKNOWN*";
    var NOT_AN_APNG = "*NOT_AN_APNG*";

    var loadBytes = function (url) {
        var d = D();
        if (inStopList(url)) {
            d.reject("Url in stop list");
        } else if (url.substr(0, 5) == "blob:") {
            d.reject("BLOB's not supported");
        } else if (url.substr(0, 5) == "data:") {
            var parts = url.substr(5).split(",", 2);
            parts[0] = parts[0].split(";");
            var data = parts[1], mime = parts[0][0], enc = parts[0][parts[0].length - 1];

            if (mime.indexOf("image/png") !== 0) {
                d.reject("not a PNG data");
            } else {
                var str = (enc == "base64") ? atob(data) : unescape(data);
                var bytes = new Uint8Array(str.length);
                for (var i = 0; i < str.length; i++) bytes[i] = str.charCodeAt(i);
                d.resolve(bytes);
            }
        } else {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', url, true);
            xhr.responseType = "arraybuffer";
            xhr.onload = function () {
                if (this.status == 200) {
                    d.resolve(new Uint8Array(this.response));
                } else {
                    d.reject(xhr.statusText);
                }
            };
            xhr.send();
        }
        return d.promise();
    };

    var checkUrl = function(url) {
        var d = D();
        chrome.extension.sendRequest(
                {"action":"checkUrl", "url":url},
                function (resp) {
                    if (resp == "yes") {
                        d.resolve(url);
                    } else if (resp == "no") {
                        d.reject(NOT_AN_APNG);
                    } else {
                        d.reject(UNKNOWN_URL);
                    }
                }
        );
        return d.promise();
    };

    var urlPromises = {};
    var allAnimations = [];
    var loadAndParseURL = function (url) {
        if (!(url in urlPromises)) {
            urlPromises[url] = D.pipeline(url)(
                    checkUrl,
                    loadBytes,
                    parseAPNG,
                    function (apng) {
                        return new Animation(apng);
                    },
                    function (a) {
                        allAnimations.push(a);
                        animationFound();
                        return a;
                    }
            );
        }
        return urlPromises[url];
    };

    var ctxNamePrefix = "apng-chrome-ext-css-", ctxNameCounter = 1;
    var Animation = function(apng) {
        this.isActive = false;
        this.nextRenderTime = 0;

        for (var k in apng) if (apng.hasOwnProperty(k)) this[k] = apng[k];

        var context = null;
        var contextName = null;
        this.getCanvasName = function() {
            if (!context) {
                contextName = ctxNamePrefix + (ctxNameCounter++);
                context = document.getCSSCanvasContext("2d", contextName, this.width, this.height);
                this.isActive = true;
            }
            return contextName;
        };

        var fNum = 0;
        var prevF = null;
        this.renderFrame = function(now) {
            if (!context) return;
            var f = fNum++ % this.frames.length;
            var frame = this.frames[f];

            if (f == 0) {
                context.clearRect(0, 0, this.width, this.height);
                prevF = null;
                if (frame.disposeOp == 2) frame.disposeOp = 1;
            }

            if (prevF && prevF.disposeOp == 1) {
                context.clearRect(prevF.left, prevF.top, prevF.width, prevF.height);
            } else if (prevF && prevF.disposeOp == 2) {
                context.putImageData(prevF.iData, prevF.left, prevF.top);
            }
            prevF = frame;
            prevF.iData = null;
            if (prevF.disposeOp == 2) {
                prevF.iData = context.getImageData(frame.left, frame.top, frame.width, frame.height);
            }
            if (frame.blendOp == 0) context.clearRect(frame.left, frame.top, frame.width, frame.height);
            context.drawImage(frame.img, frame.left, frame.top);

            if (this.numPlays == 0 || fNum / this.frames.length < this.numPlays) {
                if (this.nextRenderTime == 0) this.nextRenderTime = now;
                while (now > this.nextRenderTime + this.playTime) this.nextRenderTime += this.playTime;
                this.nextRenderTime += frame.delay;
            } else {
                this.isActive = false;
            }
        };
    };

    var onImageLoad = function () {
        var image = this, w = image.width, h = image.height;
        loadAndParseURL(image.src)
                .done(function (a) {
                    if (!image.hasAttribute("width") && (!image.style.width || image.style.width == "auto")) image.style.width = w + "px !important";
                    if (!image.hasAttribute("height") && (!image.style.height || image.style.height == "auto")) image.style.height = h + "px !important";
                    var ctxName = a.getCanvasName();
                    image.apngContextName = ctxName;
                    image.style.content = "-webkit-canvas(" + ctxName + ")";
                })
                .fail(function (err) {<commit_msg>Перекрытие стиля в ЖЖ: .b-singlepost-body IMG:not([width]):not([height]):not(.i-ljpoll-results-bar) {     width: auto !important;     height: auto !important;     max-width: 100%; }<commit_after>(function () {
    var global = (function() {
        return this;
    })(), D = Deferred;

    var isEnabled = false;

    var requestAnimationFrame = global.requestAnimationFrame || global.webkitRequestAnimationFrame;

    var UNKNOWN_URL = "*UNKNOWN*";
    var NOT_AN_APNG = "*NOT_AN_APNG*";

    var loadBytes = function (url) {
        var d = D();
        if (inStopList(url)) {
            d.reject("Url in stop list");
        } else if (url.substr(0, 5) == "blob:") {
            d.reject("BLOB's not supported");
        } else if (url.substr(0, 5) == "data:") {
            var parts = url.substr(5).split(",", 2);
            parts[0] = parts[0].split(";");
            var data = parts[1], mime = parts[0][0], enc = parts[0][parts[0].length - 1];

            if (mime.indexOf("image/png") !== 0) {
                d.reject("not a PNG data");
            } else {
                var str = (enc == "base64") ? atob(data) : unescape(data);
                var bytes = new Uint8Array(str.length);
                for (var i = 0; i < str.length; i++) bytes[i] = str.charCodeAt(i);
                d.resolve(bytes);
            }
        } else {
            var xhr = new XMLHttpRequest();
            xhr.open('GET', url, true);
            xhr.responseType = "arraybuffer";
            xhr.onload = function () {
                if (this.status == 200) {
                    d.resolve(new Uint8Array(this.response));
                } else {
                    d.reject(xhr.statusText);
                }
            };
            xhr.send();
        }
        return d.promise();
    };

    var checkUrl = function(url) {
        var d = D();
        chrome.extension.sendRequest(
                {"action":"checkUrl", "url":url},
                function (resp) {
                    if (resp == "yes") {
                        d.resolve(url);
                    } else if (resp == "no") {
                        d.reject(NOT_AN_APNG);
                    } else {
                        d.reject(UNKNOWN_URL);
                    }
                }
        );
        return d.promise();
    };

    var urlPromises = {};
    var allAnimations = [];
    var loadAndParseURL = function (url) {
        if (!(url in urlPromises)) {
            urlPromises[url] = D.pipeline(url)(
                    checkUrl,
                    loadBytes,
                    parseAPNG,
                    function (apng) {
                        return new Animation(apng);
                    },
                    function (a) {
                        allAnimations.push(a);
                        animationFound();
                        return a;
                    }
            );
        }
        return urlPromises[url];
    };

    var ctxNamePrefix = "apng-chrome-ext-css-", ctxNameCounter = 1;
    var Animation = function(apng) {
        this.isActive = false;
        this.nextRenderTime = 0;

        for (var k in apng) if (apng.hasOwnProperty(k)) this[k] = apng[k];

        var context = null;
        var contextName = null;
        this.getCanvasName = function() {
            if (!context) {
                contextName = ctxNamePrefix + (ctxNameCounter++);
                context = document.getCSSCanvasContext("2d", contextName, this.width, this.height);
                this.isActive = true;
            }
            return contextName;
        };

        var fNum = 0;
        var prevF = null;
        this.renderFrame = function(now) {
            if (!context) return;
            var f = fNum++ % this.frames.length;
            var frame = this.frames[f];

            if (f == 0) {
                context.clearRect(0, 0, this.width, this.height);
                prevF = null;
                if (frame.disposeOp == 2) frame.disposeOp = 1;
            }

            if (prevF && prevF.disposeOp == 1) {
                context.clearRect(prevF.left, prevF.top, prevF.width, prevF.height);
            } else if (prevF && prevF.disposeOp == 2) {
                context.putImageData(prevF.iData, prevF.left, prevF.top);
            }
            prevF = frame;
            prevF.iData = null;
            if (prevF.disposeOp == 2) {
                prevF.iData = context.getImageData(frame.left, frame.top, frame.width, frame.height);
            }
            if (frame.blendOp == 0) context.clearRect(frame.left, frame.top, frame.width, frame.height);
            context.drawImage(frame.img, frame.left, frame.top);

            if (this.numPlays == 0 || fNum / this.frames.length < this.numPlays) {
                if (this.nextRenderTime == 0) this.nextRenderTime = now;
                while (now > this.nextRenderTime + this.playTime) this.nextRenderTime += this.playTime;
                this.nextRenderTime += frame.delay;
            } else {
                this.isActive = false;
            }
        };
    };

    var onImageLoad = function () {
        var image = this, w = image.width, h = image.height;
        loadAndParseURL(image.src)
                .done(function (a) {
                    if (!image.hasAttribute("width") && (!image.style.width || image.style.width == "auto")) {
                        image.style.width = w + "px";
                        image.style.cssText = image.style.cssText.replace(/\bwidth:\s*\d+px/, "$& !important");
                    }
                    if (!image.hasAttribute("height") && (!image.style.height || image.style.height == "auto")) {
                        image.style.height = h + "px";
                        image.style.cssText = image.style.cssText.replace(/\bheight:\s*\d+px/, "$& !important");
                    }
                    var ctxName = a.getCanvasName();
                    image.apngContextName = ctxName;
                    image.style.content = "-webkit-canvas(" + ctxName + ")";
                })
                .fail(function (err) {
{'fraction_non_alphanumeric': 0.13398888413852073, 'fraction_numerical': 0.00675502351432236, 'mean_word_length': 1.3937781416291446, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 5, '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': '4953516', 'n_tokens_mistral': 3446, 'n_tokens_neox': 3247, 'n_words': 700}