From 79f12134e5042180aac05245311905fec14c8271 Mon Sep 17 00:00:00 2001 From: Roki <35699619+Roki100@users.noreply.github.com> Date: Mon, 7 Aug 2023 20:42:32 +0200 Subject: [PATCH] Initial userscript compatibility layer release --- rowsfix-helper.user.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 rowsfix-helper.user.js diff --git a/rowsfix-helper.user.js b/rowsfix-helper.user.js new file mode 100644 index 0000000..5f9f4c4 --- /dev/null +++ b/rowsfix-helper.user.js @@ -0,0 +1,33 @@ +// ==UserScript== +// @name YouTube rows fix - Compatibility userscript +// @description Experimental compatibility script for Youtube-rows-fix on home & feed page +// @namespace github.com/Roki100/YouTube-rows-fix +// @homepageURL https://github.com/Roki100/YouTube-rows-fix +// @updateURL https://raw.githubusercontent.com/Roki100/YouTube-rows-fix/main/rowsfix-helper.user.js +// @downloadURL https://raw.githubusercontent.com/Roki100/YouTube-rows-fix/main/rowsfix-helper.user.js +// @version 1.1.0 +// @license GPL3.0 +// @author Roki +// @run-at document-start +// @match *://www.youtube.com/ +// @match *://www.youtube.com/feed/subscriptions* +// @icon https://www.youtube.com/favicon.ico +// @grant none +// @require https://greasyfork.org/scripts/465819-api-for-customelements-in-youtube/code/API%20for%20CustomElements%20in%20YouTube.js?version=1215280 +// ==/UserScript== + +'use strict'; +// PLEASE USE THE USERSTYLE TO CONFIGURE - THIS IS ONLY AN EXPERIMENTAL HELPER SCRIPT - NOT INTENDED TO BE USED AS A STANDALONE ONE! +// (https://github.com/Roki100/YouTube-rows-fix / https://raw.githubusercontent.com/Roki100/YouTube-rows-fix/main/rowsfix.user.css) +setTimeout(() => { + const variables = getComputedStyle(document.body) + const element = "ytd-rich-grid-renderer"; + if (!variables.getPropertyValue('--rowsfix-by-roki-userscript-rows')) return; + const shortCount = Number(variables.getPropertyValue('--rowsfix-by-roki-userscript-shortsrows') ? variables.getPropertyValue('--rowsfix-by-roki-userscript-shortsrows') : 8); + const videoCount = Number(variables.getPropertyValue('--rowsfix-by-roki-userscript-rows') ? variables.getPropertyValue('--rowsfix-by-roki-userscript-rows') : 6); + customYtElements.whenRegistered(element, (proto) => { + proto.calcElementsPerRow = (a, b) => { + return a === 194 ? shortCount : videoCount; + }; + }); +}, 400); // Timeout is needed for reliable function \ No newline at end of file