mirror of
https://github.com/manualdousuario/marreta.git
synced 2025-09-02 02:30:20 +00:00
nova regra removeCustomAttr
This commit is contained in:
parent
d4ab2c4cd8
commit
761b2dde52
2 changed files with 37 additions and 1 deletions
|
@ -79,6 +79,7 @@ return [
|
|||
'navdmp.com',
|
||||
'getblue.io',
|
||||
'smartocto.com',
|
||||
'cdn.pn.vg'
|
||||
'cdn.pn.vg',
|
||||
'static.vocstatic.com'
|
||||
]
|
||||
];
|
||||
|
|
|
@ -623,6 +623,41 @@ class URLAnalyzer
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($domainRules['removeCustomAttr'])) {
|
||||
foreach ($domainRules['removeCustomAttr'] as $attrPattern) {
|
||||
if (strpos($attrPattern, '*') !== false) {
|
||||
// For wildcard attributes (e.g. data-*) / Para atributos com wildcard (ex: data-*)
|
||||
$elements = $xpath->query('//*');
|
||||
if ($elements !== false) {
|
||||
$pattern = '/^' . str_replace('*', '.*', $attrPattern) . '$/';
|
||||
foreach ($elements as $element) {
|
||||
if ($element->hasAttributes()) {
|
||||
$attrs = [];
|
||||
foreach ($element->attributes as $attr) {
|
||||
if (preg_match($pattern, $attr->name)) {
|
||||
$attrs[] = $attr->name;
|
||||
}
|
||||
}
|
||||
foreach ($attrs as $attr) {
|
||||
$element->removeAttribute($attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->activatedRules[] = "removeCustomAttr: $attrPattern";
|
||||
}
|
||||
} else {
|
||||
// For non-wildcard attributes / Para atributos sem wildcard
|
||||
$elements = $xpath->query("//*[@$attrPattern]");
|
||||
if ($elements !== false && $elements->length > 0) {
|
||||
foreach ($elements as $element) {
|
||||
$element->removeAttribute($attrPattern);
|
||||
}
|
||||
$this->activatedRules[] = "removeCustomAttr: $attrPattern";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue