Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mods/features/adblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions mods/resolveCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand All @@ -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.');
});
}
9 changes: 9 additions & 0 deletions mods/ui/ytUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down