-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove-comments.js
52 lines (40 loc) · 1.68 KB
/
move-comments.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// ==UserScript==
// @name Move YouTube Comments
// @namespace http://tampermonkey.net/
// @version 2.0
// @description Move YouTube Comments to where live chat would be and put them in an infinite scroll box
// @author votqanh
// @match *://*.youtube.com/*
// @exclude *://*.youtube.com/playlist*
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
var comments = "#sections.ytd-comments:not([static-comments-header])"
window.addEventListener('load', () => {
waitForKeyElements(comments, () => {
comments = document.querySelector(comments);
var container = document.getElementById("secondary-inner");
container.prepend(comments);
const styles = {
display: 'block',
padding: '5px',
width: '100%',
height: '470px',
overflowY: 'scroll',
marginBottom: '20px'
}
Object.assign(comments.style, styles);
var header = "ytd-comments-header-renderer";
waitForKeyElements(header, () => {document.querySelector(header).style.marginTop = "0px"});
var loadCmt = "yt-next-continuation.ytd-item-section-renderer";
comments.addEventListener('scroll', () => {
if (comments.scrollHeight - comments.scrollTop === comments.clientHeight) {
document.querySelector(loadCmt).trigger();
}
});
});
});
})();