temp
===
```=js
let smarteditContainer = null;
const waitInsertClass = (smarteditContainer) => {
return new Promise((resolve, reject) => {
const checkContainer = setInterval(() => {
smarteditContainer = document.querySelector('smarteditcontainer-component');
if (smarteditContainer != null) {
clearInterval(checkContainer);
resolve();
}
}, 1000)
})
}
waitInsertClass(smarteditContainer).then(() => {
smarteditContainer = document.querySelector('smarteditcontainer-component')
smarteditObserver.observe(smarteditContainer, { childList: true });
})
const smarteditObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach((node) => {
waitForButton(editButton).then(() => {
initPage();
editButton = document.querySelector('.se-perspective-selector__btn');
const observer = new MutationObserver((mutations) => {
if (mutations != null) {
mutations.forEach((mutation) => {
if (editButton.textContent != null) {
initPage();
}
});
}
});
if (editButton != null) {
observer.observe(editButton, { characterData: true, subtree: true });
}
}); if (node.parentNode === targetNodeee) {
}
});
}
});
});
let editButton = null;
const waitForButton = (editButton) => {
return new Promise((resolve, reject) => {
const checkButton = setInterval(() => {
editButton = document.querySelector('.se-perspective-selector__btn');
if (editButton != null) {
clearInterval(checkButton);
resolve();
}
}, 1000)
})
}
waitForButton(editButton).then(() => {
initPage();
editButton = document.querySelector('.se-perspective-selector__btn');
const observer = new MutationObserver((mutations) => {
if (mutations != null) {
mutations.forEach((mutation) => {
if (editButton.textContent != null) {
initPage();
}
});
}
});
if (editButton != null) {
observer.observe(editButton, { characterData: true, subtree: true });
}
});
function initPage() {
document.querySelector('#js_iFrameWrapper').setAttribute("style", "height:101%");
setTimeout(() => {
document.querySelector('#js_iFrameWrapper').setAttribute("style", "height:100%");
}, 10)
}
```
其中 mutation Observe的部份
```=js
const smarteditObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach((node) => {
waitForButton(editButton).then(() => {
initPage();
editButton = document.querySelector('.se-perspective-selector__btn');
const observer = new MutationObserver((mutations) => {
if (mutations != null) {
mutations.forEach((mutation) => {
if (editButton.textContent != null) {
initPage();
}
});
}
});
if (editButton != null) {
observer.observe(editButton, { characterData: true, subtree: true });
}
}); if (node.parentNode === targetNodeee) {
}
});
}
});
});
```