[Javascript]
/*
* Obtain the style value of the specified category selector.
* @ Method getClassStyle
* @ Param {String} name of the class selector
* @ Param {Document} the document specified by doc
* @ Return {String} cssText of the style
*/
GetClassStyle: function (name, doc ){
Var doc = doc | document,
Name2 = name. replace (/\./, '\.'). replace (/\ B/, '\ B') + '\ B ',
Reg = new RegExp (name2, 'I ');
Ret = '';
For (var I = 0; I <doc. styleSheets. length; I ++ ){
Var styleSheet = document. styleSheets [I],
Rules = styleSheet.css Rules? StyleSheet.css Rules: styleSheet. rules;
For (var j = 0; j <rules. length; j ++ ){
Var rule = rules [j],
Cls = rule. selectorText;
// Rule. selectorText may not exist
If (cls & reg. test (cls )){
Var newStr = /{.*?} /.Exec(rule.css Text) | '';
// Deduplication
If (-1 = ret. indexOf (newStr )){
Ret + = newStr;
}
}
}
}
// Filter out braces
Return ret. replace (/{|}/g ,'');
}