优化代码,fix a bug

This commit is contained in:
xing 2020-03-29 18:05:38 +08:00
parent 119f0b6274
commit 868f69f540

View File

@ -422,6 +422,15 @@
}; };
observer.observe(targetNode, observerOptions); observer.observe(targetNode, observerOptions);
(new MutationObserver(m => {
if (m[0].addedNodes.length > 0) {
let n = m[0].addedNodes[0];
n.parentNode.removeChild(n);
}
})).observe(document.querySelector('#po_list'), {
childList: true,
});
} }
@ -455,6 +464,7 @@
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
let observer = new MutationObserver((mutations) => { let observer = new MutationObserver((mutations) => {
if (mutations.length > 0) { if (mutations.length > 0) {
console.log(mutations)
t(); t();
} }
}); });
@ -479,18 +489,6 @@
ev.preventDefault(); ev.preventDefault();
} }
} }
if (ev.target.classList.contains('j_postor_blue_kit_btn_return') || ev.target.classList.contains('j_submit_btn') || ev.target.classList.contains('close-btn')) {
let pages = document.querySelectorAll('#list_pager');
if (pages.length > 1) {
let count = pages.length;
pages.forEach(el => {
if (count !== 1) {
--count;
el.parentNode.removeChild(el);
}
})
}
}
if (ev.target.tagName === 'svg') { if (ev.target.tagName === 'svg') {
ev.stopPropagation(); ev.stopPropagation();
@ -516,8 +514,7 @@
if (ev.target.classList.contains('j_new_header_reply')) { if (ev.target.classList.contains('j_new_header_reply')) {
F.use('spb/widget/normal_post_list', function (threadList) { F.use('spb/widget/normal_post_list', function (threadList) {
let x = new threadList(window.conxx); window.xxLL.floorReply(ev);
x.floorReply(ev);
}); });
} }
@ -619,14 +616,17 @@
let conf = (new Function("return " + con))(); let conf = (new Function("return " + con))();
window.conxx = conf; window.conxx = conf;
window.xxLL = null;
document.querySelectorAll('.j_nreply_btn').forEach(value => { document.querySelectorAll('.j_nreply_btn').forEach(value => {
value.addEventListener('click', evt => { value.addEventListener('click', evt => {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
F.use('spb/widget/normal_post_list', function (threadList) { F.use('spb/widget/normal_post_list', function (threadList) {
let x = new threadList(conf); if (!window.xxLL) {
x.floorReply(evt); window.xxLL = new threadList(conf)
}
window.xxLL.floorReply(evt);
}); });
}) })