diff --git a/background.js b/background.js index f04135b53..5d137d65b 100644 --- a/background.js +++ b/background.js @@ -9,10 +9,25 @@ # Message listener # Uninstall URL --------------------------------------------------------------*/ +/* +// For Manifest3: +/*-----# Persistent Serviceworker: + "Manifest2 Background.js"-----*/ + // Periodic "keep-alive" message every 29.5 seconds +// const keepAliveInterval = setInterval(() => chrome.runtime.sendMessage({ status: 'keep-alive' }), 29.5 * 1000); + +/* Sidepanel Option */ +/* + chrome.storage.local.get('improvedTubeSidebar', function (result) { + if ( result.improvedTubeSidebar) { if ( result.ImprovedTubeSidebar === true) { + chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: true }) + } } else {chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: false }) } + }); + +*/ /*--------------------------- # IMPORTING OLD SETTINGS ------------------------------*/ - +-----------------------------*/ chrome.runtime.onInstalled.addListener(function (installed){ if(installed.reason == 'update'){ // var thisVersion = chrome.runtime.getManifest().version; @@ -29,7 +44,7 @@ chrome.storage.local.get('limit_page_width', function (result) { }}); } }); -} + } else if(installed.reason == 'install'){ if(navigator.userAgent.indexOf("Firefox") != -1){chrome.storage.local.set({below_player_pip: false})}; if(navigator.userAgent.indexOf("Safari") != -1){chrome.storage.local.set({below_player_pip: false})}; @@ -45,11 +60,13 @@ if(navigator.userAgent.indexOf("Safari") != -1){chrome.storage.local.set({below_ --------------------------------------------------------------*/ function getLocale(language, callback) { language = language.replace('-', '_'); - - fetch('_locales/' + language + '/messages.json').then(function (response) { - if (response.ok) { - response.json().then(callback); - } else { + fetch('_locales/' + language.substring(0,2) + '/messages.json').then(function (response) { + if (response.ok) {response.json().then(callback); + } else { + fetch('_locales/' + language.substring(0,2) + '/messages.json').then(function (response) { + if (response.ok) { response.json().then(callback); + } else { getLocale('en', callback); } }).catch(function (){getLocale('en', callback); + }); getLocale('en', callback); } }).catch(function () { @@ -63,14 +80,12 @@ function updateContextMenu(language) { if (!language) { language = chrome.i18n.getUILanguage(); } - getLocale(language, function (response) { var items = [ 'donate', 'rateMe', 'GitHub' ]; - chrome.contextMenus.removeAll(); for (var i = 0; i < 3; i++) { @@ -86,10 +101,10 @@ function updateContextMenu(language) { chrome.contextMenus.create({ id: String(i), title: text, - contexts: ['browser_action'] //manifest3 : 'action' + // contexts: ['action'] //manifest3 + contexts: ['browser_action'] //manifest2 }); } - chrome.contextMenus.onClicked.addListener(function (info) { var links = [ 'https://www.improvedtube.com/donate', @@ -101,28 +116,22 @@ function updateContextMenu(language) { }); }); } - chrome.runtime.onInstalled.addListener(function (details) { chrome.storage.local.get(function (items) { var language = items.language; - updateContextMenu(language); }); }); chrome.storage.onChanged.addListener(function (changes) { for (var key in changes) { - if (key === 'language') { - updateContextMenu(changes[key].newValue); - } + if (key === 'language') {updateContextMenu(changes[key].newValue);} + if (key === 'improvedTubeSidebar') { chrome.sidePanel.setPanelBehavior({ openPanelOnActionClick: changes[key].newValue }); } } }); - - /*-------------------------------------------------------------- # TAB FOCUS/BLUR --------------------------------------------------------------*/ - chrome.tabs.onActivated.addListener(function (activeInfo) { chrome.tabs.sendMessage(activeInfo.tabId, { action: 'focus' @@ -142,7 +151,6 @@ chrome.tabs.onActivated.addListener(function (activeInfo) { } }); }); - chrome.windows.onFocusChanged.addListener(function (windowId) { chrome.windows.getAll(function (windows) { for (var i = 0, l = windows.length; i < l; i++) { @@ -180,12 +188,9 @@ chrome.windows.onFocusChanged.addListener(function (windowId) { } }); }); - - /*-------------------------------------------------------------- # MESSAGE LISTENER --------------------------------------------------------------*/ - chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { var name = request.name; @@ -216,7 +221,6 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) { }); let prevTabsLength = 0; - chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) { var action = message.action || message; @@ -252,8 +256,7 @@ try{ sendResponse({ hostname: new URL(sender.url).hostname, tabId: sender.tab.id }); } catch (error) { console.error("invalid url?", error);} - } else if (action === 'fixPopup') - { + } else if (action === 'fixPopup') { //~ get the current focused tab and convert it to a URL-less popup (with same state and size) chrome.windows.getLastFocused(w => { chrome.tabs.query({ @@ -265,15 +268,14 @@ try{ sendResponse({ state: w.state, width: parseInt(message.width, 10), height: parseInt(message.height, 10), - left: -3, - top: 3 + left: 0, + top: 20 }; if (tID) {data.tabId = tID;} - chrome.windows.create(data, pw => { }); + chrome.windows.create(data, pw => { }); - //append to title - + //append to title? chrome.tabs.onUpdated.addListener(function listener(tabId, changeInfo) { if (tabId === tID && changeInfo.status === 'complete' && !message.title.startsWith("undefined")){ chrome.tabs.onUpdated.removeListener(listener); @@ -286,7 +288,6 @@ try{ sendResponse({ }; }); - /*------ search results in new tab --------- chrome.storage.local.get('open_new_tab', function (result) {if (result.open_new_tab === true){ @@ -299,8 +300,5 @@ chrome.runtime.onMessage.addListener(function (request) { }}); */ -/*-------------------------------------------------------------- -# UNINSTALL URL ---------------------------------------------------------------*/ - +/*-----# UNINSTALL URL-----------------------------------*/ chrome.runtime.setUninstallURL('https://improvedtube.com/uninstalled'); \ No newline at end of file diff --git a/manifest.json b/manifest.json index 569976bb7..0b9fcb41a 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "short_name" : "ImprovedTube", "name": "'Improve YouTube!' 🎧 (for YouTube & Videos)", "description": "__MSG_description_ext__", - "version": "4.506", + "version": "4.580", "default_locale": "en", "icons": { "16": "stuff/icons/16.png", @@ -83,3 +83,4 @@ "js&css/web-accessible/mutations.js" ] } + diff --git a/manifest3.json b/manifest3.json index 166187a51..00bb780de 100644 --- a/manifest3.json +++ b/manifest3.json @@ -1,9 +1,9 @@ { "manifest_version": 3, "short_name" : "ImprovedTube", - "name": "'Improve YouTube!'🎧(for YouTube & Videos)", + "name": "'Improve YouTube!' 🎧 (for YouTube & Videos)", "description": "__MSG_description_ext__", - "version": "4.6", + "version": "4.620", "default_locale": "en", "icons": { "128": "stuff/icons/128.png", @@ -15,9 +15,16 @@ "service_worker": "background.js" }, "action": { - "default_popup": "menu/index.html" + "default_popup": "menu/index.html", + "default_area": "navbar" }, + "side_panel": { + "default_path": "menu/index.html" + }, "options_page": "menu/index.html", + "options_ui": { + "page": "menu/index.html" + }, "content_scripts": [ { "all_frames": true, @@ -36,8 +43,7 @@ "https://www.youtube.com/audiolibrary/*", "https://www.youtube.com/tv*" ], - "js": [ - "js&css/satus.js", + "js": [ "js&css/extension/core.js", "js&css/extension/functions.js", "js&css/extension/www.youtube.com/night-mode/night-mode.js", @@ -60,7 +66,8 @@ ], "permissions": [ "contextMenus", - "storage" + "storage", + "sidePanel" ], "web_accessible_resources": [ { @@ -68,9 +75,9 @@ "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/themes.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", @@ -85,3 +92,4 @@ } ] } + \ No newline at end of file diff --git a/menu/index.html b/menu/index.html index e4467e336..355b4276b 100644 --- a/menu/index.html +++ b/menu/index.html @@ -1,5 +1,5 @@ -ImprovedTube +ImprovedTube @@ -32,4 +32,3 @@ - diff --git a/menu/satus.css b/menu/satus.css index d9c057675..aa419e3c4 100644 --- a/menu/satus.css +++ b/menu/satus.css @@ -1,16 +1,15 @@ *[data-value][data-value="false"] { margin-bottom: 0; margin-top: 0; transition: margin 0.14s linear !important; } *[data-value][data-value="true"] {margin-bottom: -3px; margin-top: -1px; transition: margin 0.18s linear !important; } - .satus-button--general, .satus-button--appearance, .satus-button--player { margin-left: 9px !important; margin-right: -18px !important;} -.satus-button--themes, .satus-button--playlist, .satus-button--channel, .satus-button--shortcuts { transform: scale(0.84); margin-top: -9px !important; margin-left: -5px !important; margin-right: -27px !important;} -.satus-button--blocklist, .satus-button--analyzer { transform: scale(0.70); margin-top: -20px !important; margin-left: 75px !important; margin-right: -115px !important; } +.satus-button--themes, .satus-button--playlist, .satus-button--channel, .satus-button--shortcuts { transform: scale(0.91); margin-top: -10px !important; margin-left: -5px !important; margin-right: -28px !important;} +.satus-button--blocklist, .satus-button--analyzer { transform: scale(0.78); margin-top: -22px !important; margin-left: 110px !important; margin-right: -150px !important; } /*-------------------------------------------------------------- # SCROLLBAR --------------------------------------------------------------*/ -:where([class^='satus'])::-webkit-scrollbar { width: 4px; } -:where([class^='satus'])::-webkit-scrollbar:hover { width: 8px; } +:where([class^='satus'])::-webkit-scrollbar { width: 5px; } +/* :where([class^='satus']):hover { scrollbar-width: 9px; } :where([class^='satus'])::-webkit-scrollbar:hover { width: 9px; } */ :where([class^='satus'])::-webkit-scrollbar-thumb { background: rgba(var(--satus-light), .2); } -:where([class^='satus'])::-webkit-scrollbar-thumb:hover { background: rgba(var(--satus-light), .3); } +:where([class^='satus'])::-webkit-scrollbar-thumb:hover { background: rgba(var(--satus-light), .4); } /*-------------------------------------------------------------- # ANIMATIONS --------------------------------------------------------------*/ @@ -28,14 +27,14 @@ --------------------------------------------------------------*/ .satus-base { --satus-light: 0, 20, 82; - --satus-primary: #EE5438; + --satus-primary: #ff4148; --satus-alert-background--error: #501616; --satus-alert-border--error: 1px solid #6f1f1f; --satus-alert-foreground--error: #d77070; --satus-alert-background--success: rgb(246, 180, 101, .32); --satus-alert-border--success: 1px solid rgb(246, 180, 101, .6); --satus-alert-foreground--success: rgb(184, 115, 30); - --satus-base-background: #EFEEED; + --satus-base-background: #F4F3F2; --satus-base-foreground: #565e76; --satus-checkbox-background: #f3f4f6; --satus-checkbox-border: #dcdfe5; @@ -93,18 +92,9 @@ /*-------------------------------------------------------------- >>> NORMALIZE --------------------------------------------------------------*/ - -:where([class^='satus']) { - box-sizing: border-box; -} - -:where([class^='satus'])[hidden]:not([hidden='false']) { - display: none; -} - -:where([class^='satus'])[transparent] { - opacity: 0; -} +:where([class^='satus']){box-sizing: border-box;} +:where([class^='satus'])[hidden]:not([hidden='false']) {display: none;} +:where([class^='satus'])[transparent]{opacity:0;} /*-------------------------------------------------------------- >>> MODAL ---------------------------------------------------------------- @@ -114,12 +104,9 @@ # Variants # Vertical menu --------------------------------------------------------------*/ - - /*-------------------------------------------------------------- # CONTAINER --------------------------------------------------------------*/ - .satus-modal { position: fixed; z-index: 9; @@ -133,11 +120,9 @@ cursor: default; } - /*-------------------------------------------------------------- # SCRIM --------------------------------------------------------------*/ - .satus-modal__scrim { position: absolute; top: 0; @@ -154,11 +139,9 @@ animation: fadeOut 70ms linear forwards; } - /*-------------------------------------------------------------- # SURFACE --------------------------------------------------------------*/ - .satus-modal__surface { display: flex; overflow-y: auto; @@ -195,11 +178,9 @@ margin-left: 8px; } - /*-------------------------------------------------------------- # VARIANTS --------------------------------------------------------------*/ - /*-------------------------------------------------------------- # VERTICAL MENU --------------------------------------------------------------*/ @@ -447,11 +428,9 @@ As our Syntax markup isnt read for