Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The extension says there are no MQs on a site that have some #2

Open
nhoizey opened this Issue Dec 21, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@nhoizey
Copy link

nhoizey commented Dec 21, 2017

I tried the extension on https://play.esviji.com/ and it says there is no MQs.

There are quite a lot of MQs, actually…

@eviltester

This comment has been minimized.

Copy link

eviltester commented Mar 13, 2019

The getMedia function in content.js throws an exception which prevents the media queries from populating in the popup.

If the contents of the getMedia method are wrapped in a try/catch then the media queries are displayed and the basic functionality of the extension works again, i.e. you can see the queries and use the resize functionality.

function getMedia(callback) {

            var media = [];
            for (var i in document.styleSheets) {
                var sheet = document.styleSheets[i];

                try {
                    // Checking first if media is set on style sheet level
                    // and has width settings
                    if (sheet.media && sheet.media.mediaText.indexOf('width') >= 0) {
                        media.push({
                            media: sheet.media,
                            url: sheet.href
                        });
                    }
                    // Case when css in different domain
                    if (!sheet.cssRules && sheet.href) {
                        media.push({
                            url: sheet.href
                        });
                    }
                    // Filtering media from available cssRules
                    for (var j in sheet.cssRules) {
                        var rule = sheet.cssRules[j];
                        // Adding media rule that has width settings
                        if (rule.media && rule.media.mediaText.indexOf('width') >= 0) {
                            media.push({
                                media: rule.media,
                                url: sheet.href
                            });
                        }
                    }
                } catch (e) {
                    // https://stackoverflow.com/questions/49161159/uncaught-domexception-failed-to-read-the-rules-property-from-cssstylesheet
                    console.warn("Can't read the css rules of: " + document.styleSheets[i].href, e);
                    continue;
                }

            }
            callback(media);
        }

This doesn't fix screenshots, but it does make the extension usable again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.