PageSourceSearch

https://ufc.cn/js/base/base.js

js ufc.cn collected 2026-10-04 07:38:32 UTC 7,800 bytes, 148 lines download raw bytes

1//平台检测,判断浏览器、操作系统环境
2var os = detectOS();
3function detectOS() {
4    var userAgent = navigator.userAgent;
5    var os = {};
6    os.userAgent = userAgent;
7    os.android = userAgent.match(/(Android)\s+([\d.]+)/) || userAgent.match(/Silk-Accelerated/) ? true : false;
8    os.ipad = userAgent.match(/(iPad).*OS\s([\d_]+)/) ? true : false;
9    os.iphone = !os.ipad && userAgent.match(/(iPhone\sOS)\s([\d_]+)/) ? true : false;
10    os.ios = os.ipad || os.iphone;
11    os.wp = userAgent.match(/Windows Phone/) || userAgent.match(/IEMobile/) ? true : false;
12    os.supportsTouch = ((window.DocumentTouch && document instanceof window.DocumentTouch) || 'ontouchstart' in window);
13    //	if(os.ios) os.iosVer = parseInt(userAgent.match(/OS\s\d+_/)[0].match(/\d+_/)[0]);
14    os.weixin = userAgent.match(/MicroMessenger/) ? true : false;
15    if (os.weixin) {
16        var ver = userAgent.match(/MicroMessenger\/\d+.\d+.\d+/)[0].match(/\d+.\d+.\d+/)[0].split('.');
17        os.weixinVer = 0;
18        for (var i = 0; i < ver.length; i++) os.weixinVer += parseInt(ver[i]) * Math.pow(10, ver.length - i - 1);
19    } //edn if
20    os.wxApp = window.__wxjs_environment == 'miniprogram' || userAgent.match(/miniprogram/) || userAgent.match(/miniProgram/) ? true : false;
21    os.weibo = userAgent.match(/Weibo/) || userAgent.match(/weibo/) ? true : false;
22    os.ali = userAgent.match(/AliApp/) ? true : false;
23    os.alipay = os.ali && userAgent.match(/Alipay/) ? true : false;
24    os.taobao = os.ali && userAgent.match(/WindVane/) ? true : false;
25    os.tianmao = os.ali && userAgent.match(/Tmall/) ? true : false;
26    os.netease = userAgent.match(/NewsApp/) ? true : false;
27    os.facebook = userAgent.match(/(FB)/) ? true : false;
28    os.baidu = userAgent.match(/Baidu/) ? true : false;
29    os.safari = os.ios && userAgent.match(/Safari/) ? true : false;
30    os.chrome = userAgent.match(/Chrome/) ? true : false;
31    os.firefox = userAgent.match(/Firefox/) ? true : false;
32    os.ie = document.documentMode;
33    os.edge = userAgent.match(/Edge/) ? true : false;
34    os.pc = !(os.android || os.ios || os.wp);
35    os.oppo = false;
36    os.oppoBrowser = false;
37    os.oppoApp = false;
38    os.oppoR15 = false;
39    if (os.ios) {
40        os.iphoneX = (screen.width == 375 && screen.height == 812) || (screen.width == 375 && window.innerHeight >= 635) || (window.innerWidth == 724 && window.innerHeight == 375) || (window.innerWidth == 375 && window.innerHeight == 724) || (window.innerWidth == 812 && window.innerHeight == 343) || (window.innerWidth == 343 && window.innerHeight == 812) || (screen.width == 414 && screen.height == 896) || (screen.width == 414 && window.innerHeight >= 719);
41        os.iphoneXFull = os.iphoneX && window.innerHeight > 667;
42        os.iphone6Plus = (screen.width == 414 && screen.height == 736) || (screen.width == 414 && window.innerHeight >= 622);
43        os.iphone6 = (screen.width == 375 && screen.height == 667) || (screen.width == 375 && window.innerHeight <= 603);
44        os.iphone5 = (screen.width == 320 && screen.height == 568) || (screen.width == 320 && window.innerHeight >= 460);
45        os.iphone4 = (screen.width == 320 && screen.height == 480) || (screen.width == 320 && window.innerHeight <= 450);
46        os.screen159 = false;
47        os.screen189 = false;
48        os.screen199 = (screen.height == 812 && screen.width == 375) || (screen.height == 896 && screen.width == 414);
49    } //edn if
50    else if (os.android) {
51        os.screen159 = screen.height / window.innerWidth <= 540 / 360;
52        os.screen189 = (screen.height == 720 && screen.width == 360) || (screen.height == 786 && screen.width == 393);
53        os.screen199 = screen.height / screen.width >= 760 / 360;
54        os.miui = userAgent.match(/MI/) || userAgent.match(/Redmi/) ? true : false;
55        os.huawei = userAgent.match(/HUAWEI/) || userAgent.match(/HONOR/) ? true : false;
56        os.oppo = userAgent.match(/OPPO/) ? true : false;
57        os.oppoBrowser = userAgent.match(/OppoBrowser/) ? true : false;
58        os.oppoApp = os.oppo && !os.oppoBrowser && !!window.JSCallJava;
59        os.oppoR15 = userAgent.match(/PAAM00/) || userAgent.match(/PAAT00/) || userAgent.match(/PACM00/) || userAgent.match(/PACT00/) ? true : false;
60        os.vivo = userAgent.match(/vivo/) ? true : false;
61    } //edn if
62    return os;
63}//end func
64//if (window.console) window.console.log('html5:' + os.html5);
65//if (window.console) window.console.log('html5Mode:' + os.html5Mode);
66//if (window.console) window.console.log('webkit:' + os.webkit);
67//if (window.console) window.console.log('supportTouch:' + os.supportTouch);
68
69//-----------------------------------base
70var ibase = importBase();
71function importBase() {
72    var base = {}
73
74    base.load = function (f, shell, callback, nocache) {
75        nocache = nocache != null ? nocache : true;
76        var file = get_filetype(f, nocache);
77        if (file.type == "css") this.loadCss(file.src, shell, callback);
78        else if (file.type == "js") this.loadJs(file.src, shell, callback);
79    } //end func
80
81    base.loadCss = function (src, shell, callback) {
82        shell = shell || 'head';
83        var fileref = document.createElement('link');
84        fileref.setAttribute("rel", "stylesheet");
85        fileref.setAttribute("type", "text/css");
86        fileref.setAttribute("href", src);
87        document.querySelector(shell).appendChild(fileref);
88        if (callback) loadCalback(fileref, callback);
89    }//edn func
90
91    base.loadJs = function (src, shell, callback) {
92        shell = shell || 'body';
93        var fileref = document.createElement('script');
94        fileref.setAttribute("type", "text/javascript");
95        fileref.setAttribute("src", src);
96        document.querySelector(shell).appendChild(fileref);
97        if (callback) loadCalback(fileref, callback);
98    }//edn func
99
100    function loadCalback(fileref, callback) {
101        if (fileref.readyState) {
102            fileref.onreadystatechange = function () {
103                if (fileref.readyState == "loaded" || fileref.readyState == "complete") {
104                    fileref.onreadystatechange = null;
105                    callback();
106                }//edn if
107            };
108        }//edn if
109        else fileref.onload = callback;
110    }//edn func
111
112    base.creatNode = function (nodeName, idName, className, innerHTML, wrapNode) {
113        nodeName = nodeName || 'div';
114        className = className || '';
115        idName = idName || '';
116        innerHTML = innerHTML || '';
117        wrapNode = wrapNode || document.querySelector('body');
118        var newNode = document.createElement(nodeName);
119        if (className != '') newNode.className = className;
120        if (idName != '') newNode.id = idName;
121        if (innerHTML != '') newNode.innerHTML = innerHTML;
122        wrapNode.appendChild(newNode);
123    } //end func
124
125    base.getUrl = function (url) {
126        var hmsr = icom.getQueryString('hmsr');
127        hmsr = hmsr || '';
128        var utm_source = icom.getQueryString('utm_source');
129        utm_source = utm_source || '';
130        if (url && url != '') {
131            url += (hmsr != '' ? (url.indexOf('?') == -1 ? '?' : '&') + 'hmsr=' + hmsr : '') + (utm_source != '' ? '&utm_source=' + utm_source : '');
132            location.href = url;
133        } //end if
134    } //edn func
135
136    function get_filetype(f, nocache) {
137        nocache = nocache != null ? nocache : true;
138        var tmp = f.split('.');
139        var type = tmp[tmp.length - 1];
140        var src = f + (nocache ? '?v=' + Math.random() : '');
141        return {
142            type: type,
143            src: src
144        };
145    } //end func
146
147    return base;
148} //end func

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.