commit bc5d67ae75ea3ce47365a36cd9d5f6678916bf61 Author: みてるぞ Date: Fri Jul 19 02:17:14 2024 +0900 diff --git a/Home.md b/Home.md new file mode 100644 index 0000000..097d937 --- /dev/null +++ b/Home.md @@ -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); +``` \ No newline at end of file