|
|
@@ -0,0 +1,55 @@ |
|
|
|
```javascript
|
|
|
|
let videoId;
|
|
|
|
let lastVideoId;
|
|
|
|
let comments = [];
|
|
|
|
|
|
|
|
setInterval (() => {
|
|
|
|
const sendBtn = document.getElementById ('niconico-comment-send');
|
|
|
|
const comBox = document.getElementById ('niconico-comment-input');
|
|
|
|
|
|
|
|
if (sendBtn == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
sendBtn.addEventListener ('click', () =>
|
|
|
|
{
|
|
|
|
const lang = document.querySelector ('html').lang;
|
|
|
|
|
|
|
|
const style = '';
|
|
|
|
const timeSec = document.querySelector ('video').currentTime;
|
|
|
|
const time = `${Math.trunc (timeSec / 60)}:${(timeSec % 60).toFixed (3).padStart (6, '0')}`;
|
|
|
|
|
|
|
|
if ((comBox.value == null) || (comBox.value === ''))
|
|
|
|
return;
|
|
|
|
|
|
|
|
document.querySelector ('textarea').value = `${time}/${lang}/${style}/${comBox.value}`;
|
|
|
|
document.querySelector ('textarea').dispatchEvent (new InputEvent('input', {
|
|
|
|
'bubbles': true,
|
|
|
|
'cancelable': true
|
|
|
|
}));
|
|
|
|
setTimeout (() => {
|
|
|
|
document.querySelector ('button.peertube-button.orange-button.ng-star-inserted').click ();
|
|
|
|
comBox.value = '';
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
setInterval (async () =>
|
|
|
|
{
|
|
|
|
videoId = (new URL (location.href)).pathname.match (/^\/w\/([0-9a-zA-Z\-_]+)/)?.[1];
|
|
|
|
|
|
|
|
if (videoId !== lastVideoId)
|
|
|
|
{
|
|
|
|
lastVideoId = videoId;
|
|
|
|
|
|
|
|
if (videoId)
|
|
|
|
{
|
|
|
|
console.log (comments = (await fetch(`/api/v1/videos/${videoId}/comment-threads?count=100&sort=-createdAt`)
|
|
|
|
.then(response => response.ok && response.json ())).data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let cmtStyle;
|
|
|
|
if ((cmtStyle = document.querySelector ('.comment-threads')?.parentElement?.style) != null)
|
|
|
|
cmtStyle.display = 'none';
|
|
|
|
}, 100);
|
|
|
|
``` |