Created
April 22, 2025 08:15
-
-
Save twist84/c734564c55f1580fabce03aa4591ba44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name YouTube Grid Items Fixer | |
// @version 0.1 | |
// @description fix grid item count | |
// @author Twister (https://github.com/twist84) | |
// @match *://*.youtube.com/* | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== | |
let a1 = false; | |
function update_grid_css(milliseconds, column_count) | |
{ | |
const interval = setInterval(() => | |
{ | |
if (!a1) | |
{ | |
document.querySelectorAll('ytd-rich-grid-renderer').forEach(grid_entry => | |
{ | |
document.querySelectorAll('ytd-rich-item-renderer').forEach(item_entry => | |
{ | |
if (item_entry.attributes.hasOwnProperty("is-in-first-column")) | |
{ | |
item_entry.attributes.removeNamedItem("is-in-first-column"); | |
} | |
}); | |
grid_entry.style.cssText = `--ytd-rich-grid-items-per-row: ${column_count}; --ytd-rich-grid-posts-per-row: ${column_count}; --ytd-rich-grid-slim-items-per-row: ${column_count}; --ytd-rich-grid-game-cards-per-row: ${column_count}; `; | |
}); | |
} | |
}, milliseconds); | |
if (a1) | |
{ | |
console.log(interval, a1); | |
clearInterval(interval); | |
} | |
else | |
{ | |
console.log(interval, a1); | |
} | |
return interval; | |
} | |
(function() { | |
'use strict'; | |
let interval = update_grid_css(250, 5); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment