Update
This commit is contained in:
@@ -66,11 +66,9 @@
|
|||||||
|
|
||||||
// ===== A. CAPTURE TWEET & SELECTED TEXT =====
|
// ===== A. CAPTURE TWEET & SELECTED TEXT =====
|
||||||
document.addEventListener('contextmenu', (e) => {
|
document.addEventListener('contextmenu', (e) => {
|
||||||
// Lưu text đang bôi đen (cho translate)
|
|
||||||
const sel = window.getSelection().toString().trim();
|
const sel = window.getSelection().toString().trim();
|
||||||
if (sel) lastSelectedText = sel;
|
if (sel) lastSelectedText = sel;
|
||||||
|
|
||||||
// Lưu tweet text — CHỈ khi click đúng vào article
|
|
||||||
const article = e.target.closest('article');
|
const article = e.target.closest('article');
|
||||||
if (article) {
|
if (article) {
|
||||||
const textEl =
|
const textEl =
|
||||||
@@ -79,7 +77,6 @@
|
|||||||
article.querySelector('div[dir="auto"]');
|
article.querySelector('div[dir="auto"]');
|
||||||
lastTweetText = textEl ? textEl.innerText.trim() : article.innerText.trim().slice(0, 600);
|
lastTweetText = textEl ? textEl.innerText.trim() : article.innerText.trim().slice(0, 600);
|
||||||
}
|
}
|
||||||
// ⚠️ KHÔNG xóa lastTweetText nếu không có article (tránh lỗi click vào padding/lề)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// ===== B. LISTENER =====
|
// ===== B. LISTENER =====
|
||||||
@@ -189,6 +186,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openSidebar(tweetText) {
|
function openSidebar(tweetText) {
|
||||||
|
// ⭐ FIX: Nếu mở comment mới (có tweetText), xóa sidebar cũ để render lại từ đầu
|
||||||
|
if (tweetText && sidebarHost) {
|
||||||
|
removeSidebar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nếu sidebar vẫn còn (trường hợp translate hoặc đang mở), chỉ cần mở drawer
|
||||||
if (sidebarHost) {
|
if (sidebarHost) {
|
||||||
const drawer = sidebarHost.shadowRoot.querySelector('.drawer');
|
const drawer = sidebarHost.shadowRoot.querySelector('.drawer');
|
||||||
if (drawer) drawer.classList.add('open');
|
if (drawer) drawer.classList.add('open');
|
||||||
|
|||||||
Reference in New Issue
Block a user