This commit is contained in:
meow 2022-04-20 12:13:16 +03:00
parent c72d3c4a0e
commit 38ef0b10e7
9 changed files with 45 additions and 45 deletions

View file

@ -64,8 +64,8 @@ function get_youtube_replies(target, load_more) {
xhr.open('GET', url, true); xhr.open('GET', url, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status == 200) { if (xhr.status === 200) {
if (load_more) { if (load_more) {
body = body.parentNode.parentNode; body = body.parentNode.parentNode;
body.removeChild(body.lastElementChild); body.removeChild(body.lastElementChild);

View file

@ -2,7 +2,7 @@
var video_data = JSON.parse(document.getElementById('video_data').innerHTML); var video_data = JSON.parse(document.getElementById('video_data').innerHTML);
function get_playlist(plid, retries) { function get_playlist(plid, retries) {
if (retries == undefined) retries = 5; if (retries === undefined) retries = 5;
if (retries <= 0) { if (retries <= 0) {
console.log('Failed to pull playlist'); console.log('Failed to pull playlist');

View file

@ -102,8 +102,8 @@
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
count.innerText = parseInt(count.innerText) + 1; count.innerText = parseInt(count.innerText) + 1;
row.style.display = ''; row.style.display = '';
} }
@ -131,8 +131,8 @@
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
count.innerText = parseInt(count.innerText) + 1; count.innerText = parseInt(count.innerText) + 1;
row.style.display = ''; row.style.display = '';
} }
@ -159,7 +159,7 @@
} }
// Focus search bar on '/' // Focus search bar on '/'
if (event.key == "/") { if (event.key === "/") {
document.getElementById('searchbox').focus(); document.getElementById('searchbox').focus();
event.preventDefault(); event.preventDefault();
} }

View file

@ -4,7 +4,7 @@ var notification_data = JSON.parse(document.getElementById('notification_data').
var notifications, delivered; var notifications, delivered;
function get_subscriptions(callback, retries) { function get_subscriptions(callback, retries) {
if (retries == undefined) retries = 5; if (retries === undefined) retries = 5;
if (retries <= 0) { if (retries <= 0) {
return; return;

View file

@ -225,7 +225,7 @@ player.playbackRate(video_data.params.speed);
function getCookieValue(name) { function getCookieValue(name) {
var value = document.cookie.split(";").filter(item => item.includes(name + "=")); var value = document.cookie.split(";").filter(item => item.includes(name + "="));
return (value != null && value.length >= 1) return (value.length >= 1)
? value[0].substring((name + "=").length, value[0].length) ? value[0].substring((name + "=").length, value[0].length)
: null; : null;
} }
@ -237,13 +237,13 @@ function getCookieValue(name) {
* @param {number} newSpeed New speed defined (null if unchanged) * @param {number} newSpeed New speed defined (null if unchanged)
*/ */
function updateCookie(newVolume, newSpeed) { function updateCookie(newVolume, newSpeed) {
var volumeValue = newVolume != null ? newVolume : video_data.params.volume; var volumeValue = newVolume !== null ? newVolume : video_data.params.volume;
var speedValue = newSpeed != null ? newSpeed : video_data.params.speed; var speedValue = newSpeed !== null ? newSpeed : video_data.params.speed;
var cookieValue = getCookieValue('PREFS'); var cookieValue = getCookieValue('PREFS');
var cookieData; var cookieData;
if (cookieValue != null) { if (cookieValue !== null) {
var cookieJson = JSON.parse(decodeURIComponent(cookieValue)); var cookieJson = JSON.parse(decodeURIComponent(cookieValue));
cookieJson.volume = volumeValue; cookieJson.volume = volumeValue;
cookieJson.speed = speedValue; cookieJson.speed = speedValue;
@ -260,7 +260,7 @@ function updateCookie(newVolume, newSpeed) {
var domainUsed = window.location.hostname; var domainUsed = window.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
if (domainUsed.charAt(0) != '.' && !ipRegex.test(domainUsed) && domainUsed != 'localhost') if (domainUsed.charAt(0) !== '.' && !ipRegex.test(domainUsed) && domainUsed !== 'localhost')
domainUsed = '.' + window.location.hostname; domainUsed = '.' + window.location.hostname;
document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' + document.cookie = 'PREFS=' + cookieData + '; SameSite=Strict; path=/; domain=' +
@ -334,7 +334,7 @@ if (video_data.params.autoplay) {
if (!video_data.params.listen && video_data.params.quality === 'dash') { if (!video_data.params.listen && video_data.params.quality === 'dash') {
player.httpSourceSelector(); player.httpSourceSelector();
if (video_data.params.quality_dash != "auto") { if (video_data.params.quality_dash !== "auto") {
player.ready(() => { player.ready(() => {
player.on("loadedmetadata", () => { player.on("loadedmetadata", () => {
const qualityLevels = Array.from(player.qualityLevels()).sort((a, b) => a.height - b.height); const qualityLevels = Array.from(player.qualityLevels()).sort((a, b) => a.height - b.height);
@ -357,7 +357,7 @@ if (!video_data.params.listen && video_data.params.quality === 'dash') {
} }
} }
for (let i = 0; i < qualityLevels.length; i++) { for (let i = 0; i < qualityLevels.length; i++) {
qualityLevels[i].enabled = (i == targetQualityLevel); qualityLevels[i].enabled = (i === targetQualityLevel);
} }
}); });
}); });
@ -703,7 +703,7 @@ window.addEventListener('keydown', e => {
var volumeHover = false; var volumeHover = false;
var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel'); var volumeSelector = pEl.querySelector('.vjs-volume-menu-button') || pEl.querySelector('.vjs-volume-panel');
if (volumeSelector != null) { if (volumeSelector !== null) {
volumeSelector.onmouseover = function () { volumeHover = true; }; volumeSelector.onmouseover = function () { volumeHover = true; };
volumeSelector.onmouseout = function () { volumeHover = false; }; volumeSelector.onmouseout = function () { volumeHover = false; };
} }
@ -723,9 +723,9 @@ window.addEventListener('keydown', e => {
var delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail))); var delta = Math.max(-1, Math.min(1, (event.wheelDelta || -event.detail)));
event.preventDefault(); event.preventDefault();
if (delta == 1) { if (delta === 1) {
increase_volume(volumeStep); increase_volume(volumeStep);
} else if (delta == -1) { } else if (delta === -1) {
increase_volume(-volumeStep); increase_volume(-volumeStep);
} }
} }
@ -750,7 +750,7 @@ if (player_data.preferred_caption_found) {
} }
// Safari audio double duration fix // Safari audio double duration fix
if (navigator.vendor == "Apple Computer, Inc." && video_data.params.listen) { if (navigator.vendor === "Apple Computer, Inc." && video_data.params.listen) {
player.on('loadedmetadata', function () { player.on('loadedmetadata', function () {
player.on('timeupdate', function () { player.on('timeupdate', function () {
if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) { if (player.remainingTime() < player.duration() / 2 && player.remainingTime() >= 2) {

View file

@ -15,8 +15,8 @@ function add_playlist_video(target) {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status == 200) { if (xhr.status === 200) {
option.innerText = '✓' + option.innerText; option.innerText = '✓' + option.innerText;
} }
} }
@ -39,8 +39,8 @@ function add_playlist_item(target) {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
tile.style.display = ''; tile.style.display = '';
} }
} }
@ -63,8 +63,8 @@ function remove_playlist_item(target) {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
tile.style.display = ''; tile.style.display = '';
} }
} }

View file

@ -29,8 +29,8 @@ function subscribe(retries = 5) {
subscribe_button.innerHTML = '<b>' + subscribe_data.unsubscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>'; subscribe_button.innerHTML = '<b>' + subscribe_data.unsubscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>';
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
subscribe_button.onclick = subscribe; subscribe_button.onclick = subscribe;
subscribe_button.innerHTML = fallback; subscribe_button.innerHTML = fallback;
} }
@ -69,8 +69,8 @@ function unsubscribe(retries = 5) {
subscribe_button.innerHTML = '<b>' + subscribe_data.subscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>'; subscribe_button.innerHTML = '<b>' + subscribe_data.subscribe_text + ' | ' + subscribe_data.sub_count_text + '</b>';
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
subscribe_button.onclick = unsubscribe; subscribe_button.onclick = unsubscribe;
subscribe_button.innerHTML = fallback; subscribe_button.innerHTML = fallback;
} }

View file

@ -117,7 +117,7 @@ function number_with_separator(val) {
} }
function get_playlist(plid, retries) { function get_playlist(plid, retries) {
if (retries == undefined) retries = 5; if (retries === undefined) retries = 5;
playlist = document.getElementById('playlist'); playlist = document.getElementById('playlist');
if (retries <= 0) { if (retries <= 0) {
@ -147,8 +147,8 @@ function get_playlist(plid, retries) {
xhr.open('GET', plid_url, true); xhr.open('GET', plid_url, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status == 200) { if (xhr.status === 200) {
playlist.innerHTML = xhr.response.playlistHtml; playlist.innerHTML = xhr.response.playlistHtml;
var nextVideo = document.getElementById(xhr.response.nextVideo); var nextVideo = document.getElementById(xhr.response.nextVideo);
nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop; nextVideo.parentNode.parentNode.scrollTop = nextVideo.offsetTop;
@ -210,7 +210,7 @@ function get_playlist(plid, retries) {
} }
function get_reddit_comments(retries) { function get_reddit_comments(retries) {
if (retries == undefined) retries = 5; if (retries === undefined) retries = 5;
comments = document.getElementById('comments'); comments = document.getElementById('comments');
if (retries <= 0) { if (retries <= 0) {
@ -232,8 +232,8 @@ function get_reddit_comments(retries) {
xhr.open('GET', url, true); xhr.open('GET', url, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status == 200) { if (xhr.status === 200) {
comments.innerHTML = ' \ comments.innerHTML = ' \
<div> \ <div> \
<h3> \ <h3> \
@ -287,7 +287,7 @@ function get_reddit_comments(retries) {
} }
function get_youtube_comments(retries) { function get_youtube_comments(retries) {
if (retries == undefined) retries = 5; if (retries === undefined) retries = 5;
comments = document.getElementById('comments'); comments = document.getElementById('comments');
if (retries <= 0) { if (retries <= 0) {
@ -310,8 +310,8 @@ function get_youtube_comments(retries) {
xhr.open('GET', url, true); xhr.open('GET', url, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status == 200) { if (xhr.status === 200) {
comments.innerHTML = ' \ comments.innerHTML = ' \
<div> \ <div> \
<h3> \ <h3> \
@ -384,8 +384,8 @@ function get_youtube_replies(target, load_more, load_replies) {
xhr.open('GET', url, true); xhr.open('GET', url, true);
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status == 200) { if (xhr.status === 200) {
if (load_more) { if (load_more) {
body = body.parentNode.parentNode; body = body.parentNode.parentNode;
body.removeChild(body.lastElementChild); body.removeChild(body.lastElementChild);

View file

@ -14,8 +14,8 @@ function mark_watched(target) {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
tile.style.display = ''; tile.style.display = '';
} }
} }
@ -39,8 +39,8 @@ function mark_unwatched(target) {
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () { xhr.onreadystatechange = function () {
if (xhr.readyState == 4) { if (xhr.readyState === 4) {
if (xhr.status != 200) { if (xhr.status !== 200) {
count.innerText = count.innerText - 1 + 2; count.innerText = count.innerText - 1 + 2;
tile.style.display = ''; tile.style.display = '';
} }