diff --git a/build/manifest3Firefox.json b/build/manifest3Firefox.json new file mode 100644 index 000000000..0ecc1f22d --- /dev/null +++ b/build/manifest3Firefox.json @@ -0,0 +1,93 @@ +{ + "manifest_version": 3, + "short_name": "ImprovedTube", + "name": "'Improve YouTube!' 🎧 (for YouTube & Videos)", + "description": "__MSG_description_ext__", + "version": "4.1077", + "default_locale": "en", + "icons": { + "128": "menu/icons/128.png", + "16": "menu/icons/16.png", + "32": "menu/icons/32.png", + "48": "menu/icons/48.png" + }, + "browser_specific_settings": { + "gecko": { + "id": "{3c6bf0cc-3ae2-42fb-9993-0d33104fdcaf}" + } + }, + "background": { + "background.scripts": "background.js", + "scripts": [ "background.js" ] + }, + "action": { + "default_popup": "menu/index.html", + "default_area": "navbar" + }, + "options_page": "menu/index.html", + "options_ui": { + "page": "menu/index.html" + }, + "content_scripts": [ + { + "all_frames": true, + "css": [ + "js&css/extension/www.youtube.com/styles.css", + "js&css/extension/www.youtube.com/night-mode/night-mode.css", + "js&css/extension/www.youtube.com/general/general.css", + "js&css/extension/www.youtube.com/appearance/header/header.css", + "js&css/extension/www.youtube.com/appearance/player/player.css", + "js&css/extension/www.youtube.com/appearance/details/details.css", + "js&css/extension/www.youtube.com/appearance/sidebar/sidebar.css", + "js&css/extension/www.youtube.com/appearance/comments/comments.css" + ], + "exclude_matches": [ + "https://www.youtube.com/audiolibrary/*", + "https://www.youtube.com/tv*" + ], + "js": [ + "js&css/extension/core.js", + "js&css/extension/functions.js", + "js&css/extension/www.youtube.com/night-mode/night-mode.js", + "js&css/extension/www.youtube.com/general/general.js", + "js&css/extension/www.youtube.com/appearance/sidebar/sidebar.js", + "js&css/extension/www.youtube.com/appearance/comments/comments.js", + "js&css/extension/init.js" + ], + "matches": [ + "https://www.youtube.com/*" + ], + "run_at": "document_start" + } + ], + "host_permissions": [ "https://www.youtube.com/*" ], + "optional_permissions": [ + "downloads" + ], + "permissions": [ + "contextMenus", + "storage" + ], + "web_accessible_resources": [ + { + "resources": [ + "menu/index.html", + "js&css/web-accessible/core.js", + "js&css/web-accessible/functions.js", + "js&css/web-accessible/www.youtube.com/appearance.js", + "js&css/web-accessible/www.youtube.com/player.js", + "js&css/web-accessible/www.youtube.com/themes.js", + "js&css/web-accessible/www.youtube.com/playlist.js", + "js&css/web-accessible/www.youtube.com/channel.js", + "js&css/web-accessible/www.youtube.com/shortcuts.js", + "js&css/web-accessible/www.youtube.com/blocklist.js", + "js&css/web-accessible/www.youtube.com/settings.js", + "js&css/web-accessible/init.js", + "menu/icons/48.png" + ], + "matches": [ + "https://www.youtube.com/*" + ] + } + ] +} diff --git a/js&css/extension/functions.js b/js&css/extension/functions.js index cc7ac242e..4b6c9f742 100644 --- a/js&css/extension/functions.js +++ b/js&css/extension/functions.js @@ -5,4 +5,5 @@ --------------------------------------------------------------*/ extension.functions.getUrlParameter = function (url, parameter) { var match = url.match(new RegExp('(\\?|\\&)' + parameter + '=[^&]+')); - if (match) {return match[0].substr(3);}}; \ No newline at end of file + if (match) {return match[0].substr(3);} +}; \ No newline at end of file diff --git a/js&css/extension/www.youtube.com/general/general.js b/js&css/extension/www.youtube.com/general/general.js index 374627927..ca9f80a45 100644 --- a/js&css/extension/www.youtube.com/general/general.js +++ b/js&css/extension/www.youtube.com/general/general.js @@ -356,7 +356,8 @@ extension.features.markWatchedVideos = function (anything) { target.itMarkWatchedVideosButton.appendChild(svg); target.itMarkWatchedVideosButton.appendChild(svg2); if (extension.storage.get('watched') && extension.storage.get('watched')[id]) { - target.itMarkWatchedVideosButton.setAttribute('watched', '')}; + target.itMarkWatchedVideosButton.setAttribute('watched', '') + }; target.appendChild(target.itMarkWatchedVideosButton); target.itMarkWatchedVideosButton.addEventListener('click', function (event) { var id = this.dataset.id, @@ -379,7 +380,8 @@ extension.features.markWatchedVideos = function (anything) { chrome.storage.local.set({ watched: extension.storage.get('watched') - });}); + }); + }); } else { var button = target.itMarkWatchedVideosButton; diff --git a/js&css/web-accessible/core.js b/js&css/web-accessible/core.js index e0546cc26..ad7aeb566 100644 --- a/js&css/web-accessible/core.js +++ b/js&css/web-accessible/core.js @@ -231,7 +231,7 @@ document.addEventListener('it-message-from-extension', function () { case 'playerForcedPlaybackSpeed': if (ImprovedTube.storage.player_forced_playback_speed === true) { ImprovedTube.elements.player.setPlaybackRate(Number(ImprovedTube.storage.player_playback_speed)); - ImprovedTube.elements.player.querySelector('video').playbackRate = Number(ImprovedTube.storage.player_playback_speed); + ImprovedTube.elements.player.querySelector('video').playbackRate = Number(ImprovedTube.storage.player_playback_speed).toFixed(2); } else if (ImprovedTube.storage.player_forced_playback_speed === false) { ImprovedTube.elements.player.setPlaybackRate(1); ImprovedTube.elements.player.querySelector('video').playbackRate = 1; @@ -397,7 +397,8 @@ document.addEventListener('it-message-from-extension', function () { break case 'playerlistUpNextAutoplay': if (this.storage.playlist_up_next_autoplay !== false) { - if (playlistData.currentIndex != playlistData.localCurrentIndex) { playlistData.currentIndex = playlistData.localCurrentIndex;} } + if (playlistData.currentIndex != playlistData.localCurrentIndex) { playlistData.currentIndex = playlistData.localCurrentIndex;} + } break } diff --git a/js&css/web-accessible/functions.js b/js&css/web-accessible/functions.js index eb4d029ac..da3c07995 100644 --- a/js&css/web-accessible/functions.js +++ b/js&css/web-accessible/functions.js @@ -129,8 +129,7 @@ ImprovedTube.ytElementsHandler = function (node) { this.improvedtubeYoutubeIcon(); } - } - else if (name === 'TP-YT-APP-DRAWER') { + } else if (name === 'TP-YT-APP-DRAWER') { if (!this.elements.app_drawer) { this.elements.app_drawer = {start: node.querySelector('div#header'), logo: node.querySelector('a#logo') @@ -416,9 +415,27 @@ ImprovedTube.playerOnEnded = function (event) { ImprovedTube.played_time = 0; }; +// https://github.com/code-charity/youtube/pull/2431 +ImprovedTube.onkeydown = function () { + ImprovedTube.pauseWhileTypingOnYoutube() + window.addEventListener('keydown', function () { + ImprovedTube.user_interacted = true; + }, true); +}; + +ImprovedTube.onmousedown = function (event) { + window.addEventListener('mousedown', function (event) { + ImprovedTube.user_interacted = true; + }, true); +}; + +/* ImprovedTube.onkeydown = function () { ImprovedTube.pauseWhileTypingOnYoutube() window.addEventListener('keydown', function () { + if (!ImprovedTube.user_interacted) { + setTimeout(function () {ImprovedTube.user_interacted = true}, 2500); + } if (ImprovedTube.elements.player && ImprovedTube.elements.player.classList.contains('ad-showing') === false) { ImprovedTube.user_interacted = true; } @@ -428,7 +445,7 @@ ImprovedTube.onkeydown = function () { ImprovedTube.onmousedown = function () { window.addEventListener('mousedown', function (event) { if (!ImprovedTube.user_interacted) { - setTimeout(function () {ImprovedTube.user_interacted = true}, 3000); + setTimeout(function () {ImprovedTube.user_interacted = true}, 2500); if (ImprovedTube.elements.player && ImprovedTube.elements.player.classList.contains('ad-showing') === false) { var path = event.composedPath(); for (var i = 0, l = path.length; i < l; i++) { @@ -441,6 +458,7 @@ ImprovedTube.onmousedown = function () { } }, true); }; +*/ ImprovedTube.getParam = function (query, name) { var params = query.split('&'), diff --git a/js&css/web-accessible/www.youtube.com/channel.js b/js&css/web-accessible/www.youtube.com/channel.js index f341886eb..084139b33 100644 --- a/js&css/web-accessible/www.youtube.com/channel.js +++ b/js&css/web-accessible/www.youtube.com/channel.js @@ -61,8 +61,8 @@ ImprovedTube.channelCompactTheme = function () { document.querySelector("#sections #items") ? styleWithListeners() : styleWithInterval(); } else if (compact.hasApplied) { //cleanup - try {clearInterval(compact.listener)} - catch (err) {console.log("ERR: We couldn't clear listener. Reload page")} + try {clearInterval(compact.listener) + } catch (err) {console.log("ERR: We couldn't clear listener. Reload page")} if (compact.eventHandlerFns.length) removeListeners(); if (compact.styles.length) removeStyles() compact = {} @@ -92,8 +92,7 @@ ImprovedTube.channelCompactTheme = function () { if (!isCompact) { sub.style.display = "none" isCompact = true - } - else { + } else { sub.style.display = "" isCompact = false } diff --git a/js&css/web-accessible/www.youtube.com/player.js b/js&css/web-accessible/www.youtube.com/player.js index 3b2222d0e..20f913590 100644 --- a/js&css/web-accessible/www.youtube.com/player.js +++ b/js&css/web-accessible/www.youtube.com/player.js @@ -9,14 +9,14 @@ ImprovedTube.autoplayDisable = function (videoElement) { if (this.video_url !== location.href) { this.user_interacted = false; } - // if (there is a player) and (no user clicks) and (no ads playing) + //if (there is a player) and (no user clicks) and (no ads playing) // and( ((auto play is off and it is not in a playlist) // or (playlist auto play is off and in a playlist)) // or (we are in a channel and the channel trailer autoplay is off) ) - if (player && !this.user_interacted // (=user didnt click or type) - & !player.classList.contains('ad-showing') // (=no ads playing, needs an update?) - && ((location.href.includes('/watch?') // #1703 // (=video page) + if (player && !this.user_interacted // (=user didnt click or type) + && !player.classList.contains('ad-showing') // (=no ads playing, needs an update?) + && ((location.href.includes('/watch?') // #1703 // (=video page) // player_autoplay_disable & not playlist && (this.storage.player_autoplay_disable && !location.href.includes('list=')) // !playlist_autoplay & playlist @@ -877,8 +877,7 @@ ImprovedTube.playerCinemaModeButton = function () { player.style.zIndex = 1; svg.parentNode.style.opacity = 0.64; svg.parentNode.style.zIndex = 1; - } - else { + } else { player.style.zIndex = 10000; svg.parentNode.style.opacity = 1; } @@ -936,55 +935,56 @@ ImprovedTube.playerCinemaModeEnable = function () { /*------------------------------------------------------------------------------ HAMBURGER MENU ------------------------------------------------------------------------------*/ -ImprovedTube.playerHamburgerButton = function () { if (this.storage.player_hamburger_button === true) { - const videoPlayer = document.querySelector('.html5-video-player'); - - if (!videoPlayer) { - return; - } +ImprovedTube.playerHamburgerButton = function () { + if (this.storage.player_hamburger_button === true) { + const videoPlayer = document.querySelector('.html5-video-player'); - const controlsContainer = videoPlayer.querySelector('.ytp-right-controls'); + if (!videoPlayer) { + return; + } - if (!controlsContainer) { - return; - } + const controlsContainer = videoPlayer.querySelector('.ytp-right-controls'); - let hamburgerMenu = document.querySelector('.custom-hamburger-menu'); - if (!hamburgerMenu) { - hamburgerMenu = document.createElement('div'); - hamburgerMenu.className = 'custom-hamburger-menu'; - hamburgerMenu.style.position = 'absolute'; - hamburgerMenu.style.right = '0'; - hamburgerMenu.style.marginTop = '8px'; - hamburgerMenu.style.cursor = 'pointer'; + if (!controlsContainer) { + return; + } - const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); - svg.setAttributeNS(null, 'viewBox', '0 0 24 24'); - svg.setAttribute('style', 'width: 32px; height: 32px;'); + let hamburgerMenu = document.querySelector('.custom-hamburger-menu'); + if (!hamburgerMenu) { + hamburgerMenu = document.createElement('div'); + hamburgerMenu.className = 'custom-hamburger-menu'; + hamburgerMenu.style.position = 'absolute'; + hamburgerMenu.style.right = '0'; + hamburgerMenu.style.marginTop = '8px'; + hamburgerMenu.style.cursor = 'pointer'; - const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); - path.setAttributeNS(null, 'd', 'M3 18h18v-2H3v2zM3 13h18v-2H3v2zM3 6v2h18V6H3z'); - path.setAttributeNS(null, 'fill', 'white'); + const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); + svg.setAttributeNS(null, 'viewBox', '0 0 24 24'); + svg.setAttribute('style', 'width: 32px; height: 32px;'); - svg.appendChild(path); - hamburgerMenu.appendChild(svg); + const path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); + path.setAttributeNS(null, 'd', 'M3 18h18v-2H3v2zM3 13h18v-2H3v2zM3 6v2h18V6H3z'); + path.setAttributeNS(null, 'fill', 'white'); - controlsContainer.style.paddingRight = '40px'; - controlsContainer.parentNode.appendChild(hamburgerMenu); + svg.appendChild(path); + hamburgerMenu.appendChild(svg); - let controlsVisible = true; - controlsContainer.style.display = controlsVisible ? 'none' : 'flex'; - controlsVisible = false; + controlsContainer.style.paddingRight = '40px'; + controlsContainer.parentNode.appendChild(hamburgerMenu); - hamburgerMenu.addEventListener('click', function () { + let controlsVisible = true; controlsContainer.style.display = controlsVisible ? 'none' : 'flex'; - controlsVisible = !controlsVisible; + controlsVisible = false; - // Change the opacity of hamburgerMenu based on controls visibility - hamburgerMenu.style.opacity = controlsVisible ? '0.85' : '0.65'; - }); + hamburgerMenu.addEventListener('click', function () { + controlsContainer.style.display = controlsVisible ? 'none' : 'flex'; + controlsVisible = !controlsVisible; + + // Change the opacity of hamburgerMenu based on controls visibility + hamburgerMenu.style.opacity = controlsVisible ? '0.85' : '0.65'; + }); + } } -} }; /*------------------------------------------------------------------------------ POPUP PLAYER @@ -1437,61 +1437,62 @@ ImprovedTube.miniPlayer = function () { /*------------------------------------------------------------------------------ CUSTOM PAUSE FUNCTIONS ------------------------------------------------------------------------------*/ -ImprovedTube.pauseWhileTypingOnYoutube = function () { if (ImprovedTube.storage.pause_while_typing_on_youtube === true) { - var timeoutId; // Declare a variable to hold the timeout ID +ImprovedTube.pauseWhileTypingOnYoutube = function () { + if (ImprovedTube.storage.pause_while_typing_on_youtube === true) { + var timeoutId; // Declare a variable to hold the timeout ID - // Add event listener to the whole document - document.addEventListener('keydown', function (e) { + // Add event listener to the whole document + document.addEventListener('keydown', function (e) { // Check on the storage for pause_while_typing_on_youtube_storage is false - // If player is NOT in the viewport, return - if (!isPlayerInViewport()) { - return; - } + // If player is NOT in the viewport, return + if (!isPlayerInViewport()) { + return; + } - var player = ImprovedTube.elements.player; + var player = ImprovedTube.elements.player; - if (player) { - if ( - (/^[a-z0-9]$/i.test(e.key) || e.key === "Backspace") && + if (player) { + if ( + (/^[a-z0-9]$/i.test(e.key) || e.key === "Backspace") && !(e.ctrlKey && (e.key === "c" || e.key === "x" || e.key === "a")) && - ( document.activeElement.tagName === "INPUT" || document.activeElement.tagName === "TEXTAREA" || document.activeElement.tagName === "DIV" )) - { + ( document.activeElement.tagName === "INPUT" || document.activeElement.tagName === "TEXTAREA" || document.activeElement.tagName === "DIV" )) { // Pause the video // Check if player is paused - if (!player.paused) { - player.pauseVideo(); - } + if (!player.paused) { + player.pauseVideo(); + } - // Clear any existing timeout - if (timeoutId) { - clearTimeout(timeoutId); - } + // Clear any existing timeout + if (timeoutId) { + clearTimeout(timeoutId); + } - // Set a new timeout to play the video after 1 second - timeoutId = setTimeout(function () { - player.playVideo(); - }, 2000); // 2000 milliseconds = 2 seconds + // Set a new timeout to play the video after 1 second + timeoutId = setTimeout(function () { + player.playVideo(); + }, 2000); // 2000 milliseconds = 2 seconds + } } - } - }); + }); - function isPlayerInViewport () { - var player = ImprovedTube.elements.player; - if (player) { - var rect = player.getBoundingClientRect(); - var windowHeight = (window.innerHeight || document.documentElement.clientHeight); - var windowWidth = (window.innerWidth || document.documentElement.clientWidth); + function isPlayerInViewport () { + var player = ImprovedTube.elements.player; + if (player) { + var rect = player.getBoundingClientRect(); + var windowHeight = (window.innerHeight || document.documentElement.clientHeight); + var windowWidth = (window.innerWidth || document.documentElement.clientWidth); - // Check if the player is in the viewport - return ( - rect.top != 0 && + // Check if the player is in the viewport + return ( + rect.top != 0 && rect.left != 0 && rect.bottom <= windowHeight && rect.right <= windowWidth - ); + ); + } + return false; } - return false; - } -}}; + } +}; \ No newline at end of file diff --git a/js&css/web-accessible/www.youtube.com/playlist.js b/js&css/web-accessible/www.youtube.com/playlist.js index 3f08d54c4..79628849f 100644 --- a/js&css/web-accessible/www.youtube.com/playlist.js +++ b/js&css/web-accessible/www.youtube.com/playlist.js @@ -10,9 +10,9 @@ ImprovedTube.playlistUpNextAutoplay = function () { if (this.storage.playlist_up && playlistData.currentIndex && playlistData.totalVideos && playlistData.localCurrentIndex) { - playlistData.currentIndex = playlistData.totalVideos; + playlistData.currentIndex = playlistData.totalVideos; + } } -} }; /*------------------------------------------------------------------------------ 4.5.2 REVERSE @@ -183,11 +183,12 @@ ImprovedTube.playlistPopupCreateButton = function (playlistID, altButtonStyle, c } : function () { let width = ImprovedTube.elements.player.offsetWidth * 0.7 ?? innerWidth * 0.45; let height = ImprovedTube.elements.player.offsetHeight * 0.7 ?? innerHeight * 0.45; - if (!ImprovedTube.elements.player) { - shorts = /short/.test(this.parentElement.href); - if ( width / height < 1 ) { vertical = true } else { vertical = false } - if ( !vertical && shorts ) { width = height * 0.6} - if ( vertical && !shorts ) { height = width * 0.6} } + if (!ImprovedTube.elements.player) { + shorts = /short/.test(this.parentElement.href); + if ( width / height < 1 ) { vertical = true } else { vertical = false } + if ( !vertical && shorts ) { width = height * 0.6} + if ( vertical && !shorts ) { height = width * 0.6} + } "use strict"; window.open(`${location.protocol}//www.youtube.com/embed/videoseries?autoplay=${ImprovedTube.storage.player_autoplay_disable ? '0' : '1'}&list=${this.dataset.list}`, '_blank', `directories=no,toolbar=no,location=no,menubar=no,status=no,titlebar=no,scrollbars=no,resizable=no,width=${width / 3},height=${height / 3}`); //~ change focused tab to URL-less popup @@ -245,4 +246,5 @@ ImprovedTube.playlistPopup = function () { else panelItemButtons.appendChild(this.elements.buttons['it-popup-playlist-button-panel'] = this.playlistPopupCreateButton(playlistID, true, true)); } else if (playlistID != null && this.elements.buttons['it-popup-playlist-button-panel'].dataset.list !== playlistID) this.elements.buttons['it-popup-playlist-button-panel'].dataset.list = playlistID; } catch (error) { console.error("Error appending playlist button panel:", error);} - }}; + } +}; diff --git a/js&css/web-accessible/www.youtube.com/settings.js b/js&css/web-accessible/www.youtube.com/settings.js index 20bd387dd..7771cfb3e 100644 --- a/js&css/web-accessible/www.youtube.com/settings.js +++ b/js&css/web-accessible/www.youtube.com/settings.js @@ -113,8 +113,7 @@ ImprovedTube.improvedtubeYoutubeIcon = function () { if (option === 'header_left') { if (this.storage.header_position === 'normal' && this.elements.masthead.start) { this.elements.masthead.start.appendChild(button); - } - else if (this.elements.app_drawer.start) { + } else if (this.elements.app_drawer.start) { this.elements.app_drawer.start.appendChild(button); } } else if (option === 'header_right') { diff --git a/js&css/web-accessible/www.youtube.com/shortcuts.js b/js&css/web-accessible/www.youtube.com/shortcuts.js index 583e66150..5b052857a 100644 --- a/js&css/web-accessible/www.youtube.com/shortcuts.js +++ b/js&css/web-accessible/www.youtube.com/shortcuts.js @@ -332,36 +332,36 @@ ImprovedTube.shortcutScreenshot = ImprovedTube.screenshot; /*------------------------------------------------------------------------------ 4.7.16 INCREASE PLAYBACK SPEED ------------------------------------------------------------------------------*/ -ImprovedTube.shortcutIncreasePlaybackSpeed = function () { const value = Number(this.storage.shortcuts_playback_speed_step) || .05, +ImprovedTube.shortcutIncreasePlaybackSpeed = function () { value = Number(this.storage.shortcuts_playback_speed_step) || .05; // original: const video = this.elements.video; if (video) {if ( video.playbackRate){ - if ( video.playbackRate < 1 && video.playbackRate > 1-ImprovedTube.storage.shortcut_playback_speed_step ) { + if ( video.playbackRate < 1 && video.playbackRate > 1-ImprovedTube.storage.shortcuts_playback_speed_step ) { video.playbackRate = 1 } // aligning at 1.0 instead of passing by 1.0 - else { video.playbackRate = Math.min(Math.max(Number((video.playbackRate + Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1),16); + else { video.playbackRate = Math.min(Math.max(Number((video.playbackRate + Number(ImprovedTube.storage.shortcuts_playback_speed_step || .05)).toFixed(2)), .1),16); } // Firefox doesnt limit speed to 16x. We can allow more in Firefox if people ask ImprovedTube.showStatus(video.playbackRate); } else { // alternative: const player = this.elements.player; if (player) { - if ( player.getPlaybackRate() < 1 && player.getPlaybackRate() > 1-ImprovedTube.storage.shortcut_playback_speed_step ) { + if ( player.getPlaybackRate() < 1 && player.getPlaybackRate() > 1-ImprovedTube.storage.shortcuts_playback_speed_step ) { player.setPlaybackRate(1) } // aligning at 1.0 instead of passing by 1.0 - else { player.setPlaybackRate(Math.min(Math.max(Number((player.getPlaybackRate() + Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1),16)) + else { player.setPlaybackRate(Math.min(Math.max(Number((player.getPlaybackRate() + Number(ImprovedTube.storage.shortcuts_playback_speed_step || .05)).toFixed(2)), .1),16)) } ImprovedTube.showStatus(player.getPlaybackRate()); }}}}; /*------------------------------------------------------------------------------ 4.7.17 DECREASE PLAYBACK SPEED ------------------------------------------------------------------------------*/ -ImprovedTube.shortcutDecreasePlaybackSpeed = function () { const value = Number(ImprovedTube.storage.shortcut_playback_speed_step) || .05; +ImprovedTube.shortcutDecreasePlaybackSpeed = function () { value = Number(ImprovedTube.storage.shortcuts_playback_speed_step) || .05; // original: const video = this.elements.video; if (video) { if (video.playbackRate){ - if ( video.playbackRate < 0.1+ImprovedTube.storage.shortcut_playback_speed_step ) { + if ( video.playbackRate < 0.1+ImprovedTube.storage.shortcuts_playback_speed_step ) { video.playbackRate = video.playbackRate*0.7 } // slow down near minimum - else { video.playbackRate = Math.max(Number((video.playbackRate - Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1); + else { video.playbackRate = Math.max(Number((video.playbackRate - Number(ImprovedTube.storage.shortcuts_playback_speed_step || .05)).toFixed(2)), .1); } ImprovedTube.showStatus(video.playbackRate); } @@ -369,9 +369,9 @@ ImprovedTube.shortcutDecreasePlaybackSpeed = function () { const value = Number( // alternative: const player = this.elements.player; if (player) { - if ( player.getPlaybackRate() < 0.1+ImprovedTube.storage.shortcut_playback_speed_step ) { + if ( player.getPlaybackRate() < 0.1+ImprovedTube.storage.shortcuts_playback_speed_step ) { player.setPlaybackRate(player.getPlaybackRate()*0.7) } // slow down near minimum - else { player.setPlaybackRate(Math.max(Number((player.getPlaybackRate() - Number(ImprovedTube.storage.shortcut_playback_speed_step || .05)).toFixed(2)), .1)) + else { player.setPlaybackRate(Math.max(Number((player.getPlaybackRate() - Number(ImprovedTube.storage.shortcuts_playback_speed_step || .05)).toFixed(2)), .1)) } ImprovedTube.showStatus(player.getPlaybackRate()); }}}}; diff --git a/manifest.json b/manifest.json index 0ecc1f22d..81e1d9e1e 100644 --- a/manifest.json +++ b/manifest.json @@ -11,14 +11,8 @@ "32": "menu/icons/32.png", "48": "menu/icons/48.png" }, - "browser_specific_settings": { - "gecko": { - "id": "{3c6bf0cc-3ae2-42fb-9993-0d33104fdcaf}" - } - }, "background": { - "background.scripts": "background.js", - "scripts": [ "background.js" ] + "background.scripts": "background.js" }, "action": { "default_popup": "menu/index.html", diff --git a/menu/index.js b/menu/index.js index 00617bcfb..24238322a 100644 --- a/menu/index.js +++ b/menu/index.js @@ -7,7 +7,7 @@ --------------------------------------------------------------*/ satus.storage.import(function (items) { var language = items.language; - if (!language || language === 'default') { language = false;} + if (!language || language === 'default') { language = false;} satus.locale.import(language, function () { satus.render(extension.skeleton); diff --git a/menu/satus.js b/menu/satus.js index 556c651db..1295a22b9 100644 --- a/menu/satus.js +++ b/menu/satus.js @@ -252,10 +252,10 @@ satus.isNumber = function (t) { return (typeof t ==='number' && !isNaN(t)); }; satus.isObject = function (t) { return (t instanceof Object && t !== null); }; satus.isElement = function (t) { return (t instanceof Element || t instanceof HTMLDocument); }; satus.isNodeList = function (t) { return t instanceof NodeList; }; -satus.isBoolean = function (t) { return (t === false || t === true); }; +satus.isBoolean = function (t) { return (t === false || t === true); }; /*---LOG------------------------------------------------------*/ -satus.log = function () { console.log.apply(null, arguments);}; +satus.log = function () { console.log.apply(null, arguments);}; /*-------------------------------------------------------------- @@ -1050,27 +1050,29 @@ satus.locale.import = function (code, callback, path) { importLocale(language, () => importLocale('en', callback)); } } else { // try chrome://settings/languages: - try {chrome.i18n.getAcceptLanguages(function (languages) { - languages = languages.map(language => language.replace('-', '_')); - for (let i = languages.length - 1; i >= 0; i--) { - if (languages[i].includes('_')) { - let languageWithoutCountryCode = languages[i].substring(0, 2); - - if (!languages.includes(languageWithoutCountryCode)) { - languages.splice(i + 1, 0, languageWithoutCountryCode); + try { + chrome.i18n.getAcceptLanguages(function (languages) { + languages = languages.map(language => language.replace('-', '_')); + for (let i = languages.length - 1; i >= 0; i--) { + if (languages[i].includes('_')) { + let languageWithoutCountryCode = languages[i].substring(0, 2); + + if (!languages.includes(languageWithoutCountryCode)) { + languages.splice(i + 1, 0, languageWithoutCountryCode); + } } } - } - languages.includes("en") || languages.push("en"); + languages.includes("en") || languages.push("en"); - languages.forEach((language, index) => index === languages.length - 1 ? importLocale(language, callback) : importLocale(language, () => {})); + languages.forEach((language, index) => index === languages.length - 1 ? importLocale(language, callback) : importLocale(language, () => {})); /* equals: languages.length === 1 && importLocale(languages[0], callback); languages.length === 2 && importLocale(languages[0], () => importLocale(languages[1], callback)); languages.length === 3 && importLocale(languages[0], () => importLocale(languages[1], () => importLocale(languages[2], callback))); ... */ // console.log(languages); - });} catch (error) { + }); + } catch (error) { // Finally, if code nor chrome://settings/languages are available, use window.navigator.language: let language = window.navigator.language.replace('-', '_'); diff --git a/menu/skeleton-parts/appearance.js b/menu/skeleton-parts/appearance.js index 9711cbef8..b3da19d60 100644 --- a/menu/skeleton-parts/appearance.js +++ b/menu/skeleton-parts/appearance.js @@ -838,10 +838,11 @@ extension.skeleton.main.layers.section.appearance.on.click.sidebar = { click: function () { setTimeout(() => { if (satus.storage.get('related_videos')==="Titles" - && satus.storage.get("relatedVideosPrev") ==="Titles") {if (!satus.storage.get('thumbnails_right')) { - this.nextSibling.nextSibling.click(); - satus.storage.set('relatedVideosPrev', "notTitles") - } + && satus.storage.get("relatedVideosPrev") ==="Titles") { + if (!satus.storage.get('thumbnails_right')) { + this.nextSibling.nextSibling.click(); + satus.storage.set('relatedVideosPrev', "notTitles") + } } }, 650) @@ -866,13 +867,15 @@ extension.skeleton.main.layers.section.appearance.on.click.sidebar = { value: false, id: 'transcript', on: { - click: function () { setTimeout(() => { - if (satus.storage.get('transcript')) { - if (satus.storage.get('no_page_margin')) { - this.nextSibling.nextSibling.click(); + click: function () { + setTimeout(() => { + if (satus.storage.get('transcript')) { + if (satus.storage.get('no_page_margin')) { + this.nextSibling.nextSibling.click(); + } } - } - }, 250); } + }, 250); + } } }, compact_spacing: { @@ -886,13 +889,15 @@ extension.skeleton.main.layers.section.appearance.on.click.sidebar = { value: false, on: { - click: function () { setTimeout(() => { - if (satus.storage.get('no_page_margin')) { - if (satus.storage.get('transcript')) { - this.previousSibling.previousSibling.click(); + click: function () { + setTimeout(() => { + if (satus.storage.get('no_page_margin')) { + if (satus.storage.get('transcript')) { + this.previousSibling.previousSibling.click(); + } } - } - }, 250); } + }, 250); + } } }, chapters: { diff --git a/menu/skeleton-parts/general.js b/menu/skeleton-parts/general.js index 4fdf67374..a12841953 100644 --- a/menu/skeleton-parts/general.js +++ b/menu/skeleton-parts/general.js @@ -229,13 +229,15 @@ extension.skeleton.main.layers.section.general = { component: 'switch', text: 'markWatchedVideos', on: { - click: function () { setTimeout(() => { - if (satus.storage.get('mark_watched_videos')) { - if (!satus.storage.get('track_watched_videos')) { - this.nextSibling.click(); + click: function () { + setTimeout(() => { + if (satus.storage.get('mark_watched_videos')) { + if (!satus.storage.get('track_watched_videos')) { + this.nextSibling.click(); + } } - } - }, 250); } + }, 250); + } } }, track_watched_videos: {