1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 10:09:38 +02:00
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(){}; var noopFunc = function(){};
/******************************************************************************/ /******************************************************************************/
@ -730,12 +737,7 @@ vAPI.messaging.onPortMessage = (function() {
var messaging = vAPI.messaging, var messaging = vAPI.messaging,
toAuxPending = {}; toAuxPending = {};
// https://issues.adblockplus.org/ticket/5695 var supportsUserStylesheets = vAPI.supportsUserStylesheets;
// - 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;
// Use a wrapper to avoid closure and to allow reuse. // Use a wrapper to avoid closure and to allow reuse.
var CallbackWrapper = function(port, request, timeout) { var CallbackWrapper = function(port, request, timeout) {

View File

@ -98,7 +98,8 @@ var fromNetFilter = function(details) {
var fromCosmeticFilter = function(details) { var fromCosmeticFilter = function(details) {
var match = /^#@?#/.exec(details.rawFilter), var match = /^#@?#/.exec(details.rawFilter),
prefix = match[0], 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 // 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 // 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] ) { switch ( fargs[0] ) {
case 0: // id-based case 0: // id-based
case 2: // class-based case 2: // class-based
found = prefix + idOrClassPrefix + filter; found = prefix + selector;
break; break;
case 4: case 4:
case 5: case 5:
case 7: case 7:
found = prefix + filter; found = prefix + selector;
break; break;
case 1: case 1:
case 3: case 3:
if ( fargs[2] === filter ) { if ( fargs[2] === selector ) {
found = prefix + filter; found = prefix + selector;
} }
break; break;
case 6: case 6:
case 8: case 8:
case 9: case 9:
if ( fargs[3] !== selector ) { break; }
if ( if (
fargs[2] === '' || fargs[2] === '' ||
reHostname.test(fargs[2]) === true || reHostname.test(fargs[2]) === true ||
reEntity !== undefined && reEntity.test(fargs[2]) === true reEntity !== undefined && reEntity.test(fargs[2]) === true
) { ) {
found = fargs[2] + prefix + filter; found = fargs[2] + prefix + selector;
} }
break; break;
} }