feat: add UMass Amherst theme support, implement HTML snippet management system, and update page rendering logic
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
(function (el) {
|
||||
if (!el) {
|
||||
console.error("Vui lòng chọn thẻ HTML bên tab Elements trước!");
|
||||
return;
|
||||
}
|
||||
const clone = el.cloneNode(true);
|
||||
function applyStyles(original, cloned) {
|
||||
const computed = window.getComputedStyle(original);
|
||||
let styleString = "";
|
||||
for (let i = 0; i < computed.length; i++) {
|
||||
const prop = computed[i];
|
||||
const val = computed.getPropertyValue(prop);
|
||||
if (val && val !== "none" && val !== "normal" && val !== "auto") {
|
||||
styleString += `${prop}: ${val}; `;
|
||||
}
|
||||
}
|
||||
cloned.setAttribute("style", styleString);
|
||||
// Đệ quy quét qua tất cả các con, cháu bên trong để áp dụng CSS
|
||||
for (let i = 0; i < original.children.length; i++) {
|
||||
applyStyles(original.children[i], cloned.children[i]);
|
||||
}
|
||||
}
|
||||
applyStyles(el, clone);
|
||||
copy(clone.outerHTML);
|
||||
console.log("👉 Đã copy thành công cả THẺ CHA & CÁC THẺ CON kèm CSS!");
|
||||
})($0);
|
||||
Reference in New Issue
Block a user