Skip to content

Instantly share code, notes, and snippets.

@sokollondon
Last active April 23, 2024 05:51
Show Gist options
  • Save sokollondon/4be0d13f33a371895308ed7b1dc15fcf to your computer and use it in GitHub Desktop.
Save sokollondon/4be0d13f33a371895308ed7b1dc15fcf to your computer and use it in GitHub Desktop.
Sort by reactions. Allows you to find posts with a lot of reactions (likes) in https://web.telegram.org/a/
// ==UserScript==
// @name Tg Sort by reactions
// @name:ru Tg Сортировка по реакциям
// @name:zh Tg 按反应排序
// @version 0.1.4
// @description Allows you to find posts with a lot of reactions (likes) in Telegram
// @description:ru Позволяет найти сообщения с наибольшим количеством реакций (лайков) в Телеграм
// @description:zh 允许您在电报中找到有很多反应(喜欢)在 Telegram
// @author sokollondon
// @match https://web.telegram.org/a/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=telegram.org
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.3/jquery.scrollTo.min.js
// @grant none
// @namespace https://gist.github.com/sokollondon/4be0d13f33a371895308ed7b1dc15fcf
// @updateURL https://gist.github.com/sokollondon/4be0d13f33a371895308ed7b1dc15fcf/raw/TgSortByReactions.user.js
// @downloadURL https://gist.github.com/sokollondon/4be0d13f33a371895308ed7b1dc15fcf/raw/TgSortByReactions.user.js
// ==/UserScript==
(function() {
let style = `
#sBtn{position:fixed;top:73px;right:16px;width:45px;height:45px;padding:5px;border-radius:10px;text-align:center;font-size:20px;padding-top:5px;z-index:2;opacity: .7;background:url(https://cdn0.iconfinder.com/data/icons/font-awesome-solid-vol-4/512/sort-amount-down-alt-64.png) no-repeat center center;background-size:32px;background-color:#fff;cursor:pointer;}
.theme-dark #sBtn{background-color: #a9a9a9;}
@media screen and (max-width: 600px) {
#sBtn{top: 111px;right: 8px;}
}
`;
let $body = $('body');
$body.prepend('<style>'+style+'</style>');
//Btn
$body.prepend("<div id='sBtn' title='Сортировать по количеству реакций'></div>");
$('#sBtn').click(function() {
$('.message-date-group').each(function() {//add date to msg
let date = $(this).find('.sticky-date').text();
$(this).find('.message-list-item').each(function() {
$(this).find('.message-time').prepend(date+' ');
});
});
$('.message-list-item').detach().sort(function(a, b) {
let $aQty = $(a).find('.Reactions .Button:first').text2qty(),
$bQty = $(b).find('.Reactions .Button:first').text2qty();
return $aQty - $bQty;
}).appendTo($('.messages-container'));
$('.MessageList').scrollTo($('.message-list-item:last .Reactions'),{axis:'y'});
});
$.fn.text2qty = function () {
let t = $(this).text(),
qty = toFloat(t),
ava = $(this).find('.Avatar');
if(ava.length){
qty = ava.length;
}else if(t.match("K$")){
qty = qty*1000;
}else if(t.match("M$")){
qty = qty*1000000;
}
//console.info(qty);
return qty;
}
function toFloat(str) {
return str.replace(/[^0-9.,]/g,'').replace(/[,]/g,'.');
}
})();
@sokollondon
Copy link
Author

sokollondon commented Nov 28, 2022

2022-11-28
Language: EN, РУ

Installation

  1. Install Tampermonkey browser extension
  2. Then install the sorting script

Usage

  1. Open any channel or group in https://web.telegram.org
  2. Press the Page Up button several times to load more posts.
    Or use the mouse wheel. But do not use the Home button, because Not all messages will have time to load.
  3. Click the new button to sort. All messages will be sorted by the number of reactions

@sokollondon
Copy link
Author

sokollondon commented Nov 30, 2022

img
Язык: EN, РУ

Сортировка по реакциям. Позволяет найти сообщения с наибольшим количеством реакций (лайков) 👍.
Скрипт добавляет в telegram кнопку для сортировки сообщений (до 80 шт.).

Инструкция

Как установить и использовать:

На компьютере (проще)

Установка

  1. Установите расширение для браузера Tampermonkey.
  2. Затем установите скрипт для сортировки (зелёная кнопка)

Использование

  1. Откройте любой канал или группу в https://web.telegram.org
  2. Нажмите кнопку Page Up несколько раз, чтобы загрузить больше сообщений.
    Или используйте колесо мыши. Но не используйте кнопку Home, т.к. не все сообщения успеют загрузиться.
  3. Нажмите новую кнопку для сортировки. Все сообщения будут отсортированы по количеству реакций.

При возникновении проблем - обновите страницу.


На мобильных устройствах

Установка

  1. Установите браузер Kiwi
    (нужен, т.к. не все мобильные браузеры разрешают устанавливать расширения)
  2. Установите в нём расширение Tampermonkey.
  3. Затем установите скрипт для сортировки (зелёная кнопка)

Использование

  1. Откройте любой канал или группу в https://web.telegram.org
  2. Пролистайте, чтобы загрузить больше сообщений.
  3. Нажмите новую кнопку для сортировки. Все сообщения будут отсортированы по количеству реакций.

При возникновении проблем - обновите страницу.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment