diff options
author | gorhill <rhill@raymondhill.net> | 2015-02-03 18:43:51 -0500 |
---|---|---|
committer | gorhill <rhill@raymondhill.net> | 2015-02-03 18:43:51 -0500 |
commit | a9e9ea454fbfe1ddf56bc03c6552047382ec1da9 (patch) | |
tree | a4b09ba111317bee84f5dc4bfcf1261d6cfc159e /src | |
parent | bbb2d8d1ff7dfd4e981219e4c71873588d292830 (diff) | |
download | uBlock-a9e9ea454fbfe1ddf56bc03c6552047382ec1da9.zip uBlock-a9e9ea454fbfe1ddf56bc03c6552047382ec1da9.tar.gz uBlock-a9e9ea454fbfe1ddf56bc03c6552047382ec1da9.tar.bz2 |
this fixes part of #671
Diffstat (limited to 'src')
-rw-r--r-- | src/js/element-picker.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/js/element-picker.js b/src/js/element-picker.js index db79f61..7915aea 100644 --- a/src/js/element-picker.js +++ b/src/js/element-picker.js @@ -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); } } |