Skip to content

Commit

Permalink
Update player.js try to catch silent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
raszpl authored Jun 15, 2024
1 parent 77bd6b6 commit 2803bf1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions js&css/web-accessible/www.youtube.com/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,24 @@ ImprovedTube.screenshot = function () {

cvs.toBlob(function (blob) {
if (ImprovedTube.storage.player_screenshot_save_as == 'clipboard') {
console.log(blob);
window.focus();
navigator.clipboard.write([
new ClipboardItem({
'image/png': blob
})
]);
])
.then(function () { console.log("ImprovedTube: Screeeeeeenshot tada!"); })
.catch(function (error) {
console.log('ImprovedTube screenshot: ', error);
alert('ImprovedTube Screenshot to Clipboard error. Details in Debug Console.');
});
} else {
let a = document.createElement('a');
a.href = URL.createObjectURL(blob);
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();
console.log("ImprovedTube: Screeeeeeenshot tada!");
}
console.log("ImprovedTube: Screeeeeeenshot tada!");
});
};

Expand Down

0 comments on commit 2803bf1

Please sign in to comment.