mirror of https://github.com/gorhill/uBlock.git
fix #3210
This commit is contained in:
parent
d523d64511
commit
386e8bee9c
|
@ -114,6 +114,7 @@
|
||||||
"group": "ads",
|
"group": "ads",
|
||||||
"off": true,
|
"off": true,
|
||||||
"title": "Adguard Mobile Filters",
|
"title": "Adguard Mobile Filters",
|
||||||
|
"ua": "mobile",
|
||||||
"contentURL": "https://filters.adtidy.org/extension/ublock/filters/11.txt",
|
"contentURL": "https://filters.adtidy.org/extension/ublock/filters/11.txt",
|
||||||
"supportURL": "https://github.com/AdguardTeam/AdguardFilters#adguard-filters",
|
"supportURL": "https://github.com/AdguardTeam/AdguardFilters#adguard-filters",
|
||||||
"instructionURL": "https://kb.adguard.com/en/general/adguard-ad-filters"
|
"instructionURL": "https://kb.adguard.com/en/general/adguard-ad-filters"
|
||||||
|
|
|
@ -295,7 +295,7 @@
|
||||||
return haystack.replace(
|
return haystack.replace(
|
||||||
new RegExp(
|
new RegExp(
|
||||||
'(^|\\n)' +
|
'(^|\\n)' +
|
||||||
needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') +
|
this.escapeRegex(needle) +
|
||||||
'(\\n|$)', 'g'),
|
'(\\n|$)', 'g'),
|
||||||
'\n'
|
'\n'
|
||||||
).trim();
|
).trim();
|
||||||
|
@ -439,7 +439,7 @@
|
||||||
selectedListKeys.push(key);
|
selectedListKeys.push(key);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( this.matchCurrentLanguage(list.lang) ) {
|
if ( this.listMatchesEnvironment(list) ) {
|
||||||
selectedListKeys.push(key);
|
selectedListKeys.push(key);
|
||||||
list.off = false;
|
list.off = false;
|
||||||
}
|
}
|
||||||
|
@ -1069,6 +1069,32 @@
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/2344
|
||||||
|
// Support mutliple locales per filter list.
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uBlock/issues/3210
|
||||||
|
// Support ability to auto-enable a filter list based on user agent.
|
||||||
|
|
||||||
|
µBlock.listMatchesEnvironment = function(details) {
|
||||||
|
var re;
|
||||||
|
// Matches language?
|
||||||
|
if ( typeof details.lang === 'string' ) {
|
||||||
|
if ( this.listMatchesEnvironment.reLang === undefined ) {
|
||||||
|
re = new RegExp('\\b' + self.navigator.language.slice(0, 2) + '\\b');
|
||||||
|
this.listMatchesEnvironment.reLang = re;
|
||||||
|
}
|
||||||
|
if ( re.test(details.lang) ) { return true; }
|
||||||
|
}
|
||||||
|
// Matches user agent?
|
||||||
|
if ( typeof details.ua === 'string' ) {
|
||||||
|
re = new RegExp('\\b' + this.escapeRegex(details.ua) + '\\b', 'i');
|
||||||
|
if ( re.test(self.navigator.userAgent) ) { return true; }
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
µBlock.scheduleAssetUpdater = (function() {
|
µBlock.scheduleAssetUpdater = (function() {
|
||||||
var timer, next = 0;
|
var timer, next = 0;
|
||||||
return function(updateDelay) {
|
return function(updateDelay) {
|
||||||
|
@ -1196,7 +1222,7 @@
|
||||||
if ( details.entry.content === 'filters' ) {
|
if ( details.entry.content === 'filters' ) {
|
||||||
if (
|
if (
|
||||||
details.entry.off !== true ||
|
details.entry.off !== true ||
|
||||||
this.matchCurrentLanguage(details.entry.lang)
|
this.listMatchesEnvironment(details.entry)
|
||||||
) {
|
) {
|
||||||
this.saveSelectedFilterLists([ details.assetKey ], true);
|
this.saveSelectedFilterLists([ details.assetKey ], true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,18 +347,6 @@
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/2344
|
|
||||||
|
|
||||||
µBlock.matchCurrentLanguage = function(s) {
|
|
||||||
if ( typeof s !== 'string' ) { return false; }
|
|
||||||
if ( this.matchCurrentLanguage.reLang === undefined ) {
|
|
||||||
this.matchCurrentLanguage.reLang = new RegExp('\\b' + self.navigator.language.slice(0, 2) + '\\b');
|
|
||||||
}
|
|
||||||
return this.matchCurrentLanguage.reLang.test(s);
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
µBlock.MRUCache = function(size) {
|
µBlock.MRUCache = function(size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.array = [];
|
this.array = [];
|
||||||
|
@ -396,3 +384,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
||||||
|
|
||||||
|
µBlock.escapeRegex = function(s) {
|
||||||
|
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue