Mimi
Mimi

Reputation: 1

Javascript issue in firefox

I'm working with a site that stopped working in Firefox randomly. This piece of code is populating into the html each time I try to update, and I'm trying to understand it. I haven't made any changes to the javascript used in the site but whatever this is has completely disabled all the site elements that use javascript. The kicker is that it only happens in Firefox. Chrome works perfectly. I've been poring over the html all day and this is the only thing that's weird- I'm at my wit's end, any ideas? I don't know a great deal about Javascript and I haven't touched anything in the scripts for the site, so I don't understand why they suddenly stopped functioning.

<script type="text/javascript" id="RTCEarlyScript">

window.oldSetTimeout = window.setTimeout;
window.setTimeout = function (func, delay) {
  return window.oldSetTimeout(function () {
    try {
      if (!document.documentElement.getAttribute('stopTimers ')) {
        if (typeof func == 'string') {
          var nfunc = new Function(func);
          nfunc();
        } else func();
      }
    } catch (ex) {
    }
  }, delay);
};
window.oldSetInterval = window.setInterval;
window.setInterval = function (func, delay) {
  return window.oldSetInterval(function () {
    try {
      if (!document.documentElement.getAttribute('stopTimer s')) {
        if (typeof func == 'string') {
          var nfunc = new Function(func);
          nfunc();
        } else func();
      }
    } catch (ex) {
    }
  }, delay);
};
</script>

Upvotes: 0

Views: 172

Answers (2)

David P. Caldwell
David P. Caldwell

Reputation: 3839

Don't know if this helps, but I understand the intent of the code.

setTimeout and setInterval are JavaScript functions that allow a programmer to "schedule" an event to happen at a given time. So you can execute some code a second from now, or five seconds from now.

The developer here is attempting to replace those functions with semantic equivalents that first check to see if someone has set a "stopTimers" attribute on the top-level element in the document (the <html> element). If that attribute is set, then the code that was scheduled to run does not run.

Upvotes: 1

Adria
Adria

Reputation: 9061

The RightToClick extension is injecting that script, and obviously not cleaning up after itself.
Disable or remove it.

Upvotes: 1

Related Questions