PageSourceSearch

https://www.madeinbebe.com/includes/js/css_browser_selector.js?v=1790718586

js madeinbebe.com collected 2026-09-29 21:50:04 UTC 10,673 bytes, 297 lines download raw bytes

1/*
2 CSS Browser Selector 0.81
3 Originally written by Rafael Lima (http://rafael.adm.br)
4 http://rafael.adm.br/css_browser_selector
5 License: http://creativecommons.org/licenses/by/2.5/
6
7 Co-maintained by:
8 https://github.com/ridjohansen/css_browser_selector
9 https://github.com/delka/css_browser_selector
10 https://github.com/verbatim/css_browser_selector
11 */
12 (function() {
13  var uaInfo = {
14    ua : '',
15    is : function (t) {
16      return RegExp(t, "i").test(uaInfo.ua);
17    },
18    version : function (p, n) {
19      n = n.replace(".", "_");
20      var i = n.indexOf('_'),
21        ver = "";
22      while (i > 0) {
23        ver += " " + p + n.substring(0, i);
24        i = n.indexOf('_', i + 1);
25      }
26      ver += " " + p + n;
27      return ver;
28    },
29    getBrowser : function() {
30      var g = 'gecko',
31        w = 'webkit',
32        c = 'chrome',
33        f = 'firefox',
34        s = 'safari',
35        o = 'opera',
36  
37        ua = uaInfo.ua,
38        is = uaInfo.is;
39  
40      return [
41        (!(/opera|webtv/i.test(ua)) && /msie\s(\d+)/.test(ua)) ? ('ie ie' + (/trident\/4\.0/.test(ua) ? '8' : RegExp.$1))
42          :is('edge\/') ? 'edge ie' + (/edge\/(\d+)\.(\d+)/.test(ua) ? RegExp.$1 + ' ie' + RegExp.$1 + '_' + RegExp.$2 : '') // IE Edge
43          :is('trident\/') ? 'ie ie'+ (/trident\/.+rv:(\d+)/i.test(ua) ? RegExp.$1 : '') //ie11+
44          :is('firefox/') ? g + " " + f + (/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + f + RegExp.$2 + ' ' + f + RegExp.$2 + "_" + RegExp.$4 : '')
45          :is('gecko/') ? g
46          :is('opera') ? o + (/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + o + RegExp.$2 + ' ' + o + RegExp.$2 + "_" + RegExp.$4 : (/opera(\s|\/)(\d+)\.(\d+)/.test(ua) ? ' ' + o + RegExp.$2 + " " + o + RegExp.$2 + "_" + RegExp.$3 : ''))
47          :is('konqueror') ? 'konqueror'
48          :is('chrome') ? w + ' ' + c + (/chrome\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + c + RegExp.$2 + ((RegExp.$4 > 0) ? ' ' + c + RegExp.$2 + "_" + RegExp.$4 : '') : '')
49          :is('iron') ? w + ' iron'
50          :is('applewebkit/') ? (w + ' ' + s + (/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua) ? ' ' + s + RegExp.$2 + " " + s + RegExp.$2 + RegExp.$3.replace('.', '_') : (/ Safari\/(\d+)/i.test(ua) ? ((RegExp.$1 == "419" || RegExp.$1 == "417" || RegExp.$1 == "416" || RegExp.$1 == "412") ? ' ' + s + '2_0' : RegExp.$1 == "312" ? ' ' + s + '1_3' : RegExp.$1 == "125" ? ' ' + s + '1_2' : RegExp.$1 == "85" ? ' ' + s + '1_0' : '') : ''))) //applewebkit
51          :is('mozilla/') ? g : ''
52      ];
53    },
54    getPlatform : function() {
55      var wp = 'winphone',
56        a  = 'android',
57        bb = 'blackberry',
58        dv = 'device_',
59  
60        ua = uaInfo.ua,
61        version = uaInfo.version,
62        is = uaInfo.is;
63  
64      return [
65        is('j2me') ? 'j2me'
66        :is('windows phone') ? (wp + (/Windows Phone (\d+)(\.(\d+))+/i.test(ua) ? " " + wp + RegExp.$1 + " " + wp + RegExp.$1 + RegExp.$2.replace('.', '_') : (/Windows Phone OS (\d+)(\.(\d+))+/i.test(ua) ? " " + wp + RegExp.$1 + " " + wp + RegExp.$1 + RegExp.$2.replace('.', '_') : ''))) // Windows Phone
67        :is('blackberry') ? (bb + (/Version\/(\d+)(\.(\d+)+)/i.test(ua) ? " " + bb + RegExp.$1 + " " + bb + RegExp.$1 + RegExp.$2.replace('.', '_') : (/Blackberry ?(([0-9]+)([a-z]?))[\/|;]/gi.test(ua) ? ' ' + bb + RegExp.$2 + (RegExp.$3 ? ' ' + bb + RegExp.$2 + RegExp.$3 : '') : ''))) // blackberry
68        :is('android') ? (a + (/Version\/(\d+)(\.(\d+))+/i.test(ua) ? " " + a + RegExp.$1 + " " + a + RegExp.$1 + RegExp.$2.replace('.', '_') : '') + (/Android (.+); (.+) Build/i.test(ua) ? ' ' + dv + ((RegExp.$2).replace(/ /g, "_")).replace(/-/g, "_") : '')) //android
69        :is('ipad|ipod|iphone') ? (
70        (/CPU( iPhone)? OS (\d+[_|\.]\d+([_|\.]\d+)*)/i.test(ua) ? 'ios' + version('ios', RegExp.$2) : '') + ' ' + (/(ip(ad|od|hone))/gi.test(ua) ? RegExp.$1 : "")) //'iphone'
71        //:is('ipod')?'ipod'
72        //:is('ipad')?'ipad'
73        :is('playbook') ? 'playbook'
74        :is('kindle|silk') ? 'kindle'
75        :is('playbook') ? 'playbook'
76        :is('mac') ? 'mac' + (/mac os x ((\d+)[.|_](\d+))/.test(ua) ? (' mac' 
76+ (RegExp.$2) + ' mac' + (RegExp.$1).replace('.', "_")) : '')
77        :is('win') ? 'win' + (is('windows nt 10.0') ? ' win10'
78        :is('windows nt 6.3') ? ' win8_1'
79        :is('windows nt 6.2') ? ' win8'
80        :is('windows nt 6.1') ? ' win7'
81        :is('windows nt 6.0') ? ' vista'
82        :is('windows nt 5.2') || is('windows nt 5.1') ? ' win_xp'
83        :is('windows nt 5.0') ? ' win_2k'
84        :is('windows nt 4.0') || is('WinNT4.0') ? ' win_nt' : '')
85        :is('freebsd') ? 'freebsd'
86        :is('x11|linux') ? 'linux' : ''
87      ];
88    },
89    getMobile : function() {
90      var is = uaInfo.is;
91      return [
92        is("android|mobi|mobile|j2me|iphone|ipod|ipad|blackberry|winphone|playbook|kindle|silk") ? 'mobile' : ''
93      ];
94    },
95    getIpadApp : function() {
96      var is = uaInfo.is;
97      return [
98        (is('ipad|iphone|ipod') && !is('safari')) ? 'ipad_app' : ''
99      ];
100    },
101    getLang : function() {
102      var ua = uaInfo.ua;
103  
104      return [
105        /[; |\[](([a-z]{2})(\-[a-z]{2})?)[)|;|\]]/i.test(ua) ? ('lang_' + RegExp.$2).replace("-", "_") + (RegExp.$3 != '' ? (' ' + 'lang_' + RegExp.$1).replace("-", "_") : '') : ''
106      ];
107    }
108  }
109  
110  if (typeof html =='undefined') { 
111    html=document.documentElement;
112  }
113  
114  var screenInfo = {
115    width : (window.outerWidth || html.clientWidth) - 15,
116    height : window.outerHeight || html.clientHeight,
117    screens : [0, 768, 980, 1200],
118    
119    screenSize : function () {
120      screenInfo.width = (window.outerWidth || html.clientWidth) - 15;
121      screenInfo.height = window.outerHeight || html.clientHeight;
122        
123      var screens = screenInfo.screens,
124        i = screens.length,
125        arr = [],
126        maxw, 
127        minw;
128      
129      while(i--) {
130        if (screenInfo.width >= screens[i]) {
131          if(i) {
132            arr.push("minw_" + screens[(i)]);
133          }
134          if (i <= 2) {
135            arr.push("maxw_" + (screens[(i) + 1] - 1));
136          }
137          break;
138        }
139      }
140      return arr;
141    },
142    getOrientation : function() {
143      return screenInfo.width < screenInfo.height ? ["orientation_portrait"] : ["orientation_landscape"];
144    },
145    getInfo : function() {
146      var arr = [];
147      arr = arr.concat(screenInfo.screenSize());
148      arr = arr.concat(screenInfo.getOrientation());
149      return  arr;
150    },
151    getPixelRatio : function() {
152      var arr = [],
153        pixelRatio = window.devicePixelRatio ? window.devicePixelRatio : 1;
154  
155      if(pixelRatio > 1) {
156        arr.push('retina_' + parseInt(pixelRatio) + 'x');
157        arr.push('hidpi');
158      } else {
159        arr.push('no-hidpi');
160      }
161      return arr;
162    }
163  }
164  
165  var dataUriInfo = {
166    data : new Image(),
167    div : document.createElement("div"),
168    isIeLessThan9 : false,
169    getImg : function() {
170  
171      dataUriInfo.data.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";
172      dataUriInfo.div.innerHTML = "<!--[if lt IE 9]><i></i><![endif]-->";
173      dataUriInfo.isIeLessThan9 = dataUriInfo.div.getElementsByTagName("i").length == 1;
174  
175      return dataUriInfo.data;
176    },
177    checkSupport : function() {
178      if(dataUriInfo.data.width != 1 || dataUriInfo.data.height != 1 || dataUriInfo.isIeLessThan9) {
179        return ["no-datauri"];
180      }
181      else {
182        return ["datauri"];
183      }
184    }
185  
186  }
187  
188  function css_browser_selector(u, ns) {
189    var html = document.documentElement,
190      b = []
191      ns = ns ? ns : "";
192  
193    /* ua */
194    uaInfo.ua = u.toLowerCase();
195    b = b.concat(uaInfo.getBrowser());
196    b = b.concat(uaInfo.getPlatform());
197    b = b.concat(uaInfo.getMobile());
198    b = b.concat(uaInfo.getIpadApp());
199    b = b.concat(uaInfo.getLang());
200  
201  
202    /* js */
203    b = b.concat(['js']);
204  
205    /* pixel ratio */
206    b = b.concat(screenInfo.getPixelRatio());
207  
208    /* screen */
209    b = b.concat(screenInfo.getInfo());
210  
211    var updateScreen = function() {
212      html.className = html.className.replace(/ ?orientation_\w+/g, "").replace(/ [min|max|cl]+[w|h]_\d+/g, "");
213      html.className = html.className + ' ' + screenInfo.getInfo().join(' ');
214    }
215  
216    if (window.addEventListener) {
217      window.addEventListener('resize', updateScreen);
218      window.addEventListener('orientationchange', updateScreen);
219    } else if (window.attachEvent) {
220      window.attachEvent('onresize', updateScreen);
221    }
222  
223    /* dataURI */
224    var data = dataUriInfo.getImg();
225    data.onload = data.onerror = function(){
226      html.className += ' ' + dataUriInfo.checkSupport().join(' ');
227    }
228  
229  
230    /* save & add existing html classes */
231    var classes = html.className;
232    var classesArray = classes.split(/ /);
233  
234    /* merge existing classes on html tag */
235    b = b.concat(classesArray);
236  
237    /* removendo itens invalidos do array */
238    /* add filter function polyfill for IE8 */
239    if (!Array.prototype.filter) {
240      Array.prototype.filter = function(fun/*, thisArg*/) {
241        'use strict';
242  
243        if (this === void 0 || this === null) {
244          throw new TypeError();
245        }
246  
247        var t = Object(this);
248        var len = t.length >>> 0;
249        if (typeof fun !== 'function') {
250          throw new TypeError();
251        }
252  
253        var res = [];
254        var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
255        for (var i = 0; i < len; i++) {
256          if (i in t) {
257            var val = t[i];
258  
259            // NOTE: Technically this should Object.defineProperty at
260            //			 the next index, as push can be affected by
261            //			 properties on Object.prototype and Array.prototype.
262            //			 But that method's new, and collisions should be
263            //			 rare, so use the more-compatible alternative.
264            if (fun.call(thisArg, val, i, t)) {
265              res.push(val);
266            }
267          }
268        }
269  
270        return res;
271      };
272    }
273  
274    b = b.filter(function(e){
275      /* if no-js class exists, remove it */
276      if (e === 'no-js') {
277        return false;
278          }
279      return e;
280    });
281  
282    /* prefixo do namespace */
283    b[0] = ns ? ns + b[0] : b[0];
284    html.className = b.join(' ' + ns);
285    return html.className;
286  }
287  
288  // Add css_browser_selector as a global object.
289  window.css_browser_selector = css_browser_selector;
290  })();
291  
292  // define css_browser_selector_ns before loading this script to assign a namespace
293  var css_browser_selector_ns = css_browser_selector_ns || "";
294  
295  // init
296  css_browser_selector(navigator.userAgent, css_browser_selector_ns);
297  

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.