Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加手机百度和夸克浏览器的规则 #113

Merged
merged 3 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions lib/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,8 @@ const OS = [
];

const BROWSER = [
["baiduboxapp",
function(ua) {
let back = 0;
let a;
if (/ baiduboxapp\//i.test(ua)) {
if (a = /([\d+.]+)_(?:diordna|enohpi)_/.exec(ua)) {
a = a[1].split(".");
back = a.reverse().join(".");
} else if ((a = /baiduboxapp\/([\d+.]+)/.exec(ua))) {
back = a[1];
}

return {
version: back,
};
}
return false;
},
],
// 夸克浏览器
["quark", /\bquark\/([0-9.]+)/],
["googlebot", /\bgooglebot\/([0-9.]+)/],
// 百度搜索引擎爬虫:无线、网页搜索
// http://help.baidu.com/question?prod_en=master&class=498&id=1000550
Expand Down
22 changes: 21 additions & 1 deletion lib/web-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const DEVICES = [
return /\bhtc[ _\-]?([a-z0-9 ]+)/;
}
}],
["oppo", /\boppo[_]([a-z0-9]+)/],
["oppo", /\boppo[_ ]([a-z0-9]+)/],
["konka", /\bkonka[_\-]([a-z0-9]+)/],
["sonyericsson", /\bmt([a-z0-9]+)/],
["coolpad", /\bcoolpad[_ ]?([a-z0-9]+)/],
Expand Down Expand Up @@ -304,6 +304,26 @@ const BROWSER = [
return /\b(?:ucbrowser|uc)\b/;
}
}],
["baiduboxapp",
function(ua) {
let back = 0;
let a;
if (/ baiduboxapp\//i.test(ua)) {
if (a = /([\d+.]+)_(?:diordna|enohpi)_/.exec(ua)) {
a = a[1].split(".");
back = a.reverse().join(".");
} else if ((a = /baiduboxapp\/([\d+.]+)/.exec(ua))) {
back = a[1];
}

return {
version: back,
};
}
return false;
},
],
["oppobrowser", /\boppobrowser\/([0-9.]+)/],
["chrome", / (?:chrome|crios|crmo)\/([0-9.]+)/],
// Android 默认浏览器。该规则需要在 safari 之前。
["android", function(ua){
Expand Down
24 changes: 24 additions & 0 deletions tests/detector-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,30 @@ const UAs = [
browser: "micromessenger/6.2.5.51;6.2.5.51;o",
engine: (isBlinkEngine() ? "blink" : "webkit") + "/533.1;533.1;o",
}],
["Mozilla/5.0 (Linux; Android 7.0; E6683 Build/32.3.A.0.376) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/35.0.1916.138 Mobile Safari/537.36 T7/7.4 baiduboxapp/8.4 (Baidu; P1 7.0)", {
device: "android/-1",
os: "android/7.0",
browser: "baiduboxapp/8.4;8.4;o",
engine: (isBlinkEngine() ? "blink" : "webkit") + "/537.36;537.36;o",
}],
["Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E304 baiduboxapp/0_01.0.4.8_enohpi_4331_057/1.3.01_1C2%259enohPi/1099a/5H651T3G1F97R4K26P7L7NDG6035130273SB73A96IJVT01J9UY/1", {
device: "iphone/-1",
os: "ios/10.3.1",
browser: "baiduboxapp/8.4.0.01;8.4.0.01;o",
engine: (isBlinkEngine() ? "blink" : "webkit") + "/603.1.30;603.1.30;o",
}],
["Mozilla/5.0 (Linux; U; Android 7.0; zh-CN; E6683 Build/32.3.A.0.376) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/40.0.2214.89 Quark/1.6.8.909 Mobile Safari/537.36", {
device: "android/-1",
os: "android/7.0",
browser: "quark/1.6.8.909;1.6.8.909;o",
engine: (isBlinkEngine() ? "blink" : "webkit") + "/537.36;537.36;o",
}],
["Mozilla/5.0 (Linux; U; Android 6.0.1; zh-cn; OPPO R9s Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/38.0.0.0 Mobile Safari/537.36 OppoBrowser/4.2.8", {
device: "oppo/r9s",
os: "android/6.0.1",
browser: "oppobrowser/4.2.8;4.2.8;o",
engine: (isBlinkEngine() ? "blink" : "webkit") + "/537.36;537.36;o",
}],

// NA
["", {
Expand Down