Tg Sort by reactions

Allows you to find posts with a lot of reactions (likes) in Telegram

目前為 2023-01-04 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Tg Sort by reactions
  3. // @name:ru Tg Сортировка по реакциям
  4. // @name:zh Tg 按反应排序
  5. // @version 0.1.3
  6. // @description Allows you to find posts with a lot of reactions (likes) in Telegram
  7. // @description:ru Позволяет найти сообщения с наибольшим количеством реакций (лайков) в Телеграм
  8. // @description:zh 允许您在电报中找到有很多反应(喜欢)在 Telegram
  9. // @author sokollondon
  10. // @match https://web.telegram.org/z/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=telegram.org
  12. // @require http://code.jquery.com/jquery-3.3.1.min.js
  13. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.3/jquery.scrollTo.min.js
  14. // @grant none
  15. // @namespace https://gist.github.com/sokollondon/4be0d13f33a371895308ed7b1dc15fcf
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. let style = `
  20. #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;}
  21. .theme-dark #sBtn{background-color: #a9a9a9;}
  22. @media screen and (max-width: 600px) {
  23. #sBtn{top: 111px;right: 8px;}
  24. }
  25. `;
  26. $('body').prepend('<style>'+style+'</style>');
  27.  
  28. //Btn
  29. $('body').prepend("<div id='sBtn' title='Сортировать по количеству реакций'></div>");
  30.  
  31. $('#sBtn').click(function() {
  32. $('.message-date-group').each(function() {//add date to msg
  33. let date = $(this).find('.sticky-date').text();
  34. $(this).find('.message-list-item').each(function() {
  35. $(this).find('.message-time').prepend(date+' ');
  36. });
  37. });
  38. $('.message-list-item').detach().sort(function(a, b) {
  39. let $aQty = $(a).find('.Reactions .Button:first').text2qty(),
  40. $bQty = $(b).find('.Reactions .Button:first').text2qty();
  41. return $aQty - $bQty;
  42. }).appendTo($('.messages-container'));
  43. $('.MessageList').scrollTo($('.message-list-item:last .Reactions'),{axis:'y'});
  44. });
  45.  
  46. $.fn.text2qty = function () {
  47. let t = $(this).text(),
  48. qty = toFloat(t),
  49. ava = $(this).find('.Avatar');
  50. if(ava.length){
  51. qty = ava.length;
  52. }else if(t.match("K$")){
  53. qty = qty*1000;
  54. }else if(t.match("M$")){
  55. qty = qty*1000000;
  56. }
  57. //console.info(qty);
  58. return qty;
  59. }
  60.  
  61. function toFloat(str) {
  62. return str.replace(/[^0-9.,]/g,'').replace(/[,]/g,'.');
  63. }
  64. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址