I am trying to get all CSS rules by using JavaScript. On some page I sucess, on some I don't success.
For example, here in StackOverflow, I am using:
console.log(
document.styleSheets[1].href,'rules',
document.styleSheets[1].cssRules,'Should be css rules, and not null'
)
This is what I get:
http://cdn.sstatic.net/stackoverflow/all.css?v=f7d3e9ff74be rules null Should be css rules, and not null
For some other website it's works well, but sometimes not.
For example in github.com this is what I get:
https://assets-cdn.github.com/assets/github2/index-87247f16e6450ef54cb0eda3f8f1484e33a3f18c7a7d3df1f76f67cba36a8d6d.css CSSRuleList {0: CSSStyleRule, 1: CSSStyleRule, 2: CSSStyleRule, 3: CSSStyleRule, 4: CSSStyleRule, 5: CSSStyleRule, 6: CSSStyleRule, 7: CSSStyleRule, 8: CSSStyleRule, 9: CSSStyleRule, 10: CSSStyleRule, 11: CSSStyleRule, 12: CSSStyleRule, 13: CSSStyleRule, 14: CSSStyleRule, 15: CSSStyleRule, 16: CSSStyleRule, 17: CSSStyleRule, 18: CSSStyleRule, 19: CSSStyleRule, 20: CSSStyleRule, 21: CSSStyleRule, 22:
What Can I do?
- I thought maybe it is because content-type. but no. It is always text/css
- I thought maybe it because CORS issue, but I didn't see that this is the problem.