Lint js and css files

This commit is contained in:
ChunkyProgrammer 2023-12-19 18:27:43 -05:00
parent 3b31d4881a
commit b5053aa8eb
7 changed files with 61 additions and 49 deletions

View File

@ -83,8 +83,8 @@ body a.channel-owner {
.creator-heart-container { .creator-heart-container {
display: inline-block; display: inline-block;
padding: 0px 7px 6px 0px; padding: 0 7px 6px 0;
margin: 0px -7px -4px 0px; margin: 0 -7px -4px 0;
} }
.creator-heart { .creator-heart {
@ -98,7 +98,7 @@ body a.channel-owner {
.creator-heart-background-hearted { .creator-heart-background-hearted {
width: 16px; width: 16px;
height: 16px; height: 16px;
padding: 0px; padding: 0;
position: relative; position: relative;
} }
@ -142,6 +142,12 @@ div {
animation: spin 2s linear infinite; animation: spin 2s linear infinite;
} }
@media screen and (prefers-reduced-motion: reduce) {
.loading {
animation: none;
}
}
.playlist-restricted { .playlist-restricted {
height: 20em; height: 20em;
padding-right: 10px; padding-right: 10px;

View File

@ -207,9 +207,9 @@ ul.vjs-menu-content::-webkit-scrollbar {
} }
.video-js .vjs-time-divider { .video-js .vjs-time-divider {
min-width: 0px; min-width: 0;
padding-left: 0px; padding-left: 0;
padding-right: 0px; padding-right: 0;
} }
.video-js .vjs-poster { .video-js .vjs-poster {

View File

@ -147,7 +147,7 @@ window.helpers = window.helpers || {
* @param {callbackXhrError} [callbacks.onError] * @param {callbackXhrError} [callbacks.onError]
* @param {callbackXhrError} [callbacks.onTotalFail] - if failed after all retries * @param {callbackXhrError} [callbacks.onTotalFail] - if failed after all retries
*/ */
xhr: function(method, url, options, callbacks) { xhr: function(method, url, options, callbacks) {
if (!options.retries || options.retries <= 1) { if (!options.retries || options.retries <= 1) {
helpers._xhr(method, url, options, callbacks); helpers._xhr(method, url, options, callbacks);
return; return;
@ -202,7 +202,7 @@ window.helpers = window.helpers || {
if (localStorageIsUsable) { if (localStorageIsUsable) {
return { return {
get: function (key) { get: function (key) {
let storageItem = localStorage.getItem(key) let storageItem = localStorage.getItem(key);
if (!storageItem) return; if (!storageItem) return;
try { try {
return JSON.parse(decodeURIComponent(storageItem)); return JSON.parse(decodeURIComponent(storageItem));
@ -211,9 +211,9 @@ window.helpers = window.helpers || {
helpers.storage.remove(key); helpers.storage.remove(key);
} }
}, },
set: function (key, value) { set: function (key, value) {
let encoded_value = encodeURIComponent(JSON.stringify(value)) let encoded_value = encodeURIComponent(JSON.stringify(value));
localStorage.setItem(key, encoded_value); localStorage.setItem(key, encoded_value);
}, },
remove: function (key) { localStorage.removeItem(key); } remove: function (key) { localStorage.removeItem(key); }
}; };

View File

@ -4,7 +4,7 @@ var spinnerHTML = '<h3 style="text-align:center"><div class="loading"><i class="
var spinnerHTMLwithHR = spinnerHTML + '<hr>'; var spinnerHTMLwithHR = spinnerHTML + '<hr>';
String.prototype.supplant = function (o) { String.prototype.supplant = function (o) {
return this.replace(/{([^{}]*)}/g, function (a, b) { return this.replace(/\{([^{}]*)\}/g, function (a, b) {
var r = o[b]; var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a; return typeof r === 'string' || typeof r === 'number' ? r : a;
}); });
@ -58,14 +58,14 @@ function get_youtube_comments() {
var fallback = comments.innerHTML; var fallback = comments.innerHTML;
comments.innerHTML = spinnerHTML; comments.innerHTML = spinnerHTML;
var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id;
var url = baseUrl + var url = baseUrl +
'?format=html' + '?format=html' +
'&hl=' + video_data.preferences.locale + '&hl=' + video_data.preferences.locale +
'&thin_mode=' + video_data.preferences.thin_mode; '&thin_mode=' + video_data.preferences.thin_mode;
if (video_data.ucid) { if (video_data.ucid) {
url += '&ucid=' + video_data.ucid url += '&ucid=' + video_data.ucid;
} }
var onNon200 = function (xhr) { comments.innerHTML = fallback; }; var onNon200 = function (xhr) { comments.innerHTML = fallback; };
@ -81,17 +81,17 @@ function get_youtube_comments() {
{commentsText} \ {commentsText} \
</h3> \ </h3> \
<b> \ <b> \
' ';
if (video_data.support_reddit) { if (video_data.support_reddit) {
commentInnerHtml += ' <a href="javascript:void(0)" data-comments="reddit"> \ commentInnerHtml += ' <a href="javascript:void(0)" data-comments="reddit"> \
{redditComments} \ {redditComments} \
</a> \ </a> \
' ';
} }
commentInnerHtml += ' </b> \ commentInnerHtml += ' </b> \
</div> \ </div> \
<div>{contentHtml}</div> \ <div>{contentHtml}</div> \
<hr>' <hr>';
commentInnerHtml = commentInnerHtml.supplant({ commentInnerHtml = commentInnerHtml.supplant({
contentHtml: response.contentHtml, contentHtml: response.contentHtml,
redditComments: video_data.reddit_comments_text, redditComments: video_data.reddit_comments_text,
@ -125,7 +125,7 @@ function get_youtube_replies(target, load_more, load_replies) {
var body = target.parentNode.parentNode; var body = target.parentNode.parentNode;
var fallback = body.innerHTML; var fallback = body.innerHTML;
body.innerHTML = spinnerHTML; body.innerHTML = spinnerHTML;
var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id var baseUrl = video_data.base_url || '/api/v1/comments/'+ video_data.id;
var url = baseUrl + var url = baseUrl +
'?format=html' + '?format=html' +
'&hl=' + video_data.preferences.locale + '&hl=' + video_data.preferences.locale +
@ -133,7 +133,7 @@ function get_youtube_replies(target, load_more, load_replies) {
'&continuation=' + continuation; '&continuation=' + continuation;
if (video_data.ucid) { if (video_data.ucid) {
url += '&ucid=' + video_data.ucid url += '&ucid=' + video_data.ucid;
} }
if (load_replies) url += '&action=action_get_comment_replies'; if (load_replies) url += '&action=action_get_comment_replies';
@ -171,4 +171,4 @@ function get_youtube_replies(target, load_more, load_replies) {
body.innerHTML = fallback; body.innerHTML = fallback;
} }
}); });
} }

View File

@ -73,6 +73,7 @@
el.onclick = function () { remove_subscription(el); }; el.onclick = function () { remove_subscription(el); };
}); });
document.querySelectorAll('[data-onclick="notification_requestPermission"]').forEach(function (el) { document.querySelectorAll('[data-onclick="notification_requestPermission"]').forEach(function (el) {
// eslint-disable-next-line compat/compat
el.onclick = function () { Notification.requestPermission(); }; el.onclick = function () { Notification.requestPermission(); };
}); });
@ -132,7 +133,7 @@
// Ignore shortcuts if any text input is focused // Ignore shortcuts if any text input is focused
let focused_tag = document.activeElement.tagName.toLowerCase(); let focused_tag = document.activeElement.tagName.toLowerCase();
const allowed = /^(button|checkbox|file|radio|submit)$/; const allowed = /^(?:button|checkbox|file|radio|submit)$/;
if (focused_tag === 'textarea') return; if (focused_tag === 'textarea') return;
if (focused_tag === 'input') { if (focused_tag === 'input') {

View File

@ -188,8 +188,12 @@ if (location.pathname.startsWith('/embed/')) {
// Detection code taken from https://stackoverflow.com/a/20293441 // Detection code taken from https://stackoverflow.com/a/20293441
function isMobile() { function isMobile() {
try{ document.createEvent('TouchEvent'); return true; } try {
catch(e){ return false; } document.createEvent('TouchEvent');
return true;
} catch(e) {
return false;
}
} }
if (isMobile()) { if (isMobile()) {
@ -203,8 +207,8 @@ if (isMobile()) {
// Create new control bar object for operation buttons // Create new control bar object for operation buttons
const ControlBar = videojs.getComponent('controlBar'); const ControlBar = videojs.getComponent('controlBar');
let operations_bar = new ControlBar(player, { let operations_bar = new ControlBar(player, {
children: [], children: [],
playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
}); });
buttons.slice(1).forEach(function (child) {operations_bar.addChild(child);}); buttons.slice(1).forEach(function (child) {operations_bar.addChild(child);});
@ -307,7 +311,7 @@ function updateCookie(newVolume, newSpeed) {
var date = new Date(); var date = new Date();
date.setFullYear(date.getFullYear() + 2); date.setFullYear(date.getFullYear() + 2);
var ipRegex = /^((\d+\.){3}\d+|[\dA-Fa-f]*:[\d:A-Fa-f]*:[\d:A-Fa-f]+)$/; var ipRegex = /^(?:(?:\d+\.){3}\d+|[\dA-F]*:[\dA-F]*:[\d:A-F]+)$/i;
var domainUsed = location.hostname; var domainUsed = location.hostname;
// Fix for a bug in FF where the leading dot in the FQDN is not ignored // Fix for a bug in FF where the leading dot in the FQDN is not ignored
@ -362,8 +366,9 @@ if (video_data.params.save_player_pos) {
lastUpdated = time; lastUpdated = time;
} }
}); });
} else {
remove_all_video_times();
} }
else remove_all_video_times();
if (video_data.params.autoplay) { if (video_data.params.autoplay) {
var bpb = player.getChild('bigPlayButton'); var bpb = player.getChild('bigPlayButton');
@ -427,8 +432,8 @@ if (!video_data.params.listen && video_data.params.annotations) {
addEventListener('load', function (e) { addEventListener('load', function (e) {
addEventListener('__ar_annotation_click', function (e) { addEventListener('__ar_annotation_click', function (e) {
const url = e.detail.url, const url = e.detail.url,
target = e.detail.target, target = e.detail.target,
seconds = e.detail.seconds; seconds = e.detail.seconds;
var path = new URL(url); var path = new URL(url);
if (path.href.startsWith('https://www.youtube.com/watch?') && seconds) { if (path.href.startsWith('https://www.youtube.com/watch?') && seconds) {
@ -593,20 +598,20 @@ addEventListener('keydown', function (e) {
return; return;
} }
// See https://github.com/ctd1500/videojs-hotkeys/blob/bb4a158b2e214ccab87c2e7b95f42bc45c6bfd87/videojs.hotkeys.js#L310-L313 // See https://github.com/ctd1500/videojs-hotkeys/blob/bb4a158b2e214ccab87c2e7b95f42bc45c6bfd87/videojs.hotkeys.js#L310-L313
const isPlayerFocused = false const isPlayerFocused = false ||
|| e.target === document.querySelector('.video-js') e.target === document.querySelector('.video-js') ||
|| e.target === document.querySelector('.vjs-tech') e.target === document.querySelector('.vjs-tech') ||
|| e.target === document.querySelector('.iframeblocker') e.target === document.querySelector('.iframeblocker') ||
|| e.target === document.querySelector('.vjs-control-bar') e.target === document.querySelector('.vjs-control-bar')
; ;
let action = null; let action = null;
const code = e.keyCode; const code = e.keyCode;
const decoratedKey = const decoratedKey =
e.key e.key +
+ (e.altKey ? '+alt' : '') (e.altKey ? '+alt' : '') +
+ (e.ctrlKey ? '+ctrl' : '') (e.ctrlKey ? '+ctrl' : '') +
+ (e.metaKey ? '+meta' : '') (e.metaKey ? '+meta' : '')
; ;
switch (decoratedKey) { switch (decoratedKey) {
case ' ': case ' ':

View File

@ -142,17 +142,17 @@ function get_reddit_comments() {
</div> \ </div> \
<div>{contentHtml}</div> \ <div>{contentHtml}</div> \
<hr>'.supplant({ <hr>'.supplant({
title: response.title, title: response.title,
youtubeCommentsText: video_data.youtube_comments_text, youtubeCommentsText: video_data.youtube_comments_text,
redditPermalinkText: video_data.reddit_permalink_text, redditPermalinkText: video_data.reddit_permalink_text,
permalink: response.permalink, permalink: response.permalink,
contentHtml: response.contentHtml contentHtml: response.contentHtml
}); });
comments.children[0].children[0].children[0].onclick = toggle_comments; comments.children[0].children[0].children[0].onclick = toggle_comments;
comments.children[0].children[1].children[0].onclick = swap_comments; comments.children[0].children[1].children[0].onclick = swap_comments;
}, },
onNon200: onNon200, // declared above onNon200: onNon200 // declared above
}); });
} }