Skip to content

Commit

Permalink
Merge pull request #1900 from WongChoice/master
Browse files Browse the repository at this point in the history
Modification to fix #1898 - Embeds subtitle gives user the option to embed subtitle on screenshot or not
  • Loading branch information
ImprovedTube authored Dec 27, 2023
2 parents ffc2ef6 + f5f5828 commit 2d2ee8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,21 @@ ImprovedTube.screenshot = function () {

setTimeout(function () {
ctx.drawImage(video, 0, 0, cvs.width, cvs.height);
ImprovedTube.currentSubtitle(ctx);
if(ImprovedTube.storage.embed_subtitle === true){ImprovedTube.currentSubtitle(ctx);}

cvs.toBlob(function (blob) {
if (ImprovedTube.storage.player_screenshot_save_as !== 'clipboard') {
var a = document.createElement('a');
a.href = URL.createObjectURL(blob); console.log("screeeeeeenshot tada!");
var subText = '';
if (ImprovedTube.storage.embed_subtitle === true) {
var captionElement = document.querySelectorAll('.captions-text .ytp-caption-segment');
captionElement.forEach(function (caption) {
subText += caption.textContent.trim() + ' ';
});
}

a.download = (ImprovedTube.videoId() || location.href.match) + '-' + new Date(ImprovedTube.elements.player.getCurrentTime() * 1000).toISOString().substr(11, 8).replace(/:/g, '-') + '-' + ImprovedTube.videoTitle() + '.png';
a.download = (ImprovedTube.videoId() || location.href.match) + '-' + new Date(ImprovedTube.elements.player.getCurrentTime() * 1000).toISOString().substr(11, 8).replace(/:/g, '-') + '-' + ImprovedTube.videoTitle() + (subText ? '-' + subText.trim() : '') + '.png';

a.click();
} else {
Expand Down
5 changes: 5 additions & 0 deletions menu/skeleton-parts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ extension.skeleton.main.layers.section.player.on.click = {
component: 'switch',
text: 'subtitles'
},
embed_subtitle: {
component: 'switch',
text: 'Embed subtitle on screenshots',
value:true,
},
subtitles_language: {
component: 'select',
text: 'language',
Expand Down

0 comments on commit 2d2ee8b

Please sign in to comment.