From 9bc811e9d82afe3f54471b568048bec82f593b93 Mon Sep 17 00:00:00 2001
From: 4yman <170770027+4yman-0@users.noreply.github.com>
Date: Mon, 4 Nov 2024 09:13:58 +0100
Subject: [PATCH] Use var because the original author used it
---
background.js | 34 ++---
js&css/extension/core.js | 2 +-
.../www.youtube.com/general/general.js | 22 +--
js&css/web-accessible/core.js | 12 +-
js&css/web-accessible/functions.js | 28 ++--
js&css/web-accessible/init.js | 6 +-
.../www.youtube.com/appearance.js | 64 ++++-----
.../www.youtube.com/blocklist.js | 26 ++--
.../web-accessible/www.youtube.com/channel.js | 34 ++---
.../web-accessible/www.youtube.com/player.js | 128 +++++++++---------
.../www.youtube.com/playlist.js | 26 ++--
.../www.youtube.com/settings.js | 2 +-
.../www.youtube.com/shortcuts.js | 58 ++++----
menu/satus.js | 106 +++++++--------
menu/skeleton-parts/active-features.js | 10 +-
menu/skeleton-parts/blocklist.js | 20 +--
menu/skeleton-parts/dark-light-switch.js | 8 +-
menu/skeleton-parts/general.js | 4 +-
menu/skeleton-parts/player.js | 20 +--
menu/skeleton-parts/search.js | 18 +--
menu/skeleton.js | 2 +-
tests/eslint_rules.config.mjs | 10 +-
tests/unit/core.test.js | 28 ++--
23 files changed, 334 insertions(+), 334 deletions(-)
diff --git a/background.js b/background.js
index 2d92d4c26..b86f40831 100644
--- a/background.js
+++ b/background.js
@@ -14,7 +14,7 @@
/*-----# 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);
+// var keepAliveInterval = setInterval(() => chrome.runtime.sendMessage({ status: 'keep-alive' }), 29.5 * 1000);
/* Sidepanel Option
chrome.storage.local.get('improvedTubeSidePanel', function (result) {
@@ -38,11 +38,11 @@ chrome.runtime.onInstalled.addListener(function (installed) {
// Shortcut renames:
chrome.storage.local.get(['shortcut_auto', 'shortcut_144p', 'shortcut_240p', 'shortcut_360p', 'shortcut_480p', 'shortcut_720p', 'shortcut_1080p', 'shortcut_1440p', 'shortcut_2160p', 'shortcut_2880p', 'shortcut_4320p'], function (result) {
// Validate and move to new name
- for (let [name, keys] of Object.entries(result)) {
+ for (var [name, keys] of Object.entries(result)) {
if (!keys) continue;
- let newKeys = {},
+ var newKeys = {},
newName = name.replace('shortcut_', 'shortcut_quality_');
- for (const button of ['alt', 'ctrl', 'shift', 'wheel', 'toggle']) {
+ for (var button of ['alt', 'ctrl', 'shift', 'wheel', 'toggle']) {
if (keys[button]) newKeys[button] = keys[button];
}
if (keys['keys'] && Object.keys(keys['keys'])?.length) {
@@ -54,8 +54,8 @@ chrome.runtime.onInstalled.addListener(function (installed) {
chrome.storage.local.remove(Object.keys(result));
});
chrome.storage.local.get(['volume_step', 'playback_speed_step'], function (result) {
- for (let [name, value] of Object.entries(result)) {
- let newName = 'shortcuts_' + name;
+ for (var [name, value] of Object.entries(result)) {
+ var newName = 'shortcuts_' + name;
chrome.storage.local.set({[newName]: value});
}
chrome.storage.local.remove(Object.keys(result));
@@ -140,15 +140,15 @@ function getLocale (language, callback) {
function updateContextMenu (language) {
if (!language || language === 'default') language = chrome.i18n.getUILanguage();
getLocale(language, function (response) {
- const items = [
+ var items = [
'donate',
'rateMe',
'GitHub'
];
chrome.contextMenus.removeAll();
- for (const [index, item] of items.entries()) {
- const text = response?.[item]?.message || item;
+ for (var [index, item] of items.entries()) {
+ var text = response?.[item]?.message || item;
chrome.contextMenus.create({
id: String(index),
@@ -158,7 +158,7 @@ function updateContextMenu (language) {
});
}
chrome.contextMenus.onClicked.addListener(function (info) {
- const links = [
+ var links = [
'https://www.improvedtube.com/donate',
'https://chrome.google.com/webstore/detail/improve-youtube-video-you/bnomihfieiccainjcjblhegjgglakjdd',
'https://github.com/code4charity/YouTube-Extension'
@@ -181,20 +181,20 @@ chrome.storage.onChanged.addListener(function (changes) {
/*--------------------------------------------------------------
# TAB Helper, prune stale connected tabs
--------------------------------------------------------------*/
-let tabConnected = {},
+var tabConnected = {},
tab = {},
tabPrev = {},
windowId;
function tabPrune (callback) {
chrome.tabs.query({ url: 'https://www.youtube.com/*' }).then(function (tabs) {
- let tabIds = [];
- for (let tab of tabs) {
+ var tabIds = [];
+ for (var tab of tabs) {
if (!tab.discarded && tabConnected[tab.id]) {
tabIds.push(tab.id);
}
}
- for (let id in tabConnected) {
+ for (var id in tabConnected) {
if (!tabIds.includes(Number(id))) {
delete tabConnected[id];
}
@@ -249,7 +249,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
switch (message.action || message.name || message) {
case 'play':
tabPrune(function () {
- for (let id in tabConnected) {
+ for (var id in tabConnected) {
id = Number(id);
if (id != sender.tab.id) {
chrome.tabs.sendMessage(id, {action: "another-video-started-playing"});
@@ -278,7 +278,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
windowId: w.id,
active: true
}, ts => {
- const tID = ts[0]?.id,
+ var tID = ts[0]?.id,
data = { type: 'popup',
state: w.state,
width: parseInt(message.width, 10),
@@ -308,7 +308,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
}, function (granted) {
if (granted) {
try {
- const blob = new Blob([JSON.stringify(message.value)], {
+ var blob = new Blob([JSON.stringify(message.value)], {
type: 'application/json;charset=utf-8'
});
chrome.downloads.download({
diff --git a/js&css/extension/core.js b/js&css/extension/core.js
index 666826ffb..a0db21f37 100644
--- a/js&css/extension/core.js
+++ b/js&css/extension/core.js
@@ -301,7 +301,7 @@ extension.storage.load = function (callback) {
chrome.storage.local.set({ theme: 'dark' });
}
- for (const key in items) {
+ for (var key in items) {
document.documentElement.setAttribute('it-' + key.replace(/_/g, '-'), items[key]);
}
diff --git a/js&css/extension/www.youtube.com/general/general.js b/js&css/extension/www.youtube.com/general/general.js
index 410926116..6d50ae93a 100644
--- a/js&css/extension/www.youtube.com/general/general.js
+++ b/js&css/extension/www.youtube.com/general/general.js
@@ -254,8 +254,8 @@ extension.features.popupWindowButtons = function (event) {
if (ytPlayer) {width = ytPlayer.offsetWidth * 0.65; height = ytPlayer.offsetHeight * 0.65}
else { width = innerWidth * 0.4; height = innerHeight * 0.4; }
if (!ytPlayer) {
- let shorts = /short/.test(this.parentElement.href);
- let vertical = false;
+ var shorts = /short/.test(this.parentElement.href);
+ var vertical = false;
if (width / height < 1) { vertical = true }
if (!vertical && shorts) { width = height * 0.6}
if (vertical && !shorts) { height = width * 0.6}
@@ -532,8 +532,8 @@ extension.features.disableThumbnailPlayback = function (event) {
extension.features.openNewTab = function () {
if (extension.storage.get("open_new_tab") ) {
window.onload = function () {
- const searchButton = document.querySelector("button#search-icon-legacy");
- const inputField = document.querySelector("input#search");
+ var searchButton = document.querySelector("button#search-icon-legacy");
+ var inputField = document.querySelector("input#search");
searchButton.addEventListener("mousedown", (event) => {
performSearchNewTab(inputField.value);
@@ -544,23 +544,23 @@ extension.features.openNewTab = function () {
}
});
- let searchedAlready = false;
+ var searchedAlready = false;
inputField.addEventListener("focus", function () {
searchedAlready = false;
- const observer = new MutationObserver(applySuggestionListeners);
- const container = document.querySelector("div[style*='position: fixed'] ul[role='listbox']");
+ var observer = new MutationObserver(applySuggestionListeners);
+ var container = document.querySelector("div[style*='position: fixed'] ul[role='listbox']");
if (container) observer.observe(container, { attributes: true, childList: true, subtree: true });
});
inputField.addEventListener("input", () => searchedAlready = false);
function applySuggestionListeners () {
- const suggestionContainers = document.querySelectorAll("div[class^='sbqs'], div[class^='sbpqs']");
+ var suggestionContainers = document.querySelectorAll("div[class^='sbqs'], div[class^='sbpqs']");
suggestionContainers.forEach((suggestionsContainer) => {
suggestionsContainer.addEventListener("mousedown", (event) => {
- const suggestionListItem = event.target.closest("li[role='presentation']");
+ var suggestionListItem = event.target.closest("li[role='presentation']");
if (suggestionListItem && !searchedAlready) {
- const query = suggestionListItem.querySelector("b").textContent
+ var query = suggestionListItem.querySelector("b").textContent
performSearchNewTab(inputField.value + query);
searchedAlready = true;
}
@@ -571,7 +571,7 @@ extension.features.openNewTab = function () {
function performSearchNewTab (query) {
inputField.value = "";
inputField.focus();
- const newTabURL = `https://www.youtube.com/results?search_query=${encodeURIComponent(query)}`;
+ var newTabURL = `https://www.youtube.com/results?search_query=${encodeURIComponent(query)}`;
window.open(newTabURL, '_blank');
}
}
diff --git a/js&css/web-accessible/core.js b/js&css/web-accessible/core.js
index c736c451e..8551dd973 100644
--- a/js&css/web-accessible/core.js
+++ b/js&css/web-accessible/core.js
@@ -184,7 +184,7 @@ document.addEventListener('it-message-from-extension', function () {
ImprovedTube.storage = message.storage;
if (ImprovedTube.storage.block_vp9 || ImprovedTube.storage.block_av1 || ImprovedTube.storage.block_h264) {
- let atlas = { block_vp9: 'vp9|vp09', block_h264: 'avc1', block_av1: 'av01' },
+ var atlas = { block_vp9: 'vp9|vp09', block_h264: 'avc1', block_av1: 'av01' },
codec = Object.keys(atlas).reduce(function (all, key) {
return ImprovedTube.storage[key] ? ((all ? all + '|' : '') + atlas[key]) : all
}, '');
@@ -207,11 +207,11 @@ document.addEventListener('it-message-from-extension', function () {
// REACTION OR VISUAL FEEDBACK WHEN THE USER CHANGES A SETTING (already automated for our CSS features):
} else if (message.action === 'storage-changed') {
- let camelized_key = message.camelizedKey;
+ var camelized_key = message.camelizedKey;
ImprovedTube.storage[message.key] = message.value;
if (['block_vp9', 'block_h264', 'block_av1'].includes(message.key)) {
- let atlas = { block_vp9: 'vp9|vp09', block_h264: 'avc1', block_av1: 'av01' }
+ var atlas = { block_vp9: 'vp9|vp09', block_h264: 'avc1', block_av1: 'av01' }
localStorage['it-codec'] = Object.keys(atlas).reduce(function (all, key) {
return ImprovedTube.storage[key] ? ((all ? all + '|' : '') + atlas[key]) : all
}, '');
@@ -287,7 +287,7 @@ document.addEventListener('it-message-from-extension', function () {
case 'forcedTheaterMode':
if (ImprovedTube.storage.forced_theater_mode === false && ImprovedTube.elements.ytd_watch && ImprovedTube.elements.player) {
- const button = ImprovedTube.elements.player.querySelector("button.ytp-size-button");
+ var button = ImprovedTube.elements.player.querySelector("button.ytp-size-button");
if (button && ImprovedTube.elements.ytd_watch.theater) {
ImprovedTube.elements.ytd_watch.theater = false;
setTimeout(function () { button.click(); }, 100);
@@ -336,7 +336,7 @@ document.addEventListener('it-message-from-extension', function () {
case 'playerHamburgerButton':
if (ImprovedTube.storage.player_hamburger_button == false) {
document.querySelector('.custom-hamburger-menu')?.remove();
- let rightControls = document.querySelector('.html5-video-player')?.querySelector('.ytp-right-controls');
+ var rightControls = document.querySelector('.html5-video-player')?.querySelector('.ytp-right-controls');
if (rightControls) {
rightControls.style.setProperty('padding-right', ''); // Restoring the original padding:
rightControls.style.setProperty('display', 'flex');
@@ -437,7 +437,7 @@ document.addEventListener('it-message-from-extension', function () {
} else if (message.deleteCookies) {
ImprovedTube.deleteYoutubeCookies();
} else if (message.responseOptionsUrl) {
- const iframe = document.querySelector('.it-button__iframe');
+ var iframe = document.querySelector('.it-button__iframe');
if (iframe) {
iframe.src = message.responseOptionsUrl;
diff --git a/js&css/web-accessible/functions.js b/js&css/web-accessible/functions.js
index 84b51202b..230bd0bdd 100644
--- a/js&css/web-accessible/functions.js
+++ b/js&css/web-accessible/functions.js
@@ -17,14 +17,14 @@ ImprovedTube.childHandler = function (node) {
}
/*
-const DOM_filter = /^(SCRIPT|DOM-IF|DOM-REPEAT|svg|SPAN|#text|#comment|yt-icon-shape|iron-iconset-svg)$/;
+var DOM_filter = /^(SCRIPT|DOM-IF|DOM-REPEAT|svg|SPAN|#text|#comment|yt-icon-shape|iron-iconset-svg)$/;
ImprovedTube.childHandler = function (node) { //console.log(node.nodeName);
if (DOM_filter.test(node.nodeName)) { return; }
var children = node.children;
ImprovedTube.ytElementsHandler(node);
if (children) {
- let i = 0;
- for (const child of children) {
+ var i = 0;
+ for (var child of children) {
ImprovedTube.childHandler(children[i]);
//console.log("node.nodeName:CHILD-"+i+":"+children[i].id+",class:"+children[i].className+","+children[i]+"("+children[i].nodeName+")");
i++;
@@ -33,7 +33,7 @@ ImprovedTube.childHandler = function (node) { //console.log(node.nodeName);
}; */
ImprovedTube.ytElementsHandler = function (node) {
- const name = node.nodeName,
+ var name = node.nodeName,
id = node.id;
if (name === 'A') {
@@ -430,7 +430,7 @@ ImprovedTube.playerOnPause = function (event) {
if (document.documentElement.dataset.pageType === 'video'
&& (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.transcript || ImprovedTube.storage.chapters)) {
ImprovedTube.forbidFocus = function (ms) {
- const originalFocus = HTMLElement.prototype.focus; // Backing up default method - other methods: Element.prototype.scrollIntoView window.scrollTo window.scrollBy
+ var originalFocus = HTMLElement.prototype.focus; // Backing up default method - other methods: Element.prototype.scrollIntoView window.scrollTo window.scrollBy
// Override YouTube's scroll method:
HTMLElement.prototype.focus = function () { console.log("Preventing YouTube's scripted scrolling, when expanding the video description for you"); }
if (document.hidden) ms = 3 * ms;
@@ -540,16 +540,16 @@ ImprovedTube.getCookieValueByName = function (name) {
};
ImprovedTube.getPrefCookieValueByName = function (name) {
- let prefs = this.getParams(this.getCookieValueByName('PREF'));
+ var prefs = this.getParams(this.getCookieValueByName('PREF'));
return prefs[name];
};
// set PREF cookie name=value or delete name if value == null
ImprovedTube.setPrefCookieValueByName = function (name, value) {
- let originalPref = this.getCookieValueByName('PREF');
- let prefs = this.getParams(originalPref);
- let newPrefs = '';
- let ampersant = '';
+ var originalPref = this.getCookieValueByName('PREF');
+ var prefs = this.getParams(originalPref);
+ var newPrefs = '';
+ var ampersant = '';
if (name == 'f6' && prefs[name] & 1) {
// f6 holds other settings, possible values 80000 80001 400 401 1 none
@@ -559,7 +559,7 @@ ImprovedTube.setPrefCookieValueByName = function (name, value) {
prefs[name] = value;
}
- for (let pref in prefs) {
+ for (var pref in prefs) {
if (prefs[pref]) {
newPrefs += ampersant + pref + '=' + prefs[pref];
ampersant = '&';
@@ -580,13 +580,13 @@ ImprovedTube.setCookie = function (name, value) {
};
ImprovedTube.createIconButton = function (options) {
- const button = options.href ? document.createElement('a') : document.createElement('button'),
+ var button = options.href ? document.createElement('a') : document.createElement('button'),
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
path = document.createElementNS('http://www.w3.org/2000/svg', 'path'),
type = this.button_icons[options.type];
- for (const attr of type.svg) svg.setAttribute(attr[0], attr[1]);
- for (const attr of type.path) path.setAttribute(attr[0], attr[1]);
+ for (var attr of type.svg) svg.setAttribute(attr[0], attr[1]);
+ for (var attr of type.path) path.setAttribute(attr[0], attr[1]);
svg.appendChild(path);
button.appendChild(svg);
diff --git a/js&css/web-accessible/init.js b/js&css/web-accessible/init.js
index d88fdfb94..cc8950ed1 100644
--- a/js&css/web-accessible/init.js
+++ b/js&css/web-accessible/init.js
@@ -22,17 +22,17 @@ ImprovedTube.observer = new MutationObserver(function (mutationList) {
/*
//console.log("--- p FOR PARENT, c FOR CHILD, r FOR REMOVED :");
- let i = 0; for (const mutated of mutationList) {
+ var i = 0; for (var mutated of mutationList) {
if (mutated.type === 'childList') {
// if (/^(SCRIPT|DOM-IF|DOM-REPEAT|svg|SPAN|yt-icon-shape)$/.test(mutated.target.nodeName)) {i++; continue; }
// ImprovedTube.ytElementsHandler(mutated.target);
// console.log("p"+i+":"+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+")");
- let j = 0; for (const node of mutated.addedNodes) {
+ var j = 0; for (var node of mutated.addedNodes) {
ImprovedTube.childHandler(node);
//console.log("p"+i+"c"+j+":"+node.id+",class:"+node.className+","+node+"("+node.nodeName+")");
j++;}
- let r = 0; for (const node of mutated.removedNodes){ //might fix our other playlist buttons equally?
+ var r = 0; for (var node of mutated.removedNodes){ //might fix our other playlist buttons equally?
if(node.nodeName === 'BUTTON' && node.id === 'it-popup-playlist-button') ImprovedTube.playlistPopup();
//console.log("p"+i+"removed"+r+":"+node.id+",class:"+node.className+","+node+"("+node.nodeName+")"+"(from:"+mutated.target.id+",class:"+mutated.target.className+","+mutated.target+"("+mutated.target.nodeName+")");
r++;}
diff --git a/js&css/web-accessible/www.youtube.com/appearance.js b/js&css/web-accessible/www.youtube.com/appearance.js
index 653d2ed10..21203437f 100644
--- a/js&css/web-accessible/www.youtube.com/appearance.js
+++ b/js&css/web-accessible/www.youtube.com/appearance.js
@@ -5,7 +5,7 @@ ImprovedTube.YouTubeExperiments = function () {
if ((this.storage.undo_the_new_sidebar === "true" || this.storage.description === "sidebar")
&& document.documentElement.dataset.pageType === 'video') {
if (window.yt?.config_?.EXPERIMENT_FLAGS) {
- const newSidebarFlags = [
+ var newSidebarFlags = [
'kevlar_watch_grid',
'small_avatars_for_comments',
'small_avatars_for_comments_ep',
@@ -94,25 +94,25 @@ ImprovedTube.playerHdThumbnail = function () {
ALWAYS SHOW PROGRESS BAR
------------------------------------------------------------------------------*/
ImprovedTube.showProgressBar = function () {
- const player = ImprovedTube.elements.player;
+ var player = ImprovedTube.elements.player;
if (player && player.className.indexOf("ytp-autohide") !== -1) {
- const played = (player.getCurrentTime() * 100) / player.getDuration(),
+ var played = (player.getCurrentTime() * 100) / player.getDuration(),
loaded = player.getVideoBytesLoaded() * 100,
play_bars = player.querySelectorAll(".ytp-play-progress"),
load_bars = player.querySelectorAll(".ytp-load-progress");
- let width = 0,
+ var width = 0,
progress_play = 0,
progress_load = 0;
- for (let i = 0, l = play_bars.length; i < l; i++) {
+ for (var i = 0, l = play_bars.length; i < l; i++) {
width += play_bars[i].offsetWidth;
}
- const width_percent = width / 100;
+ var width_percent = width / 100;
- for (let i = 0, l = play_bars.length; i < l; i++) {
- let a = play_bars[i].offsetWidth / width_percent,
+ for (var i = 0, l = play_bars.length; i < l; i++) {
+ var a = play_bars[i].offsetWidth / width_percent,
b = 0,
c = 0;
@@ -193,8 +193,8 @@ ImprovedTube.commentsSidebar = function () {
if (!ImprovedTube.storage.comments_sidebar) {
return;
}
- const video = document.querySelector("#player .ytp-chrome-bottom") || document.querySelector("#container .ytp-chrome-bottom");
- let hasApplied = 0;
+ var video = document.querySelector("#player .ytp-chrome-bottom") || document.querySelector("#container .ytp-chrome-bottom");
+ var hasApplied = 0;
if (/watch\?/.test(location.href)) {
sidebar();
styleScrollbars();
@@ -225,20 +225,20 @@ ImprovedTube.commentsSidebar = function () {
else { /// <1000
if (hasApplied == 1) {
document.getElementById("primary-inner").appendChild(document.getElementById("related"));
- let comments = document.querySelector("#comments");
- let below = document.getElementById("below");
+ var comments = document.querySelector("#comments");
+ var below = document.getElementById("below");
below.appendChild(comments);
}
else if (hasApplied == 2) {
- let comments = document.querySelector("#comments");
- let below = document.getElementById("below");
+ var comments = document.querySelector("#comments");
+ var below = document.getElementById("below");
below.appendChild(comments);
}
hasApplied = 0;
}
}
function setGrid() {
- let checkParentInterval = setInterval(() => {
+ var checkParentInterval = setInterval(() => {
container = document.querySelector("#related ytd-compact-video-renderer.style-scope")?.parentElement;
if (container) {
clearInterval(checkParentInterval);
@@ -249,9 +249,9 @@ ImprovedTube.commentsSidebar = function () {
}, 250);
}
function initialSetup() {
- let secondaryInner = document.getElementById("secondary-inner");
- let primaryInner = document.getElementById("primary-inner");
- let comments = document.querySelector("#comments");
+ var secondaryInner = document.getElementById("secondary-inner");
+ var primaryInner = document.getElementById("primary-inner");
+ var comments = document.querySelector("#comments");
setTimeout(() => {
primaryInner.appendChild(document.getElementById("panels"));
primaryInner.appendChild(document.getElementById("related"))
@@ -260,22 +260,22 @@ ImprovedTube.commentsSidebar = function () {
})
}
function resizePlayer() {
- const width = video.offsetWidth + 24;
+ var width = video.offsetWidth + 24;
if (width != 24) {
- const player = document.querySelector("#player.style-scope.ytd-watch-flexy");
+ var player = document.querySelector("#player.style-scope.ytd-watch-flexy");
document.getElementById("primary").style.width = `${width}px`;
player.style.width = `${width}px`;
}
}
function styleScrollbars() {
if (!navigator.userAgent.toLowerCase().includes("mac")) {
- let color, colorHover
- const isDarkMode = getComputedStyle(document.querySelector('ytd-app')).getPropertyValue('--yt-spec-base-background') == "#0f0f0f";
+ var color, colorHover
+ var isDarkMode = getComputedStyle(document.querySelector('ytd-app')).getPropertyValue('--yt-spec-base-background') == "#0f0f0f";
if (isDarkMode) [color, colorHover] = ["#616161", "#909090"];
else[color, colorHover] = ["#aaaaaa", "#717171"];
- const style = document.createElement("style");
+ var style = document.createElement("style");
if (ImprovedTube.storage.comments_sidebar_scrollbars) {
- const cssRule = `
+ var cssRule = `
#primary, #secondary {
overflow: overlay !important;
}
@@ -299,7 +299,7 @@ ImprovedTube.commentsSidebar = function () {
style.appendChild(document.createTextNode(cssRule));
}
else {
- const cssRule = `
+ var cssRule = `
#primary, #secondary {
overflow: overlay !important;
}
@@ -314,12 +314,12 @@ ImprovedTube.commentsSidebar = function () {
}
}
function applyObserver() {
- const debouncedResizePlayer = debounce(resizePlayer, 200);
- const resizeObserver = new ResizeObserver(debouncedResizePlayer);
+ var debouncedResizePlayer = debounce(resizePlayer, 200);
+ var resizeObserver = new ResizeObserver(debouncedResizePlayer);
resizeObserver.observe(video);
}
function debounce(callback, delay) {
- let timerId;
+ var timerId;
return function (...args) {
clearTimeout(timerId);
timerId = setTimeout(() => {
@@ -338,10 +338,10 @@ ImprovedTube.transcript = function (el) {
if (ImprovedTube.storage.transcript) {
return;
}
- const available = el.querySelector('[target-id*=transcript][visibility*=HIDDEN]') || el.querySelector('[target-id*=transcript]')?.clientHeight;
+ var available = el.querySelector('[target-id*=transcript][visibility*=HIDDEN]') || el.querySelector('[target-id*=transcript]')?.clientHeight;
if (available) {
ImprovedTube.forbidFocus(2100);
- const descriptionTranscript = el.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
+ var descriptionTranscript = el.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
descriptionTranscript ? descriptionTranscript.click() : el.querySelector('[target-id*=transcript]')?.removeAttribute('visibility');
if (yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid) { available.setAttribute('z-index', '98765') }
}
@@ -353,10 +353,10 @@ ImprovedTube.chapters = function (el) {
if (!ImprovedTube.storage.chapters) {
return;
}
- const available = el.querySelector('[target-id*=chapters][visibility*=HIDDEN]') || el.querySelector('[target-id*=chapters]')?.clientHeight;
+ var available = el.querySelector('[target-id*=chapters][visibility*=HIDDEN]') || el.querySelector('[target-id*=chapters]')?.clientHeight;
if (available) {
ImprovedTube.forbidFocus(2100);
- const modernChapters = el.querySelector('[modern-chapters] #navigation-button button[aria-label]');
+ var modernChapters = el.querySelector('[modern-chapters] #navigation-button button[aria-label]');
modernChapters ? modernChapters.click() : el.querySelector('[target-id*=chapters]')?.removeAttribute('visibility');
if (yt.config_.EXPERIMENT_FLAGS.kevlar_watch_grid) { available.setAttribute('z-index', '98765') }
}
diff --git a/js&css/web-accessible/www.youtube.com/blocklist.js b/js&css/web-accessible/www.youtube.com/blocklist.js
index c9feecd7c..5feefb299 100644
--- a/js&css/web-accessible/www.youtube.com/blocklist.js
+++ b/js&css/web-accessible/www.youtube.com/blocklist.js
@@ -4,7 +4,7 @@
ImprovedTube.blocklistNode = function (node) {
if (!this.storage.blocklist_activate || !node) return;
- const video = node.href?.match(ImprovedTube.regex.video_id)?.[1] || (node.classList?.contains('ytd-video-preview') ? 'video-preview' : null),
+ var video = node.href?.match(ImprovedTube.regex.video_id)?.[1] || (node.classList?.contains('ytd-video-preview') ? 'video-preview' : null),
channel = node.parentNode?.__dataHost?.__data?.data?.shortBylineText?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata?.url?.match(ImprovedTube.regex.channel)?.groups?.name,
blockedElement = this.blocklistElementTypeHelper(node);
@@ -42,12 +42,12 @@ ImprovedTube.blocklistNode = function (node) {
// skip blocklist button creation if one already exists, in theory this never happens due to check in functions.js
if (node.querySelector("button.it-add-to-blocklist")) return;
- const button = this.createIconButton({
+ var button = this.createIconButton({
type: 'blocklist',
className: 'it-add-to-blocklist',
onclick: function () {
if (!this.parentNode.href) return; // no href no action
- const video = this.parentNode.href?.match(ImprovedTube.regex.video_id)?.[1],
+ var video = this.parentNode.href?.match(ImprovedTube.regex.video_id)?.[1],
channel = this.parentNode.parentNode?.__dataHost?.__data?.data?.shortBylineText?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata?.url?.match(ImprovedTube.regex.channel)?.groups?.name
// video-preview doesnt have Channel info, extract from source thumbnail
|| ((video && this.parentNode?.classList.contains('ytd-video-preview')) ? ImprovedTube.elements.observerList.find(a => a.id == 'thumbnail' && a.href?.match(ImprovedTube.regex.video_id)?.[1] === video).parentNode?.__dataHost?.__data?.data?.shortBylineText?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata?.url?.match(ImprovedTube.regex.channel)?.groups?.name : null),
@@ -58,7 +58,7 @@ ImprovedTube.blocklistNode = function (node) {
|| this.parentNode.__dataHost?.__data?.data?.title?.simpleText
|| this.parentNode.__dataHost?.__data?.videoPreviewData?.accessibilityText
|| blockedElement?.querySelector('[title]')?.title;
- let added = false,
+ var added = false,
type = 'video';
if (!video || !blockedElement || !title) {
@@ -96,8 +96,8 @@ ImprovedTube.blocklistNode = function (node) {
ImprovedTube.blocklistChannel = function (node) {
if (!this.storage.blocklist_activate || !node) return;
- const id = location.pathname.match(ImprovedTube.regex.channel)?.groups?.name;
- let button = node.parentNode?.parentNode?.querySelector("button.it-add-channel-to-blocklist");
+ var id = location.pathname.match(ImprovedTube.regex.channel)?.groups?.name;
+ var button = node.parentNode?.parentNode?.querySelector("button.it-add-channel-to-blocklist");
if (!id) return; // not on channel page
@@ -115,7 +115,7 @@ ImprovedTube.blocklistChannel = function (node) {
event.preventDefault();
event.stopPropagation();
- const id = location.pathname.match(ImprovedTube.regex.channel)?.groups?.name,
+ var id = location.pathname.match(ImprovedTube.regex.channel)?.groups?.name,
title = this.parentNode.__dataHost?.__data?.data?.title
|| ytInitialData?.metadata?.channelMetadataRenderer?.title
|| document.querySelector('yt-dynamic-text-view-model .yt-core-attributed-string')?.innerText,
@@ -166,7 +166,7 @@ ImprovedTube.blocklistInit = function () {
if (!this.storage.blocklist.channels || typeof this.storage.blocklist.channels !== 'object') {
this.storage.blocklist.channels = {};
}
- for (const thumbnail of document.querySelectorAll('a.ytd-thumbnail[href], a.ytd-video-preview')) {
+ for (var thumbnail of document.querySelectorAll('a.ytd-thumbnail[href], a.ytd-video-preview')) {
this.blocklistNode(thumbnail);
}
if (document.querySelector('YTD-SUBSCRIBE-BUTTON-RENDERER, YT-SUBSCRIBE-BUTTON-VIEW-MODEL, YTD-BUTTON-RENDERER.ytd-c4-tabbed-header-renderer')) {
@@ -175,7 +175,7 @@ ImprovedTube.blocklistInit = function () {
} else {
// Disable and unload Blocklist
// remove all 'it-add-to-blocklist' buttons
- for (const blocked of this.elements.blocklist_buttons) {
+ for (var blocked of this.elements.blocklist_buttons) {
blocked.remove();
}
this.elements.blocklist_buttons = [];
@@ -190,18 +190,18 @@ ImprovedTube.blocklistInit = function () {
ImprovedTube.blocklistChannelObserver.disconnect();
}
// remove all video/channel blocks from thumbnails on current page
- for (const blocked of document.querySelectorAll('.it-blocklisted-video')) {
+ for (var blocked of document.querySelectorAll('.it-blocklisted-video')) {
blocked.classList.remove('it-blocklisted-video');
}
- for (const blocked of document.querySelectorAll('.it-blocklisted-channel')) {
+ for (var blocked of document.querySelectorAll('.it-blocklisted-channel')) {
blocked.classList.remove('it-blocklisted-channel');
}
}
};
ImprovedTube.blocklistObserver = new MutationObserver(function (mutationList) {
- for (const mutation of mutationList) {
- const video = mutation.target.href?.match(ImprovedTube.regex.video_id)?.[1],
+ for (var mutation of mutationList) {
+ var video = mutation.target.href?.match(ImprovedTube.regex.video_id)?.[1],
channel = mutation.target.parentNode?.__dataHost?.__data?.data?.shortBylineText?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata?.url?.match(ImprovedTube.regex.channel)?.groups?.name
// video-preview doesnt have Channel info, extract from source thumbnail
|| ((video && mutation.target?.classList.contains('ytd-video-preview')) ? ImprovedTube.elements.observerList.find(a => a.id == 'thumbnail' && a.href?.match(ImprovedTube.regex.video_id)?.[1] === video).parentNode?.__dataHost?.__data?.data?.shortBylineText?.runs?.[0]?.navigationEndpoint?.commandMetadata?.webCommandMetadata?.url?.match(ImprovedTube.regex.channel)?.groups?.name : null),
diff --git a/js&css/web-accessible/www.youtube.com/channel.js b/js&css/web-accessible/www.youtube.com/channel.js
index 0f08d09a2..2f06b7fb3 100644
--- a/js&css/web-accessible/www.youtube.com/channel.js
+++ b/js&css/web-accessible/www.youtube.com/channel.js
@@ -26,10 +26,10 @@ ImprovedTube.channelDefaultTab = function (a) {
ImprovedTube.channelPlayAllButton = function () {
if (ImprovedTube.regex.channel.test(location.pathname)) {
if (this.storage.channel_play_all_button) {
- const container = document.querySelector('ytd-channel-sub-menu-renderer #primary-items')
+ var container = document.querySelector('ytd-channel-sub-menu-renderer #primary-items')
|| document.querySelector('ytd-two-column-browse-results-renderer #chips-content');
- const playlistUrl = document.querySelector('ytd-app')?.__data?.data?.response?.metadata?.channelMetadataRenderer?.externalId?.substring(2);
- const existingPlayAllButton = document.querySelector('.it-play-all-button')
+ var playlistUrl = document.querySelector('ytd-app')?.__data?.data?.response?.metadata?.channelMetadataRenderer?.externalId?.substring(2);
+ var existingPlayAllButton = document.querySelector('.it-play-all-button')
if (!container) return; // we only add button on /videos page
if (!playlistUrl) {
@@ -37,7 +37,7 @@ ImprovedTube.channelPlayAllButton = function () {
return;
}
if (existingPlayAllButton) return // prevent add duplicate button
- const button = this.createIconButton({
+ var button = this.createIconButton({
type: 'playAll',
className: 'it-play-all-button',
text: 'Play all',
@@ -72,7 +72,7 @@ ImprovedTube.channelCompactTheme = function () {
}
function styleWithInterval() {
compact.listener = setInterval(() => {
- let item = document.querySelector(`#sections ytd-guide-section-renderer:nth-child(4) #items`)
+ var item = document.querySelector(`#sections ytd-guide-section-renderer:nth-child(4) #items`)
if (item) {
clearInterval(compact.listener);
styleWithListeners();
@@ -83,12 +83,12 @@ ImprovedTube.channelCompactTheme = function () {
function styleWithListeners() {
compact.parents = []
compact.subs = []
- for (let i = 0; i <= 2; i++) {
- const parent = document.querySelector(`#sections > ytd-guide-section-renderer:nth-child(${i + 2}) > h3`);
- const sub = document.querySelector(`#sections ytd-guide-section-renderer:nth-child(${i + 2}) #items`);
+ for (var i = 0; i <= 2; i++) {
+ var parent = document.querySelector(`#sections > ytd-guide-section-renderer:nth-child(${i + 2}) > h3`);
+ var sub = document.querySelector(`#sections ytd-guide-section-renderer:nth-child(${i + 2}) #items`);
compact.parents[i] = parent;
compact.subs[i] = sub;
- let isCompact = localStorage.getItem(`ImprovedTube-compact-${i}`) === "true";
+ var isCompact = localStorage.getItem(`ImprovedTube-compact-${i}`) === "true";
isCompact ? (sub.style.display = "none") : null;
function eventHandlerFn() {
@@ -109,9 +109,9 @@ ImprovedTube.channelCompactTheme = function () {
}
function removeListeners() { // EventListeners
- for (let i = 0; i <= 2; i++) {
- const parent = compact.parents[i]
- const sub = compact.subs[i]
+ for (var i = 0; i <= 2; i++) {
+ var parent = compact.parents[i]
+ var sub = compact.subs[i]
parent.removeEventListener("click", compact.eventHandlerFns[i]);
sub.style.display = "";
}
@@ -119,25 +119,25 @@ ImprovedTube.channelCompactTheme = function () {
}
function initialLoad() {
- for (let i = 0; i <= 2; i++) {
- let isCompact = localStorage.getItem(`ImprovedTube-compact-${i + 2}`) === "true"
+ for (var i = 0; i <= 2; i++) {
+ var isCompact = localStorage.getItem(`ImprovedTube-compact-${i + 2}`) === "true"
isCompact ? appendStyle(i) : (compact.styles[i] = null);
}
}
function appendStyle(index) { // adds style tag
- const cssRules = `
+ var cssRules = `
#sections > ytd-guide-section-renderer:nth-child(${index + 2}) > #items{
display:none;
};`;
- const style = document.createElement("style");
+ var style = document.createElement("style");
style.appendChild(document.createTextNode(cssRules));
compact.styles[index] = style;
document.head.appendChild(compact.styles[index]);
}
function removeStyles() { // styles tags
- for (let i = 0; i <= compact.styles.length; i++) {
+ for (var i = 0; i <= compact.styles.length; i++) {
if (compact.styles[i] && compact.styles[i].parentNode) {
document.head.removeChild(compact.styles[i]);
}
diff --git a/js&css/web-accessible/www.youtube.com/player.js b/js&css/web-accessible/www.youtube.com/player.js
index e9711f42c..0a2c08166 100644
--- a/js&css/web-accessible/www.youtube.com/player.js
+++ b/js&css/web-accessible/www.youtube.com/player.js
@@ -5,7 +5,7 @@ ImprovedTube.autoplayDisable = function (videoElement) {
if (this.storage.player_autoplay_disable
|| this.storage.playlist_autoplay === false
|| this.storage.channel_trailer_autoplay === false) {
- const player = this.elements.player || videoElement.closest('.html5-video-player') || videoElement.closest('#movie_player'); // #movie_player: outdated since 2024?
+ var player = this.elements.player || videoElement.closest('.html5-video-player') || videoElement.closest('#movie_player'); // #movie_player: outdated since 2024?
if (this.video_url !== location.href) { this.user_interacted = false; }
@@ -38,7 +38,7 @@ ImprovedTube.autoplayDisable = function (videoElement) {
FORCED PLAY VIDEO FROM THE BEGINNING
------------------------------------------------------------------------------*/
ImprovedTube.forcedPlayVideoFromTheBeginning = function () {
- const player = this.elements.player,
+ var player = this.elements.player,
video = this.elements.video,
paused = video?.paused;
@@ -52,7 +52,7 @@ ImprovedTube.forcedPlayVideoFromTheBeginning = function () {
AUTOPAUSE WHEN SWITCHING TABS
------------------------------------------------------------------------------*/
ImprovedTube.playerAutopauseWhenSwitchingTabs = function () {
- const player = this.elements.player;
+ var player = this.elements.player;
if (this.storage.player_autopause_when_switching_tabs && player) {
if (this.focus && this.played_before_blur && this.elements.video.paused) {
@@ -69,7 +69,7 @@ ImprovedTube.playerAutopauseWhenSwitchingTabs = function () {
PICTURE IN PICTURE (PIP)
------------------------------------------------------------------------------*/
ImprovedTube.enterPip = function (disable) {
- const video = this.elements.video;
+ var video = this.elements.video;
if (!disable
&& video
@@ -92,7 +92,7 @@ ImprovedTube.enterPip = function (disable) {
AUTO PIP WHEN SWITCHING TABS
------------------------------------------------------------------------------*/
ImprovedTube.playerAutoPip = function () {
- const video = this.elements.video;
+ var video = this.elements.video;
if (this.storage.player_autoPip && this.storage.player_autoPip_outside && this.focus) {
this.enterPip(true);
@@ -104,7 +104,7 @@ ImprovedTube.playerAutoPip = function () {
PLAYBACK SPEED
------------------------------------------------------------------------------*/
ImprovedTube.playbackSpeed = function (newSpeed) {
- const video = this.elements.video,
+ var video = this.elements.video,
player = this.elements.player,
speed = video?.playbackRate ? Number(video.playbackRate.toFixed(2)) : (player?.getPlaybackRate ? Number(player.getPlaybackRate().toFixed(2)) : null);
@@ -138,7 +138,7 @@ ImprovedTube.playerPlaybackSpeed = function () {
option = this.storage.player_playback_speed;
if (this.isset(option) === false) { option = 1; }
else if (option !== 1) {
- const speed = video?.playbackRate ? Number(video.playbackRate.toFixed(2)) : (player?.getPlaybackRate ? Number(player.getPlaybackRate().toFixed(2)) : null);
+ var speed = video?.playbackRate ? Number(video.playbackRate.toFixed(2)) : (player?.getPlaybackRate ? Number(player.getPlaybackRate().toFixed(2)) : null);
if (speed !== option && (speed > 1 || speed < 1)) { console.log("skipping permanent speed, since speed was manually set differently for this video to:" + video.playbackRate); return; }
}
if (!(player.getVideoData() && player.getVideoData().isLive)) {
@@ -169,7 +169,7 @@ ImprovedTube.playerPlaybackSpeed = function () {
// (Tags/keywords shouldnt lie & very few songs titles might have these words)
if (DATA.duration) {
function parseDuration(duration) {
- const [_, h = 0, m = 0, s = 0] = duration.match(/PT(?:(\d+)?H)?(?:(\d+)?M)?(\d+)?S?/).map(part => parseInt(part) || 0);
+ var [_, h = 0, m = 0, s = 0] = duration.match(/PT(?:(\d+)?H)?(?:(\d+)?M)?(\d+)?S?/).map(part => parseInt(part) || 0);
return h * 3600 + m * 60 + s;
}
DATA.lengthSeconds = parseDuration(DATA.duration);
@@ -241,12 +241,12 @@ ImprovedTube.playerPlaybackSpeed = function () {
keywords = '';
(async function () {
try {
- const response = await fetch(`https://www.youtube.com/watch?v=${DATA.videoID}`);
- const htmlContent = await response.text();
- const metaRegex = /]+name=["'](keywords|genre|duration)["'][^>]+content=["']([^"']+)["'][^>]*>/gi;
- let match;
+ var response = await fetch(`https://www.youtube.com/watch?v=${DATA.videoID}`);
+ var htmlContent = await response.text();
+ var metaRegex = /]+name=["'](keywords|genre|duration)["'][^>]+content=["']([^"']+)["'][^>]*>/gi;
+ var match;
while ((match = metaRegex.exec(htmlContent)) !== null) {
- const [, property, value] = match;
+ var [, property, value] = match;
if (property === 'keywords') {
keywords = value;
} else {
@@ -269,15 +269,15 @@ ImprovedTube.playerPlaybackSpeed = function () {
ImprovedTube.fetchDOMData();
} else {
//Invidious instances. Should be updated automatically!...
- const invidiousInstances = ['invidious.fdn.fr', 'inv.tux.pizza', 'invidious.flokinet.to', 'invidious.protokolla.fi', 'invidious.private.coffee', 'yt.artemislena.eu', 'invidious.materialio.us', 'iv.datura.network'];
+ var invidiousInstances = ['invidious.fdn.fr', 'inv.tux.pizza', 'invidious.flokinet.to', 'invidious.protokolla.fi', 'invidious.private.coffee', 'yt.artemislena.eu', 'invidious.materialio.us', 'iv.datura.network'];
function getRandomInvidiousInstance() { return invidiousInstances[Math.floor(Math.random() * invidiousInstances.length)]; }
(async function () {
- let retries = 4;
- let invidiousFetched = false;
+ var retries = 4;
+ var invidiousFetched = false;
async function fetchInvidiousData() {
try {
- const response = await fetch(`https://${getRandomInvidiousInstance()}/api/v1/videos/${DATA.videoID}?fields=genre,title,lengthSeconds,keywords`);
+ var response = await fetch(`https://${getRandomInvidiousInstance()}/api/v1/videos/${DATA.videoID}?fields=genre,title,lengthSeconds,keywords`);
DATA = await response.json();
if (DATA.genre && DATA.title && DATA.keywords && DATA.lengthSeconds) {
if (DATA.keywords.toString() === defaultKeywords) {
@@ -313,7 +313,7 @@ ImprovedTube.playerPlaybackSpeed = function () {
SUBTITLES
------------------------------------------------------------------------------*/
ImprovedTube.playerSubtitles = function () {
- const player = this.elements.player;
+ var player = this.elements.player;
if (player && player.isSubtitlesOn && player.toggleSubtitles && player.toggleSubtitlesOn) {
switch (this.storage.player_subtitles) {
@@ -331,12 +331,12 @@ ImprovedTube.playerSubtitles = function () {
SUBTITLES LANGUAGE
------------------------------------------------------------------------------*/
ImprovedTube.subtitlesLanguage = function () {
- const option = this.storage.subtitles_language,
+ var option = this.storage.subtitles_language,
player = this.elements.player;
- let subtitlesState;
+ var subtitlesState;
if (option && player && player.getOption && player.setOption && player.isSubtitlesOn && player.toggleSubtitles) {
- const matchedTrack = player.getOption('captions', 'tracklist', { includeAsr: true })?.find(track => track.languageCode.includes(option) && (!track.vss_id.includes("a.") || this.storage.auto_generate));
+ var matchedTrack = player.getOption('captions', 'tracklist', { includeAsr: true })?.find(track => track.languageCode.includes(option) && (!track.vss_id.includes("a.") || this.storage.auto_generate));
if (matchedTrack) {
subtitlesState = player.isSubtitlesOn();
@@ -369,7 +369,7 @@ default = {
},
------------------------------------------------------------------------------*/
ImprovedTube.subtitlesUserSettings = function () {
- const ourSettings = {
+ var ourSettings = {
fontFamily: this.storage.subtitles_font_family,
color: this.storage.subtitles_font_color,
fontSizeIncrement: this.storage.subtitles_font_size,
@@ -384,12 +384,12 @@ ImprovedTube.subtitlesUserSettings = function () {
player = this.elements.player;
if (userSettings.length && player && player.getSubtitlesUserSettings && player.updateSubtitlesUserSettings) {
- let ytSettings = player.getSubtitlesUserSettings(),
+ var ytSettings = player.getSubtitlesUserSettings(),
setting;
if (!ytSettings) return; //null SubtitlesUserSettings seem to mean subtitles not available
- for (const value of userSettings) {
+ for (var value of userSettings) {
setting = null;
switch (value) {
case 'fontFamily':
@@ -425,12 +425,12 @@ SUBTITLES DISABLE SUBTILES FOR LYRICS
------------------------------------------------------------------------------*/
ImprovedTube.subtitlesDisableLyrics = function () {
if (this.storage.subtitles_disable_lyrics) {
- const player = this.elements.player;
+ var player = this.elements.player;
if (player && player.isSubtitlesOn && player.isSubtitlesOn() && player.toggleSubtitles) {
// Music detection only uses 3 identifiers for Lyrics: lyrics, sing-along, karaoke.
// Easier to simply use those here. Can replace with music detection later.
- const terms = ["sing along", "sing-along", "karaoke", "lyric", "卡拉OK", "卡拉OK", "الكاريوكي", "караоке", "カラオケ", "노래방"];
+ var terms = ["sing along", "sing-along", "karaoke", "lyric", "卡拉OK", "卡拉OK", "الكاريوكي", "караоке", "カラオケ", "노래방"];
if (terms.some(term => this.videoTitle().toLowerCase().includes(term))) {
player.toggleSubtitles();
}
@@ -458,9 +458,9 @@ ADS
------------------------------------------------------------------------------*/
ImprovedTube.playerAds = function (parent) {
- let button = parent.querySelector('.ytp-ad-skip-button-modern.ytp-button,[class*="ytp-ad-skip-button"].ytp-button') || parent;
+ var button = parent.querySelector('.ytp-ad-skip-button-modern.ytp-button,[class*="ytp-ad-skip-button"].ytp-button') || parent;
// TODO: Replace this with centralized video element pointer
- let video = document.querySelector('.video-stream.html5-main-video') || false;
+ var video = document.querySelector('.video-stream.html5-main-video') || false;
function skipAd() {
if (video) video.currentTime = video.duration;
if (button) button.click();
@@ -476,8 +476,8 @@ ImprovedTube.playerAds = function (parent) {
skipAd();
}
} else if (this.storage.ads === 'small_creators') {
- let userDefiniedLimit = this.storage.smallCreatorsCount * parseInt(this.storage.smallCreatorsUnit);
- let subscribersNumber = ImprovedTube.subscriberCount;
+ var userDefiniedLimit = this.storage.smallCreatorsCount * parseInt(this.storage.smallCreatorsUnit);
+ var subscribersNumber = ImprovedTube.subscriberCount;
if (subscribersNumber > userDefiniedLimit) {
skipAd();
}
@@ -499,16 +499,16 @@ ImprovedTube.playerAutofullscreen = function () {
QUALITY
------------------------------------------------------------------------------*/
ImprovedTube.playerQuality = function (quality = this.storage.player_quality) {
- let player = this.elements.player;
+ var player = this.elements.player;
if (quality && quality !== 'disabled'
&& player && player.getAvailableQualityLevels
&& (!player.dataset.defaultQuality || player.dataset.defaultQuality != quality)) {
- let available_quality_levels = player.getAvailableQualityLevels();
+ var available_quality_levels = player.getAvailableQualityLevels();
function closest(num, arr) {
- let curr = arr[0];
- let diff = Math.abs(num - curr);
- for (let val = 1; val < arr.length; val++) {
- let newdiff = Math.abs(num - arr[val]);
+ var curr = arr[0];
+ var diff = Math.abs(num - curr);
+ for (var val = 1; val < arr.length; val++) {
+ var newdiff = Math.abs(num - arr[val]);
if (newdiff < diff) {
diff = newdiff;
curr = arr[val];
@@ -518,9 +518,9 @@ ImprovedTube.playerQuality = function (quality = this.storage.player_quality) {
};
if (!available_quality_levels.includes(quality)) {
- let label = ['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'];
- let resolution = ['144', '240', '360', '480', '720', '1080', '1440', '2160', '2880', '4320'];
- let availableresolutions = available_quality_levels.map(q => resolution[label.indexOf(q)]);
+ var label = ['tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'];
+ var resolution = ['144', '240', '360', '480', '720', '1080', '1440', '2160', '2880', '4320'];
+ var availableresolutions = available_quality_levels.map(q => resolution[label.indexOf(q)]);
quality = label[resolution.indexOf(closest(resolution[label.indexOf(quality)], availableresolutions))];
}
player.setPlaybackQualityRange(quality);
@@ -532,7 +532,7 @@ ImprovedTube.playerQuality = function (quality = this.storage.player_quality) {
QUALITY WITHOUT FOCUS
------------------------------------------------------------------------------*/
ImprovedTube.playerQualityWithoutFocus = function () {
- let player = this.elements.player,
+ var player = this.elements.player,
qualityWithoutFocus = this.storage.player_quality_without_focus;
if (qualityWithoutFocus && qualityWithoutFocus !== 'auto' && player && player.getPlaybackQuality) {
if (this.focus) {
@@ -557,7 +557,7 @@ ImprovedTube.batteryFeatures = async function () {
if (ImprovedTube.storage.qualityWhenRunningOnBattery
|| ImprovedTube.storage.pauseWhileIUnplugTheCharger
|| ImprovedTube.storage.whenBatteryIslowDecreaseQuality) {
- const updateQuality = async (battery, charging) => {
+ var updateQuality = async (battery, charging) => {
if (battery) {
if (!battery.charging) {
if (ImprovedTube.storage.pauseWhileIUnplugTheCharger && charging) {
@@ -568,7 +568,7 @@ ImprovedTube.batteryFeatures = async function () {
ImprovedTube.playerQuality(ImprovedTube.storage.qualityWhenRunningOnBattery);
}
if (ImprovedTube.storage.whenBatteryIslowDecreaseQuality) {
- let quality;
+ var quality;
if (battery.level > 0.11 || battery.dischargingTime > 900) {
quality = "large";
} else if (battery.level > 0.08 || battery.dischargingTime > 600) {
@@ -586,7 +586,7 @@ ImprovedTube.batteryFeatures = async function () {
}
}
};
- const battery = await navigator.getBattery();
+ var battery = await navigator.getBattery();
battery.addEventListener("levelchange", () => updateQuality(battery));
battery.addEventListener("chargingchange", () => updateQuality(battery, true));
await updateQuality(battery);
@@ -667,10 +667,10 @@ ImprovedTube.playerLoudnessNormalization = function () {
SCREENSHOT
------------------------------------------------------------------------------*/
ImprovedTube.screenshot = function () {
- const video = ImprovedTube.elements.video,
+ var video = ImprovedTube.elements.video,
cvs = document.createElement('canvas'),
ctx = cvs.getContext('2d');
- let subText = '';
+ var subText = '';
cvs.width = video.videoWidth;
cvs.height = video.videoHeight;
@@ -678,7 +678,7 @@ ImprovedTube.screenshot = function () {
ctx.drawImage(video, 0, 0, cvs.width, cvs.height);
if (ImprovedTube.storage.embed_subtitle != false) {
- let captionElements = document.querySelectorAll('.captions-text .ytp-caption-segment');
+ var captionElements = document.querySelectorAll('.captions-text .ytp-caption-segment');
captionElements.forEach(function (caption) { subText += caption.textContent.trim() + ' '; });
ImprovedTube.renderSubtitle(ctx, captionElements);
@@ -698,7 +698,7 @@ ImprovedTube.screenshot = function () {
alert('ImprovedTube Screenshot to Clipboard error. Details in Debug Console.');
});
} else {
- let a = document.createElement('a');
+ var 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();
@@ -859,11 +859,11 @@ FIT-TO-WIN BUTTON
------------------------------------------------------------------------------*/
ImprovedTube.playerFitToWinButton = function () {
if (this.storage.player_fit_to_win_button && (/watch\?/.test(location.href))) {
- let tempContainer = document.createElement("div");
- let svg;
+ var tempContainer = document.createElement("div");
+ var svg;
if (typeof trustedTypes !== 'undefined' && typeof trustedTypes.createPolicy === 'function') {
// Create a Trusted Type policy
- const policy = trustedTypes.createPolicy('default', {
+ var policy = trustedTypes.createPolicy('default', {
createHTML: (string) => string,
});
@@ -885,8 +885,8 @@ ImprovedTube.playerFitToWinButton = function () {
opacity: 0.85,
position: "right",
onclick: function () {
- let previousSize = ImprovedTube.storage.player_size === "fit_to_window" ? "do_not_change" : (ImprovedTube.storage.player_size ?? "do_not_change");
- let isFTW = document.querySelector("html").getAttribute("it-player-size") === "fit_to_window"
+ var previousSize = ImprovedTube.storage.player_size === "fit_to_window" ? "do_not_change" : (ImprovedTube.storage.player_size ?? "do_not_change");
+ var isFTW = document.querySelector("html").getAttribute("it-player-size") === "fit_to_window"
if (isFTW) {
document.querySelector("html").setAttribute("it-player-size", previousSize);
} else {
@@ -1009,19 +1009,19 @@ HAMBURGER MENU
------------------------------------------------------------------------------*/
ImprovedTube.playerHamburgerButton = function () {
if (this.storage.player_hamburger_button) {
- const videoPlayer = document.querySelector('.html5-video-player');
+ var videoPlayer = document.querySelector('.html5-video-player');
if (!videoPlayer) {
return;
}
- const controlsContainer = videoPlayer.querySelector('.ytp-right-controls');
+ var controlsContainer = videoPlayer.querySelector('.ytp-right-controls');
if (!controlsContainer) {
return;
}
- let hamburgerMenu = document.querySelector('.custom-hamburger-menu');
+ var hamburgerMenu = document.querySelector('.custom-hamburger-menu');
if (!hamburgerMenu) {
hamburgerMenu = document.createElement('div');
hamburgerMenu.className = 'custom-hamburger-menu';
@@ -1030,11 +1030,11 @@ ImprovedTube.playerHamburgerButton = function () {
hamburgerMenu.style.marginTop = '8px';
hamburgerMenu.style.cursor = 'pointer';
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ var 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;');
- const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
+ var 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');
@@ -1044,7 +1044,7 @@ ImprovedTube.playerHamburgerButton = function () {
controlsContainer.style.paddingRight = '40px';
controlsContainer.parentNode.appendChild(hamburgerMenu);
- let controlsVisible = true;
+ var controlsVisible = true;
controlsContainer.style.display = controlsVisible ? 'none' : 'flex';
controlsVisible = false;
@@ -1077,9 +1077,9 @@ ImprovedTube.playerPopupButton = function () {
opacity: 0.8,
onclick: function () {
"use strict";
- const ytPlayer = ImprovedTube.elements.player;
+ var ytPlayer = ImprovedTube.elements.player;
ytPlayer.pauseVideo();
- const videoID = location.search.match(ImprovedTube.regex.video_id)[1],
+ var videoID = location.search.match(ImprovedTube.regex.video_id)[1],
listMatch = location.search.match(ImprovedTube.regex.playlist_id),
popup = window.open(
`${location.protocol}//www.youtube.com/embed/${videoID}?start=${parseInt(ytPlayer.getCurrentTime())}&autoplay=${ImprovedTube.storage.player_autoplay_disable ? '0' : '1'}${listMatch ? `&list=${listMatch[1]}` : ''}`,
@@ -1091,7 +1091,7 @@ ImprovedTube.playerPopupButton = function () {
popup.addEventListener('load', function () {
"use strict";
//~ check if the video ID in the link of the video title matches the original video ID in the URL and if not remove the playlist from the URL (reloads the page).
- const videoLink = this.document.querySelector('div#player div.ytp-title-text>a[href]');
+ var videoLink = this.document.querySelector('div#player div.ytp-title-text>a[href]');
if (videoLink && videoLink.href.match(ImprovedTube.regex.video_id)[1] !== videoID) this.location.search = this.location.search.replace(/(\?)list=[^&]+&|&list=[^&]+/, '$1');
}, { passive: true, once: true });
}
@@ -1123,7 +1123,7 @@ ImprovedTube.playerSDR = function () {
Hide controls
------------------------------------------------------------------------------*/
ImprovedTube.playerControls = function () {
- const player = this.elements.player,
+ var player = this.elements.player,
hide = this.storage.player_hide_controls;
if (player && player.hideControls && player.showControls) {
@@ -1134,7 +1134,7 @@ ImprovedTube.playerControls = function () {
player.onmouseenter = player.showControls;
player.onmouseleave = player.hideControls;
player.onmousemove = (function () {
- let thread,
+ var thread,
onmousestop = function () {
if (document.querySelector(".ytp-progress-bar:hover")) {
thread = setTimeout(onmousestop, 1000);
@@ -1169,7 +1169,7 @@ CUSTOM MINI-PLAYER
------------------------------------------------------------------------------*/
ImprovedTube.mini_player__setSize = function (width, height, keep_ar, keep_area) {
if (keep_ar) {
- const aspect_ratio = ImprovedTube.elements.video.style.width.replace('px', '') / ImprovedTube.elements.video.style.height.replace('px', '');
+ var aspect_ratio = ImprovedTube.elements.video.style.width.replace('px', '') / ImprovedTube.elements.video.style.height.replace('px', '');
if (keep_area) {
height = Math.sqrt((width * height) / aspect_ratio);
width = height * aspect_ratio;
diff --git a/js&css/web-accessible/www.youtube.com/playlist.js b/js&css/web-accessible/www.youtube.com/playlist.js
index c71d8a8de..7ccecd7c1 100644
--- a/js&css/web-accessible/www.youtube.com/playlist.js
+++ b/js&css/web-accessible/www.youtube.com/playlist.js
@@ -6,7 +6,7 @@
------------------------------------------------------------------------------*/
ImprovedTube.playlistUpNextAutoplay = function () {
if (this.storage.playlist_up_next_autoplay === false) {
- const playlistData = this.elements.ytd_watch?.playlistData;
+ var playlistData = this.elements.ytd_watch?.playlistData;
if (this.getParam(location.href, 'list') && playlistData
&& playlistData.currentIndex
&& playlistData.totalVideos
@@ -141,7 +141,7 @@ ImprovedTube.playlistShuffle = function () {
ImprovedTube.playlistPopupCreateButton = function (playlistID, altButtonStyle, checkVideo) {
"use strict";
if (playlistID == null) return null;
- const button = document.createElement('button'),
+ var button = document.createElement('button'),
svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'),
path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
@@ -153,14 +153,14 @@ ImprovedTube.playlistPopupCreateButton = function (playlistID, altButtonStyle, c
button.addEventListener(
'click',
(checkVideo ?? false) ? function () {
- const videoURL = ImprovedTube.elements.player?.getVideoUrl();
- let width = ImprovedTube.elements.player.offsetWidth * 0.7 ?? innerWidth * 0.4;
- let height = ImprovedTube.elements.player.offsetHeight * 0.7 ?? innerHeight * 0.4;
+ var videoURL = ImprovedTube.elements.player?.getVideoUrl();
+ var width = ImprovedTube.elements.player.offsetWidth * 0.7 ?? innerWidth * 0.4;
+ var height = ImprovedTube.elements.player.offsetHeight * 0.7 ?? innerHeight * 0.4;
"use strict";
if (videoURL != null && ImprovedTube.regex.video_id.test(videoURL)) {
ImprovedTube.elements.player.pauseVideo();
- const listID = this.dataset.list,
+ var listID = this.dataset.list,
videoID = videoURL.match(ImprovedTube.regex.video_id)[1],
popup = window.open(`${location.protocol}//www.youtube.com/embed/${videoID}?autoplay=${ImprovedTube.storage.player_autoplay_disable ? '0' : '1'}&start=${videoURL.match(ImprovedTube.regex.video_time)?.[1] ?? '0'}&list=${listID}`, '_blank', `directories=no,toolbar=no,location=no,menubar=no,status=no,titlebar=no,scrollbars=no,resizable=no,width=${width / 3},height=${height / 3}`);
//! If the video is not in the playlist or not within the first 200 entries, then it automatically selects the first video in the list.
@@ -168,7 +168,7 @@ ImprovedTube.playlistPopupCreateButton = function (playlistID, altButtonStyle, c
popup.addEventListener('load', function () {
"use strict";
//~ check if the video ID in the link of the video title matches the original video ID in the URL and if not reload as a videoseries/playlist (without the videoID and start-time).
- const videoLink = this.document.querySelector('div#player div.ytp-title-text>a[href]');
+ var videoLink = this.document.querySelector('div#player div.ytp-title-text>a[href]');
if (videoLink && videoLink.href.match(ImprovedTube.regex.video_id)[1] !== videoID) this.location.href = `${location.protocol}//www.youtube.com/embed/videoseries?autoplay=${ImprovedTube.storage.player_autoplay_disable ? '0' : '1'}&list=${listID}`;
}, { passive: true, once: true });
} else 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}`);
@@ -180,8 +180,8 @@ ImprovedTube.playlistPopupCreateButton = function (playlistID, altButtonStyle, c
title: document.title
});
} : function () {
- let width = ImprovedTube.elements.player.offsetWidth * 0.7 ?? innerWidth * 0.45;
- let height = ImprovedTube.elements.player.offsetHeight * 0.7 ?? innerHeight * 0.45;
+ var width = ImprovedTube.elements.player.offsetWidth * 0.7 ?? innerWidth * 0.45;
+ var 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 }
@@ -224,23 +224,23 @@ ImprovedTube.playlistPopup = function () {
"use strict";
if (this.storage.playlist_popup) {
- const playlistID = location.search.match(this.regex.playlist_id)?.[1],
+ var playlistID = location.search.match(this.regex.playlist_id)?.[1],
playlistIDMini = this.elements.player?.getPlaylistId?.();
if (!document.contains(this.elements.buttons['it-popup-playlist-button-playlist'])) {
- const playlistShareButton = document.body.querySelector('ytd-app>div#content>ytd-page-manager>ytd-browse>ytd-playlist-header-renderer ytd-button-renderer.ytd-playlist-header-renderer:has(button[title])');
+ var playlistShareButton = document.body.querySelector('ytd-app>div#content>ytd-page-manager>ytd-browse>ytd-playlist-header-renderer ytd-button-renderer.ytd-playlist-header-renderer:has(button[title])');
if (playlistShareButton == null) this.elements.buttons['it-popup-playlist-button-playlist'] = null;
else playlistShareButton.insertAdjacentElement('afterend', this.elements.buttons['it-popup-playlist-button-playlist'] = this.playlistPopupCreateButton(playlistID));
} else if (playlistID != null && this.elements.buttons['it-popup-playlist-button-playlist'].dataset.list !== playlistID) this.elements.buttons['it-popup-playlist-button-playlist'].dataset.list = playlistID;
if (!document.contains(this.elements.buttons['it-popup-playlist-button-mini'])) {
- const miniItemButtons = document.body.querySelector('ytd-app>ytd-miniplayer ytd-playlist-panel-renderer div#top-level-buttons-computed');
+ var miniItemButtons = document.body.querySelector('ytd-app>ytd-miniplayer ytd-playlist-panel-renderer div#top-level-buttons-computed');
if (miniItemButtons == null) this.elements.buttons['it-popup-playlist-button-mini'] = null;
else miniItemButtons.appendChild(this.elements.buttons['it-popup-playlist-button-mini'] = this.playlistPopupCreateButton(playlistIDMini, true, true));
} else if (playlistIDMini != null && this.elements.buttons['it-popup-playlist-button-mini'].dataset.list !== playlistIDMini) this.elements.buttons['it-popup-playlist-button-mini'].dataset.list = playlistIDMini;
try {
if (!document.contains(this.elements.buttons['it-popup-playlist-button-panel'])) {
- const panelItemButtons = document.body.querySelector('ytd-app>div#content>ytd-page-manager>ytd-watch-flexy ytd-playlist-panel-renderer div#top-level-buttons-computed');
+ var panelItemButtons = document.body.querySelector('ytd-app>div#content>ytd-page-manager>ytd-watch-flexy ytd-playlist-panel-renderer div#top-level-buttons-computed');
if (panelItemButtons == null) this.elements.buttons['it-popup-playlist-button-panel'] = null;
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;
diff --git a/js&css/web-accessible/www.youtube.com/settings.js b/js&css/web-accessible/www.youtube.com/settings.js
index 6409407de..cf8c9f1c9 100644
--- a/js&css/web-accessible/www.youtube.com/settings.js
+++ b/js&css/web-accessible/www.youtube.com/settings.js
@@ -163,7 +163,7 @@ ImprovedTube.deleteYoutubeCookies = function () {
-----------------------------------------------------------------------------*/
ImprovedTube.youtubeLanguage = function () {
- let value = this.storage.youtube_language;
+ var value = this.storage.youtube_language;
if (value) {
if (value == 'disabled') {
diff --git a/js&css/web-accessible/www.youtube.com/shortcuts.js b/js&css/web-accessible/www.youtube.com/shortcuts.js
index ad85a0697..63150c817 100644
--- a/js&css/web-accessible/www.youtube.com/shortcuts.js
+++ b/js&css/web-accessible/www.youtube.com/shortcuts.js
@@ -8,18 +8,18 @@ WARNING: Browser Debugger Breakpoint downstream from keydown() event will eat co
------------------------------------------------------------------------------*/
ImprovedTube.shortcutsInit = function () {
// those four are _references_ to source Objects, not copies
- const listening = ImprovedTube.input.listening,
+ var listening = ImprovedTube.input.listening,
listeners = ImprovedTube.input.listeners;
// reset 'listening' shortcuts
for (var key in listening) delete listening[key];
// extract shortcuts from User Settings and initialize 'listening'
- for (const [name, keys] of Object.entries(this.storage).filter(v => v[0].startsWith('shortcut_'))) {
+ for (var [name, keys] of Object.entries(this.storage).filter(v => v[0].startsWith('shortcut_'))) {
if (!keys) continue;
// camelCase(name)
- const camelName = name.replace(/_(.)/g, (m, l) => l.toUpperCase());
- let potentialShortcut = {};
- for (const button of ['alt', 'ctrl', 'shift', 'wheel', 'keys', 'toggle']) {
+ var camelName = name.replace(/_(.)/g, (m, l) => l.toUpperCase());
+ var potentialShortcut = {};
+ for (var button of ['alt', 'ctrl', 'shift', 'wheel', 'keys', 'toggle']) {
switch (button) {
case 'alt':
case 'ctrl':
@@ -42,7 +42,7 @@ ImprovedTube.shortcutsInit = function () {
}
// initialize 'listeners' only if there are actual shortcuts active
if (Object.keys(listening).length) {
- for (const [name, handler] of Object.entries(this.shortcutsListeners)) {
+ for (var [name, handler] of Object.entries(this.shortcutsListeners)) {
// only one listener per handle
if (!listeners[name]) {
listeners[name] = true;
@@ -51,7 +51,7 @@ ImprovedTube.shortcutsInit = function () {
}
} else {
// no shortcuts means we dont need 'listeners', uninstall all
- for (const [name, handler] of Object.entries(this.shortcutsListeners)) {
+ for (var [name, handler] of Object.entries(this.shortcutsListeners)) {
if (listeners[name]) {
delete listeners[name];
window.removeEventListener(name, handler, { passive: false, capture: true });
@@ -61,14 +61,14 @@ ImprovedTube.shortcutsInit = function () {
};
ImprovedTube.shortcutsHandler = function () {
- check: for (const [key, shortcut] of Object.entries(ImprovedTube.input.listening)) {
+ check: for (var [key, shortcut] of Object.entries(ImprovedTube.input.listening)) {
if (ImprovedTube.input.pressed.keys.size != shortcut.keys.size
|| ImprovedTube.input.pressed.wheel != shortcut.wheel
|| ImprovedTube.input.pressed.alt != shortcut.alt
|| ImprovedTube.input.pressed.ctrl != shortcut.ctrl
|| ImprovedTube.input.pressed.shift != shortcut.shift) continue;
- for (const pressedKey of ImprovedTube.input.pressed.keys.values()) {
+ for (var pressedKey of ImprovedTube.input.pressed.keys.values()) {
if (!shortcut.keys.has(pressedKey)) continue check;
}
@@ -77,7 +77,7 @@ ImprovedTube.shortcutsHandler = function () {
event.preventDefault();
event.stopPropagation();
// build 'cancelled' list so we also cancel keyup events
- for (const pressedKey of ImprovedTube.input.pressed.keys.values()) {
+ for (var pressedKey of ImprovedTube.input.pressed.keys.values()) {
ImprovedTube.input.cancelled.add(pressedKey);
}
@@ -148,7 +148,7 @@ ImprovedTube.shortcutToggleAmbientLighting = function () {
4.7.1 QUALITY
------------------------------------------------------------------------------*/
ImprovedTube.shortcutQuality = function (key) {
- const label = ['auto', 'tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'],
+ var label = ['auto', 'tiny', 'small', 'medium', 'large', 'hd720', 'hd1080', 'hd1440', 'hd2160', 'hd2880', 'highres'],
resolution = ['auto', '144p', '240p', '360p', '480p', '720p', '1080p', '1440p', '2160p', '2880p', '4320p'];
ImprovedTube.playerQuality(label[resolution.indexOf(key.replace('shortcutQuality', ''))]);
@@ -161,8 +161,8 @@ ImprovedTube.shortcutPictureInPicture = this.enterPip;
4.7.3 TOGGLE CONTROLS
------------------------------------------------------------------------------*/
ImprovedTube.shortcutToggleControls = function () {
- const player = this.elements.player;
- let option = this.storage.player_hide_controls;
+ var player = this.elements.player;
+ var option = this.storage.player_hide_controls;
if (player && player.hideControls && player.showControls) {
if (option === 'when_paused') {
@@ -185,7 +185,7 @@ ImprovedTube.shortcutToggleControls = function () {
4.7.4 PLAY / PAUSE
------------------------------------------------------------------------------*/
ImprovedTube.shortcutPlayPause = function () {
- const video = this.elements.video;
+ var video = this.elements.video;
if (video) {
if (video.paused) {
video.play();
@@ -290,7 +290,7 @@ ImprovedTube.shortcutSeekPreviousChapter = function () {
4.7.13 INCREASE VOLUME
------------------------------------------------------------------------------*/
ImprovedTube.shortcutIncreaseVolume = function (decrease) {
- const player = this.elements.player,
+ var player = this.elements.player,
value = Number(this.storage.shortcuts_volume_step) || 5,
direction = decrease ? 'Decrease' : 'Increase';
@@ -333,10 +333,10 @@ ImprovedTube.shortcutScreenshot = ImprovedTube.screenshot;
4.7.16 INCREASE PLAYBACK SPEED
------------------------------------------------------------------------------*/
ImprovedTube.shortcutIncreasePlaybackSpeed = function (decrease) {
- const value = Number(this.storage.shortcuts_playback_speed_step) || .05,
+ var value = Number(this.storage.shortcuts_playback_speed_step) || .05,
speed = this.playbackSpeed(),
direction = decrease ? 'Decrease' : 'Increase';
- let newSpeed;
+ var newSpeed;
if (!speed) {
console.error('shortcut' + direction + 'PlaybackSpeed: Cant establish playbackRate/getPlaybackRate');
@@ -387,7 +387,7 @@ ImprovedTube.shortcutActivateFullscreen = function () {
4.7.21 ACTIVATE CAPTIONS
------------------------------------------------------------------------------*/
ImprovedTube.shortcutActivateCaptions = function () {
- const player = this.elements.player;
+ var player = this.elements.player;
if (player && player.toggleSubtitlesOn) {
player.toggleSubtitlesOn();
@@ -395,12 +395,12 @@ ImprovedTube.shortcutActivateCaptions = function () {
};
/*------Chapters------*/
ImprovedTube.shortcutChapters = function () {
- const available = document.querySelector('[target-id*=chapters][visibility*=HIDDEN]') || document.querySelector('[target-id*=chapters]').clientHeight;
+ var available = document.querySelector('[target-id*=chapters][visibility*=HIDDEN]') || document.querySelector('[target-id*=chapters]').clientHeight;
if (available) {
- const modernChapters = document.querySelector('[modern-chapters] #navigation-button button[aria-label]');
+ var modernChapters = document.querySelector('[modern-chapters] #navigation-button button[aria-label]');
modernChapters ? modernChapters.click() : document.querySelector('[target-id*=chapters]')?.removeAttribute('visibility');
} else {
- const visibilityButton = document.querySelector('[target-id*=chapters][visibility*=EXPANDED] #visibility-button button[aria-label]');
+ var visibilityButton = document.querySelector('[target-id*=chapters][visibility*=EXPANDED] #visibility-button button[aria-label]');
visibilityButton ? visibilityButton.click() : document.querySelector('*[target-id*=chapters] #visibility-button button')?.click();
}
if (!modernChapters && visibilityButton) {
@@ -409,12 +409,12 @@ ImprovedTube.shortcutChapters = function () {
};
/*------Transcript------*/
ImprovedTube.shortcutTranscript = function () {
- const available = document.querySelector('[target-id*=transcript][visibility*=HIDDEN]') || document.querySelector('[target-id*=transcript]').clientHeight;
+ var available = document.querySelector('[target-id*=transcript][visibility*=HIDDEN]') || document.querySelector('[target-id*=transcript]').clientHeight;
if (available) {
- const descriptionTranscript = document.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
+ var descriptionTranscript = document.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
descriptionTranscript ? descriptionTranscript.click() : document.querySelector('[target-id*=transcript]')?.removeAttribute('visibility');
} else {
- const transcriptButton = document.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
+ var transcriptButton = document.querySelector('ytd-video-description-transcript-section-renderer button[aria-label]');
transcriptButton ? transcriptButton.click() : document.querySelector('[target-id*=transcript] #visibility-button button')?.click();
}
if (!descriptionTranscript && transcriptButton) {
@@ -511,7 +511,7 @@ ImprovedTube.shortcutCustomMiniPlayer = function () {
Loop
------------------------------------------------------------------------------*/
ImprovedTube.shortcutToggleLoop = function () {
- const video = this.elements.video,
+ var video = this.elements.video,
player = this.elements.player;
function matchLoopState(opacity) {
document.querySelector('#it-repeat-button')?.children[0]?.style.setProperty("opacity", opacity);
@@ -531,7 +531,7 @@ ImprovedTube.shortcutToggleLoop = function () {
4.7.27 STATS FOR NERDS
------------------------------------------------------------------------------*/
ImprovedTube.shortcutStatsForNerds = function () {
- const player = this.elements.player;
+ var player = this.elements.player;
if (!player || !player.isVideoInfoVisible || !player.hideVideoInfo || !player.showVideoInfo) {
console.error('shortcutStatsForNerds: Need valid Player element');
@@ -562,7 +562,7 @@ ImprovedTube.shortcutToggleCards = function () {
4.7.29 POPUP PLAYER
------------------------------------------------------------------------------*/
ImprovedTube.shortcutPopupPlayer = function () {
- const player = this.elements.player;
+ var player = this.elements.player;
if (player && document.documentElement.dataset.pageType === 'video') {
player.pauseVideo();
@@ -574,9 +574,9 @@ ImprovedTube.shortcutPopupPlayer = function () {
4.7.30 ROTATE
------------------------------------------------------------------------------*/
ImprovedTube.shortcutRotateVideo = function () {
- const player = this.elements.player,
+ var player = this.elements.player,
video = this.elements.video;
- let rotate = Number(document.body.dataset.itRotate) || 0,
+ var rotate = Number(document.body.dataset.itRotate) || 0,
transform = '';
if (!player || !video) {
diff --git a/menu/satus.js b/menu/satus.js
index b7a4cb1f7..0dc47a9e3 100644
--- a/menu/satus.js
+++ b/menu/satus.js
@@ -506,10 +506,10 @@ satus.fetch = function (url, success, error, type) {
# GET PROPERTY
--------------------------------------------------------------*/
satus.getProperty = function (object, string) {
- const properties = string.split('.');
+ var properties = string.split('.');
- for (let i = 0, l = properties.length; i < l; i++) {
- const property = properties[i];
+ for (var i = 0, l = properties.length; i < l; i++) {
+ var property = properties[i];
if (object === object[property]) {
if (i === l - 1) {
@@ -526,7 +526,7 @@ satus.getProperty = function (object, string) {
--------------------------------------------------------------*/
satus.indexOf = function (child, parent) {
- let index = 0;
+ var index = 0;
if (satus.isArray(parent)) {
index = parent.indexOf(child);
@@ -589,11 +589,11 @@ satus.on = function (element, listeners) {
});
} else if (satus.isString(listener)) {
element.addEventListener(type, function () {
- let match = this.skeleton.on[event.type].match(/(["'`].+["'`]|[^.()]+)/g),
+ var match = this.skeleton.on[event.type].match(/(["'`].+["'`]|[^.()]+)/g),
target = this.baseProvider;
- for (let i = 0, l = match.length; i < l; i++) {
- let key = match[i];
+ for (var i = 0, l = match.length; i < l; i++) {
+ var key = match[i];
if (target.skeleton && target.skeleton[key]) {
target = target.skeleton[key];
@@ -604,7 +604,7 @@ satus.on = function (element, listeners) {
target = target[key];
// render last element if its not a function, lets us use redirects
if (i == match.length-1 && (typeof target != 'function')) {
- let layers = this.layersProvider;
+ var layers = this.layersProvider;
if (!layers && this.baseProvider.layers.length > 0) {
layers = this.baseProvider.layers[0];
}
@@ -1043,7 +1043,7 @@ satus.locale.import = function (code, callback, path) {
.finally(() => successCallback && successCallback());
}
if (code) {
- let language = code.replace('-', '_');
+ var language = code.replace('-', '_');
if (language.indexOf('_') !== -1) {
importLocale(language, () => importLocale(language.split('_')[0], () => importLocale('en', callback)));
} else {
@@ -1053,9 +1053,9 @@ satus.locale.import = function (code, callback, path) {
try {
chrome.i18n.getAcceptLanguages(function (languages) {
languages = languages.map(language => language.replace('-', '_'));
- for (let i = languages.length - 1; i >= 0; i--) {
+ for (var i = languages.length - 1; i >= 0; i--) {
if (languages[i].includes('_')) {
- let languageWithoutCountryCode = languages[i].substring(0, 2);
+ var languageWithoutCountryCode = languages[i].substring(0, 2);
if (!languages.includes(languageWithoutCountryCode)) {
languages.splice(i + 1, 0, languageWithoutCountryCode);
@@ -1075,7 +1075,7 @@ satus.locale.import = function (code, callback, path) {
} catch (error) {
// Finally, if code nor chrome://settings/languages are available, use window.navigator.language:
- let language = window.navigator.language.replace('-', '_');
+ var language = window.navigator.language.replace('-', '_');
if (language.indexOf('_') !== -1) {
importLocale(language, () => importLocale(language.split('_')[0], () => importLocale('en', callback)));
} else {
@@ -1102,7 +1102,7 @@ satus.text = function (element, value) {
>>> MODAL
--------------------------------------------------------------*/
satus.components.modal = function (component, skeleton) {
- let content = skeleton.content;
+ var content = skeleton.content;
component.scrim = component.createChildElement('div', 'scrim');
component.surface = component.createChildElement('div', 'surface');
@@ -1381,7 +1381,7 @@ satus.components.textField = function (component, skeleton) {
}
if (value.length === 0) {
- let placeholder = component.placeholder;
+ var placeholder = component.placeholder;
if (typeof placeholder === 'function') {
placeholder = placeholder();
@@ -1394,13 +1394,13 @@ satus.components.textField = function (component, skeleton) {
};
cursor.update = function () {
- const component = this.parentNode.parentNode.parentNode,
+ var component = this.parentNode.parentNode.parentNode,
input = component.input,
value = input.value,
start = input.selectionStart,
end = input.selectionEnd,
rows = value.slice(0, start).split('\n');
- let top = 0;
+ var top = 0;
this.style.animation = 'none';
@@ -1456,7 +1456,7 @@ satus.components.textField = function (component, skeleton) {
document.addEventListener('selectionchange', selectionchange);
input.addEventListener('input', function () {
- const component = this.parentNode.parentNode;
+ var component = this.parentNode.parentNode;
if (component.skeleton.storage) {
component.storage.value = this.value;
@@ -1468,7 +1468,7 @@ satus.components.textField = function (component, skeleton) {
});
input.addEventListener('scroll', function () {
- const component = this.parentNode.parentNode;
+ var component = this.parentNode.parentNode;
component.display.style.top = -this.scrollTop + 'px';
component.display.style.left = -this.scrollLeft + 'px';
@@ -1533,9 +1533,9 @@ satus.components.chart.bar = function (component, skeleton) {
}
if (satus.isArray(labels)) {
- let container = component.createChildElement('div', 'labels');
+ var container = component.createChildElement('div', 'labels');
- for (let i = 0, l = labels.length; i < l; i++) {
+ for (var i = 0, l = labels.length; i < l; i++) {
var label = labels[i],
section = container.createChildElement('div', 'section');
@@ -1544,12 +1544,12 @@ satus.components.chart.bar = function (component, skeleton) {
}
if (satus.isArray(datasets)) {
- let container = component.createChildElement('div', 'bars');
+ var container = component.createChildElement('div', 'bars');
- for (let i = 0, l = datasets.length; i < l; i++) {
+ for (var i = 0, l = datasets.length; i < l; i++) {
var dataset = datasets[i];
- for (let j = 0, k = dataset.data.length; j < k; j++) {
+ for (var j = 0, k = dataset.data.length; j < k; j++) {
if (!satus.isElement(bars[j])) {
bars.push(container.createChildElement('div', 'bar'));
}
@@ -1760,14 +1760,14 @@ satus.components.layers = function (component, skeleton) {
--------------------------------------------------------------*/
satus.components.list = function (component, skeleton) {
- for (const item of skeleton.items) {
- const li = component.createChildElement('div', 'item');
+ for (var item of skeleton.items) {
+ var li = component.createChildElement('div', 'item');
- for (const child of item) {
+ for (var child of item) {
if (satus.isObject(child)) {
satus.render(child, li);
} else {
- const span = li.createChildElement('span');
+ var span = li.createChildElement('span');
span.textContent = satus.locale.get(child);
}
@@ -1956,7 +1956,7 @@ satus.components.colorPicker = function (component, skeleton) {
--------------------------------------------------------------*/
satus.components.radio = function (component, skeleton) {
- let value;
+ var value;
component.nativeControl = component.createChildElement('input', 'input');
@@ -1984,13 +1984,13 @@ satus.components.radio = function (component, skeleton) {
}
component.nativeControl.addEventListener('change', function () {
- const component = this.parentNode,
+ var component = this.parentNode,
parent = component.parentNode.parentNode.skeleton;
- let defValue;
+ var defValue;
// determine default value for whole radio section
- for (const key in parent) {
- let item = parent[key];
+ for (var key in parent) {
+ var item = parent[key];
// components can be functions
if (satus.isFunction(item)) {
@@ -2064,7 +2064,7 @@ satus.components.slider = function (component, skeleton) {
});
component.update = function () {
- const input = this.input;
+ var input = this.input;
this.textInput.value = input.value;
if (component.storage) {
@@ -2093,7 +2093,7 @@ satus.components.slider = function (component, skeleton) {
--------------------------------------------------------------*/
satus.components.tabs = function (component, skeleton) {
- let tabs = skeleton.items,
+ var tabs = skeleton.items,
value = skeleton.value;
if (satus.isFunction(tabs)) {
@@ -2104,11 +2104,11 @@ satus.components.tabs = function (component, skeleton) {
value = value();
}
- for (const tab of tabs) {
- const button = component.createChildElement('button');
+ for (var tab of tabs) {
+ var button = component.createChildElement('button');
button.addEventListener('click', function () {
- const component = this.parentNode,
+ var component = this.parentNode,
index = satus.elementIndex(this);
component.value = index;
@@ -2133,7 +2133,7 @@ satus.components.shortcut = function (component, skeleton) {
component.className = 'satus-button';
component.render = function (parent = this.primary) {
- let children = parent.children;
+ var children = parent.children;
satus.empty(parent);
@@ -2203,7 +2203,7 @@ satus.components.shortcut = function (component, skeleton) {
createElement('plus');
}
- let mouse = createElement('mouse'),
+ var mouse = createElement('mouse'),
div = document.createElement('div');
mouse.appendChild(div);
@@ -2216,7 +2216,7 @@ satus.components.shortcut = function (component, skeleton) {
createElement('plus');
}
- let mouse = createElement('mouse'),
+ var mouse = createElement('mouse'),
div = document.createElement('div');
mouse.appendChild(div);
@@ -2229,7 +2229,7 @@ satus.components.shortcut = function (component, skeleton) {
createElement('plus');
}
- let mouse = createElement('mouse'),
+ var mouse = createElement('mouse'),
div = document.createElement('div');
mouse.appendChild(div);
@@ -3145,7 +3145,7 @@ satus.user.device.connection = function () {
--------------------------------------------------------------*/
satus.search = function (query, object, callback) {
- const included = ['switch', 'select', 'slider', 'shortcut', 'radio', 'color-picker', 'label', 'button'],
+ var included = ['switch', 'select', 'slider', 'shortcut', 'radio', 'color-picker', 'label', 'button'],
excluded = [
'baseProvider',
'layersProvider',
@@ -3156,7 +3156,7 @@ satus.search = function (query, object, callback) {
'parentElement',
'rendered'
];
- let threads = 0,
+ var threads = 0,
results = {};
query = query.toLowerCase();
@@ -3164,7 +3164,7 @@ satus.search = function (query, object, callback) {
function parse (items) {
threads++;
- for (const [key, item] of Object.entries(items)) {
+ for (var [key, item] of Object.entries(items)) {
if (!excluded.includes(key)) {
if (item.component && item.text
// list of elements we allow search on
@@ -3199,7 +3199,7 @@ satus.search = function (query, object, callback) {
# count
--------------------------------------------------------------*/
function createInput (placeholder, onChange) {
- const input = document.createElement('input');
+ var input = document.createElement('input');
input.type = 'number';
input.placeholder = placeholder;
input.addEventListener('change', onChange);
@@ -3207,10 +3207,10 @@ function createInput (placeholder, onChange) {
}
function createSelect (options, changeHandler) {
- const select = document.createElement('select');
+ var select = document.createElement('select');
- for (const optionData of options) {
- const option = document.createElement('option');
+ for (var optionData of options) {
+ var option = document.createElement('option');
option.text = optionData.text;
option.value = optionData.value;
select.add(option);
@@ -3227,16 +3227,16 @@ function createSelect (options, changeHandler) {
satus.components.countComponent = function (component) {
component.style.display = satus.storage.get('ads') === 'small_creators' ? 'flex' : 'none';
- const countLabelText = document.createElement('span');
+ var countLabelText = document.createElement('span');
countLabelText.textContent = 'Maximum number of subscribers';
component.appendChild(countLabelText);
- const countInput = createInput('130000', function (event) {
+ var countInput = createInput('130000', function (event) {
satus.storage.set('smallCreatorsCount', event.target.value);
});
// Set the initial value from storage if available
- const storedValue = satus.storage.get('smallCreatorsCount');
+ var storedValue = satus.storage.get('smallCreatorsCount');
if (storedValue !== undefined) {
countInput.value = storedValue;
}
@@ -3247,7 +3247,7 @@ satus.components.countComponent = function (component) {
component.appendChild(countInput);
- const selectionDropdown = createSelect([
+ var selectionDropdown = createSelect([
{ text: ' ', value: '1' },
{ text: 'K', value: '1000' },
{ text: 'M', value: '1000000' }
@@ -3255,7 +3255,7 @@ satus.components.countComponent = function (component) {
satus.storage.set('smallCreatorsUnit', event.target.value);
});
- const storedUnitValue = satus.storage.get('smallCreatorsUnit');
+ var storedUnitValue = satus.storage.get('smallCreatorsUnit');
if (storedUnitValue !== undefined) {
selectionDropdown.value = storedUnitValue;
}
diff --git a/menu/skeleton-parts/active-features.js b/menu/skeleton-parts/active-features.js
index 9fd71a2b8..ff725bf5d 100644
--- a/menu/skeleton-parts/active-features.js
+++ b/menu/skeleton-parts/active-features.js
@@ -10,18 +10,18 @@ extension.skeleton.header.sectionEnd.menu.on.click.activeFeatures = {
variant: 'card',
on: {
render: function () {
- let component = this;
+ var component = this;
satus.search('', extension.skeleton, function (features) {
- let skeleton = {};
+ var skeleton = {};
- for (const [key, feature] of Object.entries(features)) {
+ for (var [key, feature] of Object.entries(features)) {
// search returns buttons now, skip those
if (feature.component === 'button') {
continue;
}
- let default_value = feature.value,
+ var default_value = feature.value,
value = feature.storage && satus.storage.get(feature.storage)
|| feature.radio && satus.storage.get(feature.radio.group) == feature.radio.value
|| satus.storage.get(key),
@@ -46,7 +46,7 @@ extension.skeleton.header.sectionEnd.menu.on.click.activeFeatures = {
}
if (parent_object.parentObject) {
- let category = parent_object.parentObject.label.text,
+ var category = parent_object.parentObject.label.text,
subcategory,
text;
diff --git a/menu/skeleton-parts/blocklist.js b/menu/skeleton-parts/blocklist.js
index 819b63d62..e91d63aa1 100644
--- a/menu/skeleton-parts/blocklist.js
+++ b/menu/skeleton-parts/blocklist.js
@@ -29,12 +29,12 @@ extension.skeleton.main.layers.section.blocklist = {
variant: 'card',
on: {
render: function () {
- let skeleton = {},
+ var skeleton = {},
blocklist = satus.storage.get('blocklist');
if (blocklist && blocklist.channels) {
- for (let key in blocklist.channels) {
- let channel = blocklist.channels[key];
+ for (var key in blocklist.channels) {
+ var channel = blocklist.channels[key];
if (channel ) {
skeleton[key] = {
@@ -52,7 +52,7 @@ extension.skeleton.main.layers.section.blocklist = {
component: 'button',
on: {
click: function () {
- let blocklist = satus.storage.get('blocklist'),
+ var blocklist = satus.storage.get('blocklist'),
component = this.parentNode;
if (blocklist && blocklist.channels) {
@@ -104,7 +104,7 @@ extension.skeleton.main.layers.section.blocklist = {
},
on: {
render: function () {
- let blocklist = satus.storage.get('blocklist');
+ var blocklist = satus.storage.get('blocklist');
if (blocklist && blocklist.channels && Object.keys(blocklist.channels).length) {
this.textContent = '('+Object.keys(blocklist.channels).length+')';
@@ -127,12 +127,12 @@ extension.skeleton.main.layers.section.blocklist = {
variant: 'card',
on: {
render: function () {
- let skeleton = {},
+ var skeleton = {},
blocklist = satus.storage.get('blocklist');
if (blocklist && blocklist.videos) {
- for (let key in blocklist.videos) {
- let video = blocklist.videos[key];
+ for (var key in blocklist.videos) {
+ var video = blocklist.videos[key];
if (video ) {
skeleton[key] = {
@@ -150,7 +150,7 @@ extension.skeleton.main.layers.section.blocklist = {
component: 'button',
on: {
click: function () {
- let blocklist = satus.storage.get('blocklist'),
+ var blocklist = satus.storage.get('blocklist'),
component = this.parentNode;
if (blocklist && blocklist.videos) {
@@ -202,7 +202,7 @@ extension.skeleton.main.layers.section.blocklist = {
},
on: {
render: function () {
- let blocklist = satus.storage.get('blocklist');
+ var blocklist = satus.storage.get('blocklist');
if (blocklist && blocklist.videos && Object.keys(blocklist.videos).length) {
this.textContent = '('+Object.keys(blocklist.videos).length+')';
diff --git a/menu/skeleton-parts/dark-light-switch.js b/menu/skeleton-parts/dark-light-switch.js
index cba967913..40898c228 100644
--- a/menu/skeleton-parts/dark-light-switch.js
+++ b/menu/skeleton-parts/dark-light-switch.js
@@ -1,7 +1,7 @@
-const isDark = () => {
- const themeElement = satus.storage.get('theme')
-// const lightThemes = ['desert', 'dawn', 'plain', 'default']
- const darkThemes = ['sunset', 'night', 'dark', 'black']
+var isDark = () => {
+ var themeElement = satus.storage.get('theme')
+// var lightThemes = ['desert', 'dawn', 'plain', 'default']
+ var darkThemes = ['sunset', 'night', 'dark', 'black']
return darkThemes.includes(themeElement)
}
diff --git a/menu/skeleton-parts/general.js b/menu/skeleton-parts/general.js
index a12841953..62206d15d 100644
--- a/menu/skeleton-parts/general.js
+++ b/menu/skeleton-parts/general.js
@@ -71,10 +71,10 @@ extension.skeleton.main.layers.section.general = {
on: {
change: function (event) {
- const selectedValue = event.target.value;
+ var selectedValue = event.target.value;
// Perform actions based on the selected value
- const numberOfSubscribersInput = this.parentNode.querySelector('.count-component');
+ var numberOfSubscribersInput = this.parentNode.querySelector('.count-component');
if (selectedValue === 'small_creators') {
numberOfSubscribersInput.style.display = 'flex';
} else {
diff --git a/menu/skeleton-parts/player.js b/menu/skeleton-parts/player.js
index 86811e054..c3d62cda6 100644
--- a/menu/skeleton-parts/player.js
+++ b/menu/skeleton-parts/player.js
@@ -103,7 +103,7 @@ extension.skeleton.main.layers.section.player.on.click = {
click: function () {
if (!document.pictureInPictureEnabled) return;
if (this.dataset.value === 'false') {
- let where = this;
+ var where = this;
satus.render({
component: 'modal',
variant: 'confirm',
@@ -759,7 +759,7 @@ extension.skeleton.main.layers.section.player.on.click = {
on: {
render: function () {
// relies on options.text above auto always starting with a number for parseInt to work
- const options = this.childNodes[2].options,
+ var options = this.childNodes[2].options,
index = this.childNodes[2].selectedIndex;
cutoff = 1080;
if (satus.storage.get('player_h264')) {
@@ -770,7 +770,7 @@ extension.skeleton.main.layers.section.player.on.click = {
this.childNodes[1].removeAttribute('style');
this.childNodes[1].textContent = options[index].text;
}
- for (const [i, node] of Array.from(options).entries()) {
+ for (var [i, node] of Array.from(options).entries()) {
if (parseInt(node.text) > cutoff) {
this.childNodes[2].childNodes[i].style = 'color: red!important; font-weight: bold;';
}
@@ -781,7 +781,7 @@ extension.skeleton.main.layers.section.player.on.click = {
} else {
this.childNodes[1].removeAttribute('style');
this.childNodes[1].textContent = options[index].text;
- for (const node of options) {
+ for (var node of options) {
node.removeAttribute('style');
}
}
@@ -865,7 +865,7 @@ extension.skeleton.main.layers.section.player.on.click = {
click: function () {
if (this.dataset.value === 'false') {
if (satus.storage.get('block_h264')) {
- let where = this;
+ var where = this;
satus.render({
component: 'modal',
variant: 'confirm',
@@ -897,7 +897,7 @@ extension.skeleton.main.layers.section.player.on.click = {
click: function () {
if (this.dataset.value === 'false') {
if (satus.storage.get('block_vp9')) {
- let where = this;
+ var where = this;
satus.render({
component: 'modal',
variant: 'confirm',
@@ -965,9 +965,9 @@ extension.skeleton.main.layers.section.player.on.click = {
custom: true,
on: {
click: function () {
- //let skeleton = this.parentNode.skeleton;
+ //var skeleton = this.parentNode.skeleton;
// refresh player_codecs/optimize_codec_for_hardware_acceleration elements when we change codecs
- let refresh = function () {
+ var refresh = function () {
document.getElementById('player_quality').dispatchEvent(new CustomEvent('render'));
document.getElementById('player_codecs').dispatchEvent(new CustomEvent('render'));
document.getElementById('optimize_codec_for_hardware_acceleration').dispatchEvent(new CustomEvent('render'));
@@ -975,7 +975,7 @@ extension.skeleton.main.layers.section.player.on.click = {
//document.getElementById('quality_when_low_battery').dispatchEvent(new CustomEvent('render'));
}
if (this.dataset.value === 'false') {
- let where = this;
+ var where = this;
satus.render({
component: 'modal',
variant: 'confirm',
@@ -1092,7 +1092,7 @@ extension.skeleton.main.layers.section.player.on.click = {
component: 'select',
text: 'saveAs',
options: function () {
- let options = [{
+ var options = [{
text: 'file',
value: 'file'
}];
diff --git a/menu/skeleton-parts/search.js b/menu/skeleton-parts/search.js
index 0678117e2..98f4efbde 100644
--- a/menu/skeleton-parts/search.js
+++ b/menu/skeleton-parts/search.js
@@ -23,7 +23,7 @@ extension.skeleton.header.sectionEnd.search.on.click = {
},
blur: function () {
if (this.value.length === 0) {
- let search_results = document.querySelector('.search-results');
+ var search_results = document.querySelector('.search-results');
if (search_results) {
search_results.close();
@@ -33,21 +33,21 @@ extension.skeleton.header.sectionEnd.search.on.click = {
}
},
input: function (event) {
- let self = this,
+ var self = this,
value = this.value.trim();
this.skeleton.search = value;
if (value.length > 0) {
satus.search(value, extension.skeleton, function (results) {
- let search_results = document.querySelector('.search-results'),
+ var search_results = document.querySelector('.search-results'),
skeleton = {
component: 'modal',
class: 'search-results'
};
- for (let key in results) {
- let result = results[key],
+ for (var key in results) {
+ var result = results[key],
parent = result,
category,
subcategory,
@@ -123,7 +123,7 @@ extension.skeleton.header.sectionEnd.search.on.click = {
}
} else {
if (search_results) {
- let surface = document.querySelector('.search-results .satus-modal__surface');
+ var surface = document.querySelector('.search-results .satus-modal__surface');
satus.empty(surface);
@@ -162,7 +162,7 @@ extension.skeleton.header.sectionEnd.search.on.click = {
document.querySelector('.search-results .satus-modal__scrim').addEventListener('click', function () {
// this is someone clicking outside of Search results window
- let search_results = document.querySelector('.search-results');
+ var search_results = document.querySelector('.search-results');
if (search_results) {
self.skeleton.searchPosition = search_results.childNodes[1].scrollTop;
@@ -175,7 +175,7 @@ extension.skeleton.header.sectionEnd.search.on.click = {
}
});
} else {
- let search_results = document.querySelector('.search-results');
+ var search_results = document.querySelector('.search-results');
if (search_results) {
search_results.close();
@@ -191,7 +191,7 @@ extension.skeleton.header.sectionEnd.search.on.click = {
variant: 'icon',
on: {
click: function () {
- let search_results = document.querySelector('.search-results');
+ var search_results = document.querySelector('.search-results');
if (search_results) {
this.parentNode.skeleton.searchPosition = search_results.childNodes[1].scrollTop;
diff --git a/menu/skeleton.js b/menu/skeleton.js
index 61dc6b683..01437bc0d 100644
--- a/menu/skeleton.js
+++ b/menu/skeleton.js
@@ -8,7 +8,7 @@
/*--------------------------------------------------------------
# BASE
--------------------------------------------------------------*/
-let extension = {
+var extension = {
skeleton: {
component: 'base'
}
diff --git a/tests/eslint_rules.config.mjs b/tests/eslint_rules.config.mjs
index 4a7c329b4..9a8e4d335 100644
--- a/tests/eslint_rules.config.mjs
+++ b/tests/eslint_rules.config.mjs
@@ -1,4 +1,4 @@
-const rules = {
+var rules = {
indent: ["error", "tab", {"SwitchCase": 1}],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"no-empty": ["error", { "allowEmptyCatch": true }],
@@ -31,15 +31,15 @@ import { FlatCompat } from "@eslint/eslintrc";
import { fixupConfigRules } from '@eslint/compat';
import eslintPluginCompat from 'eslint-plugin-compat';
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-const compat = new FlatCompat({
+var __filename = fileURLToPath(import.meta.url);
+var __dirname = path.dirname(__filename);
+var compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
-const compatConfiguration = fixupConfigRules(
+var compatConfiguration = fixupConfigRules(
eslintPluginCompat.configs['flat/recommended'],
)
diff --git a/tests/unit/core.test.js b/tests/unit/core.test.js
index 7efa82e9a..06cf15c51 100644
--- a/tests/unit/core.test.js
+++ b/tests/unit/core.test.js
@@ -36,11 +36,11 @@ jest.mock('../../js&css/extension/core', () => ({
listeners: {},
on: jest.fn(),
trigger: async function (type, data) {
- const listeners = this.listeners[type];
+ var listeners = this.listeners[type];
if (listeners) {
- for (let i = 0, l = listeners.length; i < l; i++) {
- const listener = listeners[i];
+ for (var i = 0, l = listeners.length; i < l; i++) {
+ var listener = listeners[i];
if (typeof listener === 'function') {
if (listener instanceof (async function () { }).constructor ) {
@@ -57,26 +57,26 @@ jest.mock('../../js&css/extension/core', () => ({
}));
// Mock extension object
-const extensionMock = require('../../js&css/extension/core');
+var extensionMock = require('../../js&css/extension/core');
// Unit tests for the camelize function
test('Convert snake_case to camelCase', () => {
- const input = 'snake_case_example';
- const expectedOutput = 'snakeCaseExample';
+ var input = 'snake_case_example';
+ var expectedOutput = 'snakeCaseExample';
- const mockInput = extensionMock.camelize(input);
+ var mockInput = extensionMock.camelize(input);
expect(mockInput).toBe(expectedOutput);
});
test('Convert kebab-case to camelCase', () => {
// Define input and expected output
- const input = 'kebab-case-example';
- const expectedOutput = 'kebabCaseExample';
+ var input = 'kebab-case-example';
+ var expectedOutput = 'kebabCaseExample';
// Call the camelize function with the input
- const mockInput = extensionMock.camelize(input);
+ var mockInput = extensionMock.camelize(input);
// Check if the result matches the expected output
expect(mockInput).toBe(expectedOutput);
@@ -85,9 +85,9 @@ test('Convert kebab-case to camelCase', () => {
// Unit test for the events method
test('Trigger method should correctly retrieve and invoke listeners', () => {
// Mock event listeners
- const listener1 = jest.fn();
- const listener2 = jest.fn();
- const listener3 = jest.fn();
+ var listener1 = jest.fn();
+ var listener2 = jest.fn();
+ var listener3 = jest.fn();
// Register listeners for a specific event type
extensionMock.events.listeners['eventType'] = [listener1, listener2, listener3];
@@ -103,7 +103,7 @@ test('Trigger method should correctly retrieve and invoke listeners', () => {
test('Trigger method should handle asynchronous listeners', async () => {
// Mock asynchronous event listeners
- const asyncListener = jest.fn().mockImplementation(async () => {
+ var asyncListener = jest.fn().mockImplementation(async () => {
// Simulate asynchronous behavior
await new Promise(resolve => setTimeout(resolve, 100));
});