add remove all unique ids (#3964)
This commit is contained in:
@@ -2725,6 +2725,34 @@ function isAnimationFinished() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove unique_id attribute from all elements on the page.
|
||||
* This includes elements in the main document and shadow DOM.
|
||||
*/
|
||||
function removeAllUniqueIds() {
|
||||
// Function to recursively remove unique_id from an element and its children
|
||||
const removeUniqueIdFromElement = (element) => {
|
||||
if (element.hasAttribute("unique_id")) {
|
||||
element.removeAttribute("unique_id");
|
||||
}
|
||||
|
||||
// Process children in the main DOM
|
||||
for (const child of Array.from(element.children)) {
|
||||
removeUniqueIdFromElement(child);
|
||||
}
|
||||
|
||||
// Process elements in shadow DOM if present
|
||||
if (element.shadowRoot) {
|
||||
for (const shadowChild of Array.from(element.shadowRoot.children)) {
|
||||
removeUniqueIdFromElement(shadowChild);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Start from document.documentElement to process the entire page
|
||||
removeUniqueIdFromElement(document.documentElement);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
// How to run the code:
|
||||
|
||||
Reference in New Issue
Block a user