mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-15 15:32:28 +02:00
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
|
// https://github.com/gorhill/uBlock/issues/1725#issuecomment-226479197
|
||||||
// Limit returned string to 1024 characters.
|
// Limit returned string to 1024 characters.
|
||||||
// Also, return only URLs which will be seen by an HTTP observer.
|
// 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 resourceURLsFromElement = function(elem) {
|
||||||
const urls = [];
|
const urls = [];
|
||||||
const tagName = elem.localName;
|
const tagName = elem.localName;
|
||||||
@ -231,7 +232,10 @@ const resourceURLsFromElement = function(elem) {
|
|||||||
if ( url !== '' ) { urls.push(url); }
|
if ( url !== '' ) { urls.push(url); }
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
const s = elem[prop];
|
let s = elem[prop];
|
||||||
|
if ( s instanceof SVGAnimatedString ) {
|
||||||
|
s = s.baseVal;
|
||||||
|
}
|
||||||
if ( typeof s === 'string' && /^https?:\/\//.test(s) ) {
|
if ( typeof s === 'string' && /^https?:\/\//.test(s) ) {
|
||||||
urls.push(trimFragmentFromURL(s.slice(0, 1024)));
|
urls.push(trimFragmentFromURL(s.slice(0, 1024)));
|
||||||
}
|
}
|
||||||
@ -376,6 +380,7 @@ const netFilter1stSources = {
|
|||||||
'embed': 'src',
|
'embed': 'src',
|
||||||
'iframe': 'src',
|
'iframe': 'src',
|
||||||
'img': 'src',
|
'img': 'src',
|
||||||
|
'image': 'href',
|
||||||
'object': 'data',
|
'object': 'data',
|
||||||
'source': 'src',
|
'source': 'src',
|
||||||
'video': 'src'
|
'video': 'src'
|
||||||
@ -671,12 +676,17 @@ const filterToDOMInterface = (( ) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lookup by tag names.
|
// Lookup by tag names.
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/2260
|
||||||
|
// Maybe get to the actual URL indirectly.
|
||||||
const elems = document.querySelectorAll(
|
const elems = document.querySelectorAll(
|
||||||
Object.keys(netFilter1stSources).join()
|
Object.keys(netFilter1stSources).join()
|
||||||
);
|
);
|
||||||
for ( const elem of elems ) {
|
for ( const elem of elems ) {
|
||||||
const srcProp = netFilter1stSources[elem.localName];
|
const srcProp = netFilter1stSources[elem.localName];
|
||||||
const src = elem[srcProp];
|
let src = elem[srcProp];
|
||||||
|
if ( src instanceof SVGAnimatedString ) {
|
||||||
|
src = src.baseVal;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
typeof src === 'string' &&
|
typeof src === 'string' &&
|
||||||
reFilter.test(src) ||
|
reFilter.test(src) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user