Request to search by top level comments only and sort by like count #42
Replies: 2 comments 20 replies
-
|
I made a user script for my preference to order search results by likes count. // ==UserScript==
// @name YouTube YCS Sort By Likes
// @description description
// @version 1
// @match https://www.youtube.com/watch?v=*
// @run-at document-idle
// ==/UserScript==
(function(){
console.log('YouTube YCS Sort By Likes');
let timer = setInterval(function(){
const input = document.querySelector('#ycs-input-search');
const result = document.querySelector('#ycs-search-result');
if(input === null) return;
else clearInterval(timer);
input.addEventListener('keydown', e => {
if(e.isComposing) return;
if(e.key === 'Enter'){
let observer = observe(result, records => {
observer.disconnect(); // maybe this line should be removed for when it has paginations.
Array.from(document.querySelectorAll('.ycs-icon-like + .ycs-like-count'))
.sort((a, b) => parseInt(a.textContent) - parseInt(b.textContent))
.forEach(e => document.querySelector('#ycs_wrap_comments').prepend(e.parentNode.parentNode.parentNode.parentNode.parentNode));
});
}
});
const observe = function(element, callback, options = {childList: true, subtree: false, characterData: false, attributes: false, attributeFilter: undefined}){
let observer = new MutationObserver(callback.bind(element));
observer.observe(element, options);
return observer;
};
}, 1000);
})(); |
Beta Was this translation helpful? Give feedback.
-
|
Hi again friend @Letssharearow , sorry for not reaching out last week, I was a little busy. Thanks for your fix !. However, I updated the script to the newer version and while I've noticed it improved the sorting, there is still some cases where it doesn't properly organizes the ones with decimals, like the case of the image, do you have any other idea why? in my case I visualize commas for decimals as well,not dots. Link Video: https://www.youtube.com/watch?v=-5zGuFPxW88 searching for comment with "Twitch" And as for the spam clicker it works perfectly, it automatically charges all comments so the Load more button not even appear jjejej thanks, you rock 👌 . |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
I'd like to sort search term results by likes, as well as a top level comment only search. Clicking the like sort before or after results just reloads all comments again and by like count.
Beta Was this translation helpful? Give feedback.
All reactions