mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
code review: not a fan of deep indentation; detect Edge, Safari
This commit is contained in:
parent
ae6b376a75
commit
7ca6e8bfb3
1 changed files with 26 additions and 29 deletions
|
@ -70,39 +70,36 @@ vAPI.webextFlavor = {
|
|||
});
|
||||
}
|
||||
|
||||
// Synchronous
|
||||
var match = /Firefox\/([\d.]+)/.exec(ua);
|
||||
if ( match !== null ) {
|
||||
// Synchronous -- order of tests is important
|
||||
var match;
|
||||
if ( (match = /\bFirefox\/(\d+)/.exec(ua)) !== null ) {
|
||||
flavor.major = parseInt(match[1], 10) || 0;
|
||||
soup.add('mozilla')
|
||||
.add('firefox');
|
||||
soup.add('mozilla').add('firefox');
|
||||
if ( flavor.major >= 53 ) { soup.add('user_stylesheet'); }
|
||||
if ( flavor.major >= 57 ) { soup.add('html_filtering'); }
|
||||
} else {
|
||||
match = /OPR\/([\d.]+)/.exec(ua);
|
||||
if ( match !== null ) {
|
||||
var reEx = /Chrom(?:e|ium)\/([\d.]+)/;
|
||||
} else if ( (match = /\bEdge\/(\d+)/.exec(ua)) !== null ) {
|
||||
flavor.major = parseInt(match[1], 10) || 0;
|
||||
soup.add('microsoft').add('edge');
|
||||
} else if ( (match = /\bOPR\/(\d+)/.exec(ua)) !== null ) {
|
||||
var reEx = /\bChrom(?:e|ium)\/([\d.]+)/;
|
||||
if ( reEx.test(ua) ) { match = reEx.exec(ua); }
|
||||
flavor.major = parseInt(match[1], 10) || 0;
|
||||
soup.add('opera').add('chromium');
|
||||
} else {
|
||||
match = /Chromium\/([\d.]+)/.exec(ua);
|
||||
if ( match !== null ) {
|
||||
} else if ( (match = /\bChromium\/(\d+)/.exec(ua)) !== null ) {
|
||||
flavor.major = parseInt(match[1], 10) || 0;
|
||||
soup.add('chromium');
|
||||
} else {
|
||||
match = /Chrome\/([\d.]+)/.exec(ua);
|
||||
if ( match !== null ) {
|
||||
} else if ( (match = /\bChrome\/(\d+)/.exec(ua)) !== null ) {
|
||||
flavor.major = parseInt(match[1], 10) || 0;
|
||||
soup.add('google').add('chromium');
|
||||
} else if ( (match = /\bSafari\/(\d+)/.exec(ua)) !== null ) {
|
||||
flavor.major = parseInt(match[1], 10) || 0;
|
||||
soup.add('apple').add('safari');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/3588
|
||||
if ( soup.has('chromium') && flavor.major >= 67 ) {
|
||||
if ( soup.has('chromium') && flavor.major >= 66 ) {
|
||||
soup.add('user_stylesheet');
|
||||
}
|
||||
}
|
||||
|
||||
// Don't starve potential listeners
|
||||
if ( !async ) {
|
||||
|
|
Loading…
Reference in a new issue