Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions js&css/extension/www.youtube.com/general/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
} else if (anything === 'init') {
extension.events.on('init', function (resolve) {
if (/(www|m)\.youtube\.com\/?(\?|\#|$)/.test(location.href)) {

Check failure on line 47 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Unnecessary escape character: \#
chrome.storage.local.get('youtube_home_page', function (items) {
var option = items.youtube_home_page;

Expand All @@ -69,7 +69,7 @@
prepend: true
});
} else {
var option = extension.storage.get('youtube_home_page');

Check failure on line 72 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

'option' is already defined

window.removeEventListener('click', this.youtubeHomePage);

Expand Down Expand Up @@ -251,11 +251,11 @@
event.stopPropagation();
try { this.parentElement.itPopupWindowButton.dataset.id = this.parentElement.href.match(/(?:[?&]v=|embed\/|shorts\/)([^&?]{11})/)[1] } catch (error) { console.log(error)};
ytPlayer = document.querySelector("#movie_player");
if (ytPlayer) {width = ytPlayer.offsetWidth * 0.65; height = ytPlayer.offsetHeight * 0.65}

Check failure on line 254 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Closing curly brace does not appear on the same line as the subsequent block
else { width = innerWidth * 0.4; height = innerHeight * 0.4; }
if (!ytPlayer) {
let shorts = /short/.test(this.parentElement.href);
if ( width / height < 1 ) { let vertical = true } else { let vertical = false }

Check failure on line 258 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

'vertical' is assigned a value but never used

Check failure on line 258 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

'vertical' is assigned a value but never used
if ( !vertical && shorts ) { width = height * 0.6}
if ( vertical && !shorts ) { height = width * 0.6}
}
Expand Down Expand Up @@ -305,8 +305,8 @@
this.font.link = link;
this.font.style = style;
} else if (changed) {
var link = this.font.link,

Check failure on line 308 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

'link' is already defined
style = this.font.style;

Check failure on line 309 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

'style' is already defined

if (link) {
link.remove();
Expand Down Expand Up @@ -632,17 +632,17 @@
if (clickedElement) {
// Grab the plain text inside the yt-formatted-string (looking for links or URLs)
const textContent = clickedElement.innerText;

Check warning on line 635 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
// Extract URL using a simple regex (you can customize it to be more accurate)
const urlRegex = /\bhttps?:\/\/[^\s]+/g;
const match = textContent.match(urlRegex);

Check warning on line 639 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
if (match) {
// Copy the found URL to the clipboard
navigator.clipboard.writeText(match[0]).catch((err) => {
console.error("Failed to copy: ", err);
});

Check warning on line 645 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
// Prevent the default right-click menu from showing
e.preventDefault();
}
Expand All @@ -657,18 +657,29 @@
extension.features.changeThumbnailsPerRow = async function () {
var value = await extension.storage.get('change_thumbnails_per_row');

if (!value || value === 'null')

Check warning on line 660 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
return;

const applyGridLayout = () => {
const grid = document.querySelector('ytd-rich-grid-renderer');
if (!grid)
return;

// Apply custom values
grid.style.setProperty('--ytd-rich-grid-items-per-row', value);
grid.style.setProperty('--ytd-rich-grid-item-min-width', '220px');
grid.style.setProperty('--ytd-rich-grid-item-max-width', '1fr');
//Check if we are on the subscriptions page
if (location.href.indexOf('feed/subscriptions') !== -1) {
document.querySelectorAll('[style]').forEach(el => {
if (el.style.getPropertyValue('--ytd-rich-grid-items-per-row')) {
el.style.setProperty('--ytd-rich-grid-items-per-row', value);
el.style.setProperty('--ytd-rich-grid-item-min-width', '220px');
el.style.setProperty('--ytd-rich-grid-item-max-width', '1fr');
}
});
} else {

Check warning on line 673 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
const grid = document.querySelector('ytd-rich-grid-renderer');
if (!grid)

Check warning on line 675 in js&css/extension/www.youtube.com/general/general.js

View workflow job for this annotation

GitHub Actions / lint-and-test

Trailing spaces not allowed
return;

// Apply custom values
grid.style.setProperty('--ytd-rich-grid-items-per-row', value);
grid.style.setProperty('--ytd-rich-grid-item-min-width', '220px');
grid.style.setProperty('--ytd-rich-grid-item-max-width', '1fr');
}
};

// Apply initially
Expand All @@ -677,4 +688,4 @@
// Reapply when YouTube replaces content
const observer = new MutationObserver(applyGridLayout);
observer.observe(document.body, { childList: true, subtree: true });
};
};
Loading