Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
fix: show notification when error is encountered + always show error …
Browse files Browse the repository at this point in the history
…log in console
  • Loading branch information
madkarmaa committed Jun 11, 2024
1 parent a01fe27 commit 6a00aa1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions script.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// @supportURL https://github.com/madkarmaa/youtube-downloader
// @updateURL https://raw.githubusercontent.com/madkarmaa/youtube-downloader/main/script.user.js
// @downloadURL https://raw.githubusercontent.com/madkarmaa/youtube-downloader/main/script.user.js
// @version 3.0.0
// @version 3.0.1
// @description A simple userscript to download YouTube videos in MAX QUALITY
// @author mk_
// @match *://*.youtube.com/*
Expand All @@ -20,7 +20,7 @@
// ==/UserScript==

(async () => {
('use strict');
'use strict';

// abort if not on youtube or youtube music
if (!detectYoutubeService()) {
Expand Down Expand Up @@ -52,10 +52,9 @@

// ===== METHODS =====
function logger(level, ...args) {
if (!DEV_MODE) return;

if (level.toLowerCase() === 'info') oldILog.apply(console, ['%c[YTDL]', 'color: #f00;', ...args]);
else if (level.toLowerCase() === 'warn') oldWLog.apply(console, ['%c[YTDL]', 'color: #f00;', ...args]);
if (DEV_MODE && level.toLowerCase() === 'info') oldILog.apply(console, ['%c[YTDL]', 'color: #f00;', ...args]);
else if (DEV_MODE && level.toLowerCase() === 'warn')
oldWLog.apply(console, ['%c[YTDL]', 'color: #f00;', ...args]);
else if (level.toLowerCase() === 'error') oldELog.apply(console, ['%c[YTDL]', 'color: #f00;', ...args]);
}

Expand Down Expand Up @@ -387,6 +386,7 @@
logger('info', 'Download completed');
} catch (err) {
logger('error', JSON.parse(JSON.stringify(err)));
new Notification('Error', JSON.stringify(err), 'error', false);
}
}

Expand Down Expand Up @@ -424,6 +424,7 @@
logger('info', 'Download completed');
} catch (err) {
logger('error', JSON.parse(JSON.stringify(err)));
new Notification('Error', JSON.stringify(err), 'error', false);
}

return false;
Expand Down

0 comments on commit 6a00aa1

Please sign in to comment.