<commit_before>
  if (global.opera) {
    isReady = true;

    // Make scripts also work in Opera <= version 12
    opera.isReady = function(fn) {
      fn.call(opera);

      // Run delayed events (if any)
      for(var i = 0, l = _delayedExecuteEvents.length; i < l; i++) {
        var o = _delayedExecuteEvents[i];
        o.target[o.methodName].apply(o.target, o.args);
      }
      _delayedExecuteEvents = [];
    };

  } else {

    opera.isReady = (function() {

      var fns = {
            "isready": [],
            "domcontentloaded": [],
            "load": []
          };

      var hasFired_DOMContentLoaded = false,
          hasFired_Load = false;

      global.document.addEventListener("DOMContentLoaded", function handle_DomContentLoaded() {
        hasFired_DOMContentLoaded = true;
        global.document.removeEventListener("DOMContentLoaded", handle_DomContentLoaded, true);
      }, true);

      global.addEventListener("load", function handle_Load() {
        hasFired_Load = true;
        global.removeEventListener("load", handle_Load, true);
      }, true);

      function interceptAddEventListener(target, _name) {

        var _target = target.addEventListener;

        // Replace addEventListener for given target
        target.addEventListener = function(name, fn, usecapture) {
          if (name.toLowerCase() === _name.toLowerCase()) {
            if (fn === undefined || fn === null ||
                  Object.prototype.toString.call(fn) !== "[object Function]") {
              return;
            }

            if (isReady) {
              fn.call(global);
            } else {
              fns[_name.toLowerCase()].push(fn);
            }
          } else {
            // call standard addEventListener method on target
            _target.call(target, name, fn, usecapture);
          }
        };

        // Replace target.on[_name] with custom setter function
        target.__defineSetter__("on" + _name.toLowerCase(), function( fn ) {
          // call code block just created above...
          target.addEventListener(_name.toLowerCase(), fn, false);
        });

      }

      interceptAddEventListener(global, 'load');
      interceptAddEventListener(global.document, 'domcontentloaded');
      interceptAddEventListener(global, 'domcontentloaded'); // handled bubbled DOMContentLoaded

      function fireEvent(name, target) {
        var evtName = name.toLowerCase();

        var evt = new OEvent(evtName, {});

        for (var i = 0, len = fns[evtName].length; i < len; i++) {
          fns[evtName][i].call(target, evt);
        }
        fns[evtName] = [];
      }

      function ready() {
        global.setTimeout(function() {

          if (isReady) {
            return;
          }

          // Handle queued opera 'isReady' event functions
          for (var i = 0, len = fns['isready'].length; i < len; i++) {
            fns['isready'][i].call(global);
          }
          fns['isready'] = []; // clear

          var domContentLoadedTimeoutOverride = new Date().getTime() + 3000;

          // Synthesize and fire the document domcontentloaded event
          (function fireDOMContentLoaded() {

            var currentTime = new Date().getTime();

            // Check for hadFired_Load in case we missed DOMContentLoaded
            // event, in which case, we syntesize DOMContentLoaded here
            // (always synthesized in Chromium Content Scripts)
            if (hasFired_DOMContentLoaded || hasFired_Load || currentTime >= domContentLoadedTimeoutOverride) {

              fireEvent('domcontentloaded', global.document);

              if(currentTime >= domContentLoadedTimeoutOverride) {
                console.warn('document.domcontentloaded event fired on check timeout');
              }

              var loadTimeoutOverride = new Date().getTime() + 3000;

              // Synthesize and fire the window load event
              // after the domcontentloaded event has been
              // fired
              (function fireLoad() {

                var currentTime = new Date().getTime();

                if (hasFired_Load || currentTime >= loadTimeoutOverride) {

                  fireEvent('load', window);

                  if(currentTime >= loadTimeoutOverride) {
                    console.warn('window.load event fired on check timeout');
                  }

                  // Run delayed events (if any)
                  for(var i = 0, l = _delayedExecuteEvents.length; i < l; i++) {
                    var o = _delayedExecuteEvents[i];
                    o.target[o.methodName].apply(o.target, o.args);
                  }
                  _delayedExecuteEvents = [];

                } else {
                  global.setTimeout(function() {
                    fireLoad();
                  }, 50);
                }

              })();

            } else {<commit_msg>Add document.onreadystatechange load support<commit_after>
  if (global.opera) {
    isReady = true;

    // Make scripts also work in Opera <= version 12
    opera.isReady = function(fn) {
      fn.call(opera);

      // Run delayed events (if any)
      for(var i = 0, l = _delayedExecuteEvents.length; i < l; i++) {
        var o = _delayedExecuteEvents[i];
        o.target[o.methodName].apply(o.target, o.args);
      }
      _delayedExecuteEvents = [];
    };

  } else {

    opera.isReady = (function() {

      var fns = {
            "isready": [],
            "readystatechange": [],
            "domcontentloaded": [],
            "load": []
          };

      var hasFired_DOMContentLoaded = false,
          hasFired_Load = false;

      global.document.addEventListener("DOMContentLoaded", function handle_DomContentLoaded() {
        hasFired_DOMContentLoaded = true;
        global.document.removeEventListener("DOMContentLoaded", handle_DomContentLoaded, true);
      }, true);

      global.addEventListener("load", function handle_Load() {
        hasFired_Load = true;
        global.removeEventListener("load", handle_Load, true);
      }, true);
      
      global.document.addEventListener("readystatechange", function(event) {
        event.stopImmediatePropagation();
        event.stopPropagation();
        if( global.document.readyState !== 'interactive' && global.document.readyState !== 'complete' ) {
          fireEvent('readystatechange', global.document);
        } else {
          global.document.readyState = 'loading';
        }
      }, true);
      
      var _readyState = "uninitialized";
      global.document.__defineSetter__('readyState', function(val) { _readyState = val; });
      global.document.__defineGetter__('readyState', function() { return _readyState; });

      function interceptAddEventListener(target, _name) {

        var _target = target.addEventListener;

        // Replace addEventListener for given target
        target.addEventListener = function(name, fn, usecapture) {
          if (name.toLowerCase() === _name.toLowerCase()) {
            if (fn === undefined || fn === null ||
                  Object.prototype.toString.call(fn) !== "[object Function]") {
              return;
            }

            if (isReady) {
              fn.call(global);
            } else {
              fns[_name.toLowerCase()].push(fn);
            }
          } else {
            // call standard addEventListener method on target
            _target.call(target, name, fn, usecapture);
          }
        };

        // Replace target.on[_name] with custom setter function
        target.__defineSetter__("on" + _name.toLowerCase(), function( fn ) {
          // call code block just created above...
          target.addEventListener(_name.toLowerCase(), fn, false);
        });

      }

      interceptAddEventListener(global, 'load');
      interceptAddEventListener(global.document, 'domcontentloaded');
      interceptAddEventListener(global, 'domcontentloaded'); // handled bubbled DOMContentLoaded
      interceptAddEventListener(global.document, 'readystatechange');

      function fireEvent(name, target) {
        var evtName = name.toLowerCase();

        var evt = new OEvent(evtName, {});

        for (var i = 0, len = fns[evtName].length; i < len; i++) {
          fns[evtName][i].call(target, evt);
        }
      }

      function ready() {
        global.setTimeout(function() {

          if (isReady) {
            return;
          }

          // Handle queued opera 'isReady' event functions
          for (var i = 0, len = fns['isready'].length; i < len; i++) {
            fns['isready'][i].call(global);
          }
          fns['isready'] = []; // clear

          var domContentLoadedTimeoutOverride = new Date().getTime() + 3000;

          // Synthesize and fire the document domcontentloaded event
          (function fireDOMContentLoaded() {

            var currentTime = new Date().getTime();

            // Check for hadFired_Load in case we missed DOMContentLoaded
            // event, in which case, we syntesize DOMContentLoaded here
            // (always synthesized in Chromium Content Scripts)
            if (hasFired_DOMContentLoaded || hasFired_Load || currentTime >= domContentLoadedTimeoutOverride) {

              global.document.readyState = 'interactive';
              fireEvent('readystatechange', global.document);

              fireEvent('domcontentloaded', global.document);

              if(currentTime >= domContentLoadedTimeoutOverride) {
                console.warn('document.domcontentloaded event fired on check timeout');
              }

              var loadTimeoutOverride = new Date().getTime() + 3000;

              // Synthesize and fire the window load event
              // after the domcontentloaded event has been
              // fired
              (function fireLoad() {

                var currentTime = new Date().getTime();

                if (hasFired_Load || currentTime >= loadTimeoutOverride) {
                  
                  global.document.readyState = 'complete';
                  fireEvent('readystatechange', global.document);

                  fireEvent('load', window);

                  if(currentTime >= loadTimeoutOverride) {
                    console.warn('window.load event fired on check timeout');
                  }

                  // Run delayed events (if any)
                  for(var i = 0, l = _delayedExecuteEvents.length; i < l; i++) {
                    var o = _delayedExecuteEvents[i];
                    o.target[o.methodName].apply(o.target, o.args);
                  }
                  _delayedExecuteEvents = [];

                } else {
                  global.setTimeout(function() {
                    fireLoad();
                  }, 50);
                }

              })();

            } else {
{'fraction_non_alphanumeric': 0.11343255985948045, 'fraction_numerical': 0.002958306369603402, 'mean_word_length': 1.8656953642384106, 'pattern_counts': {'":': 7, '<': 13, '<?xml version=': 0, '>': 11, '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': '4574005', 'n_tokens_mistral': 2839, 'n_tokens_neox': 2719, 'n_words': 641}