diff --git a/mods/features/adblock.js b/mods/features/adblock.js index 4c3d16be..6e1a5eb2 100644 --- a/mods/features/adblock.js +++ b/mods/features/adblock.js @@ -378,6 +378,15 @@ function addLongPress(items) { } } })); + item.tileRenderer.onLongPressCommand.showMenuCommand.menu.menuRenderer.items.push(MenuServiceItemRenderer('Go to Channel', { + clickTrackingParams: null, + playlistEditEndpoint: { + customAction: { + action: 'GO_TO_CHANNEL', + parameters: { videoId: item.tileRenderer.contentId } + } + } + })); continue; } if (!configRead('enableLongPress')) continue; diff --git a/mods/resolveCommand.js b/mods/resolveCommand.js index fca33f31..a535da5d 100644 --- a/mods/resolveCommand.js +++ b/mods/resolveCommand.js @@ -212,6 +212,9 @@ function customAction(action, parameters) { window.queuedVideos.videos.push(parameters); showToast('TizenTube', 'Video added to queue.'); break; + case 'GO_TO_CHANNEL': + goToChannel(parameters); + break; case 'CLEAR_QUEUE': window.queuedVideos.videos = []; showToast('TizenTube', 'Video queue cleared.'); @@ -220,4 +223,32 @@ function customAction(action, parameters) { checkForUpdates(true); break; } +} + +function goToChannel(parameters) { + const videoId = parameters && parameters.videoId; + if (!videoId) { + showToast('TizenTube', 'Could not determine video.'); + return; + } + fetch('https://www.youtube.com/watch?v=' + encodeURIComponent(videoId) + '&hl=en', { + credentials: 'omit' + }) + .then(function (res) { return res.text(); }) + .then(function (html) { + const match = html.match(/"channelId":"(UC[A-Za-z0-9_-]{20,})"/); + if (!match) { + showToast('TizenTube', 'Could not find channel.'); + return; + } + const channelId = match[1]; + resolveCommand({ + browseEndpoint: { + browseId: channelId + } + }); + }) + .catch(function () { + showToast('TizenTube', 'Failed to load channel.'); + }); } \ No newline at end of file diff --git a/mods/ui/ytUI.js b/mods/ui/ytUI.js index a1b9c93b..ad42f027 100644 --- a/mods/ui/ytUI.js +++ b/mods/ui/ytUI.js @@ -235,6 +235,15 @@ function longPressData(data) { } } }), + MenuServiceItemRenderer('Go to Channel', { + clickTrackingParams: null, + playlistEditEndpoint: { + customAction: { + action: 'GO_TO_CHANNEL', + parameters: { videoId: data.videoId } + } + } + }), ], trackingParams: null, accessibility: {