I am writing a Chrome Extensions for reddit.com and would like to read the contents of a CSS file that website has already loaded.
In my research I've come across two methods:
- document.styleSheets
When I console.log( document.styleSheets ) however, the "cssRules" and "rules" are both "null" for some reason, however if I load the css file url in the browser, there are plenty of rules:
https://b.thumbs.redditmedia.com/qFTJmHhu1fP0DVZHvATz60WXl-MhvSmCFoByN26OkoU.css
As you can see though, the css is hosted at redditmedia.com, so is this a cross-domain issue?
- $.get
When I try to do an ajax call to read the contents of the file, it's giving me a "No 'Access-Control-Allow-Origin' header is present" message, which makes sense. It's hosted at a different domain.
Is there any way I can get the contents of this file?
Thanks for your help!