From 9e515b7230d11c77c1eab26557bfb6069fece84c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Aug 2022 10:39:31 +0200 Subject: [PATCH] Add more hooks --- .../client/video-channel-client-plugin.js | 41 +++++++++++++++++++ .../client/video-watch-client-plugin.js | 7 ++++ peertube-plugin-hello-world/package.json | 8 +++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 peertube-plugin-hello-world/client/video-channel-client-plugin.js diff --git a/peertube-plugin-hello-world/client/video-channel-client-plugin.js b/peertube-plugin-hello-world/client/video-channel-client-plugin.js new file mode 100644 index 0000000..7459ae1 --- /dev/null +++ b/peertube-plugin-hello-world/client/video-channel-client-plugin.js @@ -0,0 +1,41 @@ +function register ({ registerHook, peertubeHelpers }) { + + for (const hook of [ + 'action:video-channel-create.init', + 'action:video-channel-update.init', + 'action:video-channel-videos.init', + 'action:video-channel-playlists.init' + ]) { + registerHook({ + target: hook, + handler: () => console.log('Hello world', hook) + }) + } + + registerHook({ + target: 'action:video-channel-update.video-channel.loaded', + handler: ({ videoChannel }) => console.log('Channel loaded', { videoChannel }) + }) + + registerHook({ + target: 'action:video-channel-playlists.video-channel.loaded', + handler: ({ videoChannel }) => console.log('Channel loaded', { videoChannel }) + }) + registerHook({ + target: 'action:video-channel-playlists.playlists.loaded', + handler: ({ playlists }) => console.log('Playlists loaded', { playlists }) + }) + + registerHook({ + target: 'action:video-channel-videos.video-channel.loaded', + handler: ({ videoChannel }) => console.log('Channel loaded', { videoChannel }) + }) + registerHook({ + target: 'action:video-channel-videos.videos.loaded', + handler: ({ videos }) => console.log('Videos loaded', { videos }) + }) +} + +export { + register +} diff --git a/peertube-plugin-hello-world/client/video-watch-client-plugin.js b/peertube-plugin-hello-world/client/video-watch-client-plugin.js index 49c46ba..1786a3e 100644 --- a/peertube-plugin-hello-world/client/video-watch-client-plugin.js +++ b/peertube-plugin-hello-world/client/video-watch-client-plugin.js @@ -71,6 +71,13 @@ function register ({ registerHook, peertubeHelpers }) { } }) + registerHook({ + target: 'action:video-watch.video-threads.loaded', + handler: () => { + console.log('Comments found.', document.querySelectorAll('.comment')); + } + }) + for (const hook of [ 'filter:api.video-watch.video-playlist-elements.get.result' ]) { diff --git a/peertube-plugin-hello-world/package.json b/peertube-plugin-hello-world/package.json index 43f6e20..14462e1 100644 --- a/peertube-plugin-hello-world/package.json +++ b/peertube-plugin-hello-world/package.json @@ -1,6 +1,6 @@ { "name": "peertube-plugin-hello-world", - "version": "0.0.19", + "version": "0.0.20", "description": "Hello world PeerTube plugin example", "engine": { "peertube": ">=3.2.0" @@ -68,6 +68,12 @@ "scopes": [ "admin-plugin" ] + }, + { + "script": "client/video-channel-client-plugin.js", + "scopes": [ + "video-channel" + ] } ], "translations": {