Various search filters and user experience enhancers
< Opinie na SpankBang - Search and UI Enhancer
OK, I also hate this mobile aspect ratio revolution.
I don't really know JS or much about making users cripts at all, but here's a bit of code that seems to work in the console that just gives each 'video-item' div a data-aspect 'horizontal' or 'vertical' attribute.
const imgElements = document.querySelectorAll('img');
imgElements.forEach(imgElement => {
const aspectRatio = imgElement.naturalWidth / imgElement.naturalHeight;
let parent = imgElement;
for (let i = 0; i < 3; i++) {
parent = parent.parentElement;
if (!parent) break; // If there are fewer than 3 parents, exit the loop
}
if (parent) {
const aspectAttribute = aspectRatio > 1 ? 'horizontal' : (aspectRatio < 1 ? 'vertical' : 'square');
parent.setAttribute('data-aspect', aspectAttribute);
}
});
They can then be filtered out with the following CSS:
div[data-aspect="vertical"] {
display: none !important;
}
Problem is that a lot of vertical aspect videos have the black bars on either side making them falsely 'horizontal'. I dunno how to detect that since it's how the video itself is too.
I had built the feature on the day you asked but there is a condition for the script that makes it unreliable at detection of such. Like when the images are loaded, the timing is not linear obviously. Some images never load either as you do not progress to that video, due to lazy loading. So its a very costly thing to make, it will delay everything else.
I mean there can only be one way to accomplish such; Do the usual run of the script and add events to make this filtering happen when it can happen per item. This will have obvious artefacts that there will be multiple runs happening for the script, the results won't be instantaneous and the user may get confused as to why such is so. To make it better I will have to either make a universal progress bar at the bottom of the screen to show where the script is in its operation or show such progress bar on each item as an overlay. Then there could be further issues with such if you want to change settings in the middle.
nice job. it would be great if you could filter videos by aspect ratio, i.e. do or don't show mobile recorded vids in the feed