domains/remove_print_css.js
[app.webkitpdf] / domains / remove_print_css.js
index 81d3261..b2e7d65 100644 (file)
         }
         
         // now we are dealing with non-print styles...
-        
-        var ar = document.styleSheets[ss].rules;
+        try {
+            var ar = document.styleSheets[ss].rules;
+        } catch(e) {
+            console.log("could not access stylesheet:" + ss);
+            continue;
+        }
         if (!ar) {
             del.push(node);
             continue;
             }
             
             // see if getting rid of 'only' from screen works.
-            if(!ar[i].cssText.match(/only\s+screen/)) {
-                newsheet += ar[i].cssText +"\n";
+            if(ar[i].cssText.match(/only\s+screen/)) {
+                var str = ar[i].cssText.replace(/only\s+screen/, '');
+                newsheet += str +"\n";
                 continue;   
             }
-            var str = ar[i].cssText.replace(/only\s+screen/, 'screen');
-            newsheet += str +"\n";
+            if(ar[i].cssText.match(/screen\s+and/)) {
+                var str = ar[i].cssText.replace(/screen\s+and/, '');
+                newsheet += str +"\n";
+                continue;   
+            }
+            newsheet += ar[i].cssText +"\n";
+                
+            
             
             
         }
@@ -62,7 +73,7 @@
         
     
     }
-    for(i = 0; i < del.length) {
+    for(i = 0; i < del.length;i++) {
         del[i].parentNode.removeChild(del[i]);
     }