gorhill 2017-10-22 12:48:13 -04:00
parent 4f7aab695c
commit ef84e6d8fd
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 16 additions and 12 deletions

View File

@ -54,6 +54,13 @@ if (
});
}
// https://issues.adblockplus.org/ticket/5695
// - Good idea, adopted: cleaner way to detect user-stylesheet support.
vAPI.supportsUserStylesheets =
chrome.extensionTypes instanceof Object &&
chrome.extensionTypes.CSSOrigin instanceof Object &&
'USER' in chrome.extensionTypes.CSSOrigin;
var noopFunc = function(){};
/******************************************************************************/
@ -730,12 +737,7 @@ vAPI.messaging.onPortMessage = (function() {
var messaging = vAPI.messaging,
toAuxPending = {};
// https://issues.adblockplus.org/ticket/5695
// - Good idea, adopted: cleaner way to detect user-stylesheet support.
var supportsUserStylesheets =
chrome.extensionTypes instanceof Object &&
chrome.extensionTypes.CSSOrigin instanceof Object &&
'USER' in chrome.extensionTypes.CSSOrigin;
var supportsUserStylesheets = vAPI.supportsUserStylesheets;
// Use a wrapper to avoid closure and to allow reuse.
var CallbackWrapper = function(port, request, timeout) {

View File

@ -98,7 +98,8 @@ var fromNetFilter = function(details) {
var fromCosmeticFilter = function(details) {
var match = /^#@?#/.exec(details.rawFilter),
prefix = match[0],
filter = details.rawFilter.slice(prefix.length);
filter = details.rawFilter.slice(prefix.length),
selector = filter;
// With low generic simple cosmetic filters, the class or id prefix
// character is not part of the compiled data. So we must be ready to
@ -173,28 +174,29 @@ var fromCosmeticFilter = function(details) {
switch ( fargs[0] ) {
case 0: // id-based
case 2: // class-based
found = prefix + idOrClassPrefix + filter;
found = prefix + selector;
break;
case 4:
case 5:
case 7:
found = prefix + filter;
found = prefix + selector;
break;
case 1:
case 3:
if ( fargs[2] === filter ) {
found = prefix + filter;
if ( fargs[2] === selector ) {
found = prefix + selector;
}
break;
case 6:
case 8:
case 9:
if ( fargs[3] !== selector ) { break; }
if (
fargs[2] === '' ||
reHostname.test(fargs[2]) === true ||
reEntity !== undefined && reEntity.test(fargs[2]) === true
) {
found = fargs[2] + prefix + filter;
found = fargs[2] + prefix + selector;
}
break;
}