//Get all styles where the provided class is involved //Input parameters should be css selector such as .myClass or #m //returned as an array of tuples {selectorText:"", styleDefinition:""} function getStyleWithCSSSelector(cssSelector) { var styleSheets = window.document.styleSheets; var styleSheetsLength = styleSheets.length; var arStylesWithCSSSelector = []; //in order to not find class which has the current name as prefix var arValidCharsAfterCssSelector = [" ", ".", ",", "#",">","+",":","["]; //loop through all the stylessheets in the bor for(var i = 0; i < styleSheetsLength; i++){ var classes = styleSheets[i].rules || styleSheets[i].cssRules; var classesLength = classes.length; for (var x = 0; x < classesLength; x++) { //check for any reference to the class in the selector string if(typeof classes[x].selectorText != "undefined"){ var matchClass = false; if(classes[x].selectorText === cssSelector){//exact match matchClass=true; }else {//check for it as part of the selector string //TODO: Optimize with regexp for (var j=0;j0){ arStackElements= arStackElements.concat(currentElement.children().toArray()); } } console.log("Found " + Object.keys(existingClassDefinitions).length + " CSS class definitions"); return cssString; }