Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added css class detector

  • Loading branch information...
commit 877a0d0da8f051ea11527069bab43f0ba536bc42 1 parent 69a0154
@fluescher fluescher authored
Showing with 40 additions and 2 deletions.
  1. +40 −2 detector.js
View
42 detector.js
@@ -162,8 +162,7 @@
'Prostores' : /-legacycss\/Asset">/,
'osCommerce': /(product_info\.php\?products_id|_eof \/\/-->)/,
'OpenCart': /index.php\?route=product\/product/,
- 'Shibboleth': /<form action="\/idp\/Authn\/UserPassword" method="post">/,
- 'Bootstrap': /<link.*href=\".*bootstrap.*\.css\" rel=\"stylesheet\"/
+ 'Shibboleth': /<form action="\/idp\/Authn\/UserPassword" method="post">/
};
for (t in text_tests)
@@ -378,6 +377,45 @@
// 8: detect based on built-in database
// @todo
+ // 9: detect based on defined css classes
+ var cssClasses = {
+ 'Bootstrap': ['hero-unit', '.carousel-control', '[class^="icon-"]:last-child']
+ };
+
+ for (t in cssClasses) {
+ if (t in _apps) continue;
+
+ var found = true;
+ for(css in cssClasses[t]) {
+ var act = false;
+ var name = cssClasses[t][css];
+
+ /* Iterate through all registered css classes and check for presence */
+ for(cssFile in document.styleSheets) {
+ for(cssRule in document.styleSheets[cssFile].cssRules) {
+ var style = document.styleSheets[cssFile].cssRules[cssRule];
+
+ if (typeof style === "undefined") continue;
+ if (typeof style.selectorText === "undefined") continue;
+
+ if (style.selectorText.indexOf(name) != -1) {
+ act = true;
+ break;
+ }
+ }
+ if (act === true) break;
+ }
+
+ found = found & act;
+ }
+
+ if(found == true) {
+ _apps[t] = -1;
+ } else {
+ break;
+ }
+ }
+
// convert to array
var jsonString = JSON.stringify(_apps);
// send back to background page
Please sign in to comment.
Something went wrong with that request. Please try again.