mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 11:22:38 +01:00
this fixes part of #671
This commit is contained in:
parent
bbb2d8d1ff
commit
a9e9ea454f
@ -114,9 +114,6 @@
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
@ -270,10 +267,10 @@ var netFilterFromElement = function(elem, out) {
|
||||
return;
|
||||
}
|
||||
var tagName = elem.tagName.toLowerCase();
|
||||
if ( tagName !== 'img' && tagName !== 'iframe' ) {
|
||||
if ( netFilterSources.hasOwnProperty(tagName) === false ) {
|
||||
return;
|
||||
}
|
||||
var src = elem.getAttribute('src');
|
||||
var src = elem.getAttribute(netFilterSources[tagName]);
|
||||
if ( typeof src !== 'string' || src.length === 0 ) {
|
||||
return;
|
||||
}
|
||||
@ -297,6 +294,12 @@ var netFilterFromElement = function(elem, out) {
|
||||
}
|
||||
};
|
||||
|
||||
var netFilterSources = {
|
||||
'iframe': 'src',
|
||||
'img': 'src',
|
||||
'object': 'data'
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Extract the best possible cosmetic filter, i.e. as specific as possible.
|
||||
@ -431,15 +434,16 @@ var elementsFromFilter = function(filter) {
|
||||
if ( filter.slice(0, 2) === '||' ) {
|
||||
filter = filter.replace('||', '');
|
||||
}
|
||||
var elems = document.querySelectorAll('[src]');
|
||||
var elems = document.querySelectorAll('iframe,img,object');
|
||||
var i = elems.length;
|
||||
var elem;
|
||||
var elem, src;
|
||||
while ( i-- ) {
|
||||
elem = elems[i];
|
||||
if ( typeof elem.src !== 'string' ) {
|
||||
src = elem.getAttribute(netFilterSources[elem.tagName.toLowerCase()]);
|
||||
if ( typeof src !== 'string' ) {
|
||||
continue;
|
||||
}
|
||||
if ( elem.src.indexOf(filter) !== -1 ) {
|
||||
if ( src.indexOf(filter) !== -1 ) {
|
||||
out.push(elem);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user