Skip to content

Commit

Permalink
redo braces & spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Jul 8, 2024
1 parent a60bb38 commit 324299f
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 159 deletions.
93 changes: 93 additions & 0 deletions build/manifest3Firefox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"manifest_version": 3,
"short_name": "ImprovedTube",
"name": "'Improve YouTube!' 🎧 (for YouTube & Videos)",
"description": "__MSG_description_ext__",
"version": "4.1077",
"default_locale": "en",
"icons": {
"128": "menu/icons/128.png",
"16": "menu/icons/16.png",
"32": "menu/icons/32.png",
"48": "menu/icons/48.png"
},
"browser_specific_settings": {
"gecko": {
"id": "{3c6bf0cc-3ae2-42fb-9993-0d33104fdcaf}"
}
},
"background": {
"background.scripts": "background.js",
"scripts": [ "background.js" ]
},
"action": {
"default_popup": "menu/index.html",
"default_area": "navbar"
},
"options_page": "menu/index.html",
"options_ui": {
"page": "menu/index.html"
},
"content_scripts": [
{
"all_frames": true,
"css": [
"js&css/extension/www.youtube.com/styles.css",
"js&css/extension/www.youtube.com/night-mode/night-mode.css",
"js&css/extension/www.youtube.com/general/general.css",
"js&css/extension/www.youtube.com/appearance/header/header.css",
"js&css/extension/www.youtube.com/appearance/player/player.css",
"js&css/extension/www.youtube.com/appearance/details/details.css",
"js&css/extension/www.youtube.com/appearance/sidebar/sidebar.css",
"js&css/extension/www.youtube.com/appearance/comments/comments.css"
],
"exclude_matches": [
"https://www.youtube.com/audiolibrary/*",
"https://www.youtube.com/tv*"
],
"js": [
"js&css/extension/core.js",
"js&css/extension/functions.js",
"js&css/extension/www.youtube.com/night-mode/night-mode.js",
"js&css/extension/www.youtube.com/general/general.js",
"js&css/extension/www.youtube.com/appearance/sidebar/sidebar.js",
"js&css/extension/www.youtube.com/appearance/comments/comments.js",
"js&css/extension/init.js"
],
"matches": [
"https://www.youtube.com/*"
],
"run_at": "document_start"
}
],
"host_permissions": [ "https://www.youtube.com/*" ],
"optional_permissions": [
"downloads"
],
"permissions": [
"contextMenus",
"storage"
],
"web_accessible_resources": [
{
"resources": [
"menu/index.html",
"js&css/web-accessible/core.js",
"js&css/web-accessible/functions.js",
"js&css/web-accessible/www.youtube.com/appearance.js",
"js&css/web-accessible/www.youtube.com/player.js",
"js&css/web-accessible/www.youtube.com/themes.js",
"js&css/web-accessible/www.youtube.com/playlist.js",
"js&css/web-accessible/www.youtube.com/channel.js",
"js&css/web-accessible/www.youtube.com/shortcuts.js",
"js&css/web-accessible/www.youtube.com/blocklist.js",
"js&css/web-accessible/www.youtube.com/settings.js",
"js&css/web-accessible/init.js",
"menu/icons/48.png"
],
"matches": [
"https://www.youtube.com/*"
]
}
]
}
3 changes: 2 additions & 1 deletion js&css/extension/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
--------------------------------------------------------------*/
extension.functions.getUrlParameter = function (url, parameter) {
var match = url.match(new RegExp('(\\?|\\&)' + parameter + '=[^&]+'));
if (match) {return match[0].substr(3);}};
if (match) {return match[0].substr(3);}
};
6 changes: 4 additions & 2 deletions js&css/extension/www.youtube.com/general/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ extension.features.markWatchedVideos = function (anything) {
target.itMarkWatchedVideosButton.appendChild(svg);
target.itMarkWatchedVideosButton.appendChild(svg2);
if (extension.storage.get('watched') && extension.storage.get('watched')[id]) {
target.itMarkWatchedVideosButton.setAttribute('watched', '')};
target.itMarkWatchedVideosButton.setAttribute('watched', '')
};
target.appendChild(target.itMarkWatchedVideosButton);
target.itMarkWatchedVideosButton.addEventListener('click', function (event) {
var id = this.dataset.id,
Expand All @@ -379,7 +380,8 @@ extension.features.markWatchedVideos = function (anything) {

chrome.storage.local.set({
watched: extension.storage.get('watched')
});});
});
});

} else {
var button = target.itMarkWatchedVideosButton;
Expand Down
5 changes: 3 additions & 2 deletions js&css/web-accessible/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ document.addEventListener('it-message-from-extension', function () {
case 'playerForcedPlaybackSpeed':
if (ImprovedTube.storage.player_forced_playback_speed === true) {
ImprovedTube.elements.player.setPlaybackRate(Number(ImprovedTube.storage.player_playback_speed));
ImprovedTube.elements.player.querySelector('video').playbackRate = Number(ImprovedTube.storage.player_playback_speed);
ImprovedTube.elements.player.querySelector('video').playbackRate = Number(ImprovedTube.storage.player_playback_speed).toFixed(2);
} else if (ImprovedTube.storage.player_forced_playback_speed === false) {
ImprovedTube.elements.player.setPlaybackRate(1);
ImprovedTube.elements.player.querySelector('video').playbackRate = 1;
Expand Down Expand Up @@ -397,7 +397,8 @@ document.addEventListener('it-message-from-extension', function () {
break
case 'playerlistUpNextAutoplay':
if (this.storage.playlist_up_next_autoplay !== false) {
if (playlistData.currentIndex != playlistData.localCurrentIndex) { playlistData.currentIndex = playlistData.localCurrentIndex;} }
if (playlistData.currentIndex != playlistData.localCurrentIndex) { playlistData.currentIndex = playlistData.localCurrentIndex;}
}
break
}

Expand Down
24 changes: 21 additions & 3 deletions js&css/web-accessible/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ ImprovedTube.ytElementsHandler = function (node) {

this.improvedtubeYoutubeIcon();
}
}
else if (name === 'TP-YT-APP-DRAWER') {
} else if (name === 'TP-YT-APP-DRAWER') {
if (!this.elements.app_drawer) {
this.elements.app_drawer = {start: node.querySelector('div#header'),
logo: node.querySelector('a#logo')
Expand Down Expand Up @@ -416,9 +415,27 @@ ImprovedTube.playerOnEnded = function (event) {
ImprovedTube.played_time = 0;
};

// https://github.com/code-charity/youtube/pull/2431
ImprovedTube.onkeydown = function () {
ImprovedTube.pauseWhileTypingOnYoutube()
window.addEventListener('keydown', function () {
ImprovedTube.user_interacted = true;
}, true);
};

ImprovedTube.onmousedown = function (event) {
window.addEventListener('mousedown', function (event) {
ImprovedTube.user_interacted = true;
}, true);
};

/*
ImprovedTube.onkeydown = function () {
ImprovedTube.pauseWhileTypingOnYoutube()
window.addEventListener('keydown', function () {
if (!ImprovedTube.user_interacted) {
setTimeout(function () {ImprovedTube.user_interacted = true}, 2500);
}
if (ImprovedTube.elements.player && ImprovedTube.elements.player.classList.contains('ad-showing') === false) {
ImprovedTube.user_interacted = true;
}
Expand All @@ -428,7 +445,7 @@ ImprovedTube.onkeydown = function () {
ImprovedTube.onmousedown = function () {
window.addEventListener('mousedown', function (event) {
if (!ImprovedTube.user_interacted) {
setTimeout(function () {ImprovedTube.user_interacted = true}, 3000);
setTimeout(function () {ImprovedTube.user_interacted = true}, 2500);
if (ImprovedTube.elements.player && ImprovedTube.elements.player.classList.contains('ad-showing') === false) {
var path = event.composedPath();
for (var i = 0, l = path.length; i < l; i++) {
Expand All @@ -441,6 +458,7 @@ ImprovedTube.onmousedown = function () {
}
}, true);
};
*/

ImprovedTube.getParam = function (query, name) {
var params = query.split('&'),
Expand Down
7 changes: 3 additions & 4 deletions js&css/web-accessible/www.youtube.com/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ ImprovedTube.channelCompactTheme = function () {
document.querySelector("#sections #items") ? styleWithListeners() : styleWithInterval();
}
else if (compact.hasApplied) { //cleanup
try {clearInterval(compact.listener)}
catch (err) {console.log("ERR: We couldn't clear listener. Reload page")}
try {clearInterval(compact.listener)
} catch (err) {console.log("ERR: We couldn't clear listener. Reload page")}
if (compact.eventHandlerFns.length) removeListeners();
if (compact.styles.length) removeStyles()
compact = {}
Expand Down Expand Up @@ -92,8 +92,7 @@ ImprovedTube.channelCompactTheme = function () {
if (!isCompact) {
sub.style.display = "none"
isCompact = true
}
else {
} else {
sub.style.display = ""
isCompact = false
}
Expand Down
Loading

0 comments on commit 324299f

Please sign in to comment.