From 44ed8708a5e11d9d83e5d04af4eb58e6d8a614cb Mon Sep 17 00:00:00 2001 From: 1natsu172 <1natsu172@users.noreply.github.com> Date: Thu, 28 Dec 2017 04:01:48 +0900 Subject: [PATCH 1/3] change the hide method to not disappear elements tree --- youtube.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube.css b/youtube.css index a116150..99dd471 100644 --- a/youtube.css +++ b/youtube.css @@ -1,5 +1,6 @@ .hide-comments { - display: none !important; + height: 0px; + overflow: hidden; } .fake-paper-button { From 510bd4e014acba4504afa8c60d7dc5abf8fb97f4 Mon Sep 17 00:00:00 2001 From: 1natsu <1natsu@1natsus-MacBook-Pro.local> Date: Thu, 28 Dec 2017 04:29:03 +0900 Subject: [PATCH 2/3] Improve not to disturb comment loading process. Pre-load comments in the background before displaying comments. --- script.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/script.js b/script.js index ba05206..a5c1c39 100644 --- a/script.js +++ b/script.js @@ -137,14 +137,14 @@ const newYouTube = { return ( typeof e !== 'undefined' && e.type === 'yt-visibility-refresh' && - (e.target.tagName === 'YT-IMG-SHADOW' || - e.target.tagName === 'YTD-VIDEO-SECONDARY-INFO-RENDERER') + e.target.tagName === 'YTD-ITEM-SECTION-RENDERER' // this mean: rendered childNode of comments'DOM(ytd-comments) ); }, _addClass() { debugLog('ADDING CLASS...'); - document.getElementById('comments').classList.add('hide-comments'); + // document.getElementById('comments').classList.add('hide-comments'); + document.querySelector('ytd-item-section-renderer.ytd-comments').classList.add('hide-comments'); }, _addButton() { @@ -166,7 +166,8 @@ const newYouTube = { _toggleComments() { const label = document.getElementById('toggle-comments').firstElementChild; - const comments = document.getElementById('comments'); + // const comments = document.getElementById('comments'); + const comments = document.querySelector("ytd-item-section-renderer.ytd-comments"); if (comments.classList.toggle('hide-comments')) { label.textContent = globals.showComments; From 1e83df646718964bc24edb5ac67fa0ee72242ade Mon Sep 17 00:00:00 2001 From: 1natsu <1natsu172@users.noreply.github.com> Date: Thu, 28 Dec 2017 04:53:59 +0900 Subject: [PATCH 3/3] comment out delete --- script.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/script.js b/script.js index a5c1c39..78ca8dd 100644 --- a/script.js +++ b/script.js @@ -143,7 +143,6 @@ const newYouTube = { _addClass() { debugLog('ADDING CLASS...'); - // document.getElementById('comments').classList.add('hide-comments'); document.querySelector('ytd-item-section-renderer.ytd-comments').classList.add('hide-comments'); }, @@ -166,7 +165,6 @@ const newYouTube = { _toggleComments() { const label = document.getElementById('toggle-comments').firstElementChild; - // const comments = document.getElementById('comments'); const comments = document.querySelector("ytd-item-section-renderer.ytd-comments"); if (comments.classList.toggle('hide-comments')) {