mirror of https://github.com/gorhill/uBlock.git
Add support to report/filter SVG image elements
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/2260
This commit is contained in:
parent
3e26a1ead8
commit
887a87d9ca
|
@ -221,7 +221,8 @@ const backgroundImageURLFromElement = function(elem) {
|
|||
// https://github.com/gorhill/uBlock/issues/1725#issuecomment-226479197
|
||||
// Limit returned string to 1024 characters.
|
||||
// Also, return only URLs which will be seen by an HTTP observer.
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/2260
|
||||
// Maybe get to the actual URL indirectly.
|
||||
const resourceURLsFromElement = function(elem) {
|
||||
const urls = [];
|
||||
const tagName = elem.localName;
|
||||
|
@ -231,7 +232,10 @@ const resourceURLsFromElement = function(elem) {
|
|||
if ( url !== '' ) { urls.push(url); }
|
||||
return urls;
|
||||
}
|
||||
const s = elem[prop];
|
||||
let s = elem[prop];
|
||||
if ( s instanceof SVGAnimatedString ) {
|
||||
s = s.baseVal;
|
||||
}
|
||||
if ( typeof s === 'string' && /^https?:\/\//.test(s) ) {
|
||||
urls.push(trimFragmentFromURL(s.slice(0, 1024)));
|
||||
}
|
||||
|
@ -376,6 +380,7 @@ const netFilter1stSources = {
|
|||
'embed': 'src',
|
||||
'iframe': 'src',
|
||||
'img': 'src',
|
||||
'image': 'href',
|
||||
'object': 'data',
|
||||
'source': 'src',
|
||||
'video': 'src'
|
||||
|
@ -671,12 +676,17 @@ const filterToDOMInterface = (( ) => {
|
|||
}
|
||||
|
||||
// Lookup by tag names.
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/2260
|
||||
// Maybe get to the actual URL indirectly.
|
||||
const elems = document.querySelectorAll(
|
||||
Object.keys(netFilter1stSources).join()
|
||||
);
|
||||
for ( const elem of elems ) {
|
||||
const srcProp = netFilter1stSources[elem.localName];
|
||||
const src = elem[srcProp];
|
||||
let src = elem[srcProp];
|
||||
if ( src instanceof SVGAnimatedString ) {
|
||||
src = src.baseVal;
|
||||
}
|
||||
if (
|
||||
typeof src === 'string' &&
|
||||
reFilter.test(src) ||
|
||||
|
|
Loading…
Reference in New Issue