/**
 * Searches the first loaded style sheet for an @keyframes animation by name.
 * FYI: If you use "to" or "from" they'll get converted to percentage values, so use them for manipulating rules.
 * Source (Optimized for flapper): http://jsfiddle.net/russelluresti/RHhBz/3/.
 **/
function findKeyframesRule(name) {
  for (var x = 0; x < document.styleSheets.length; x++) {
    var stylesheet = document.styleSheets[x];
    for (var i = 0; i < stylesheet.cssRules.length; i++) {
      var rule = stylesheet.cssRules[i];
      if (rule.name == name) {
        return rule;
      }
    }
  }
  return null;
}

/**
 * Searches the first loaded style sheet for a CSS rule by name.
 **/
 function findCSSRule(name) {
   for (var x = 0; x < document.styleSheets.length; x++) {
     var stylesheet = document.styleSheets[x];
     for (var i = 0; i < stylesheet.cssRules.length; i++) {
       var rule = stylesheet.cssRules[i];
       if (rule.selectorText == name) {
         return rule;
       }
     }
   }
   return null;
 }

/**
 * Searches the first loaded style sheet for an @keyframes animation by name.
 * FYI: If you use "to" or "from" they'll get converted to percentage values, so use them for manipulating rules.
 * Source (Optimized for flapper): http://jsfiddle.net/russelluresti/RHhBz/3/.
 **/
function findKeyframesRule(name) {
  var stylesheet = document.styleSheets[0];
  for (var i = 0; i < stylesheet.cssRules.length; i++) {
    var cssRule = stylesheet.cssRules[i];
    if (cssRule.name == name) return cssRule;
  }
  return null;
}

/**
 * Searches the first loaded style sheet for a CSS rule by name.
 **/
 function findCSSRule(name) {
   var stylesheet = document.styleSheets[0];
   console.log("Stylesheet: " + stylesheet);
   for (var i = 0; i < stylesheet.cssRules.length; i++) {
     var cssRule = stylesheet.cssRules[i];
     console.log(`cssRule(${i}): ${cssRule.selectorText}`)
     if (cssRule.selectorText == name) {
       console.log("Found it");
       return cssRule;
     }
   }
   return null;
 }

--- 
+++ 
@@ -4,10 +4,14 @@
  * Source (Optimized for flapper): http://jsfiddle.net/russelluresti/RHhBz/3/.
  **/
 function findKeyframesRule(name) {
-  var stylesheet = document.styleSheets[0];
-  for (var i = 0; i < stylesheet.cssRules.length; i++) {
-    var cssRule = stylesheet.cssRules[i];
-    if (cssRule.name == name) return cssRule;
+  for (var x = 0; x < document.styleSheets.length; x++) {
+    var stylesheet = document.styleSheets[x];
+    for (var i = 0; i < stylesheet.cssRules.length; i++) {
+      var rule = stylesheet.cssRules[i];
+      if (rule.name == name) {
+        return rule;
+      }
+    }
   }
   return null;
 }
@@ -16,14 +20,13 @@
  * Searches the first loaded style sheet for a CSS rule by name.
  **/
  function findCSSRule(name) {
-   var stylesheet = document.styleSheets[0];
-   console.log("Stylesheet: " + stylesheet);
-   for (var i = 0; i < stylesheet.cssRules.length; i++) {
-     var cssRule = stylesheet.cssRules[i];
-     console.log(`cssRule(${i}): ${cssRule.selectorText}`)
-     if (cssRule.selectorText == name) {
-       console.log("Found it");
-       return cssRule;
+   for (var x = 0; x < document.styleSheets.length; x++) {
+     var stylesheet = document.styleSheets[x];
+     for (var i = 0; i < stylesheet.cssRules.length; i++) {
+       var rule = stylesheet.cssRules[i];
+       if (rule.selectorText == name) {
+         return rule;
+       }
      }
    }
    return null;
Fix uBlock Origin breaking flapper by injecting CSS stylesheet
