Telegram post summary

Summarises telegram posts from channel

当前为 2017-06-29 提交的版本,查看 最新版本

// ==UserScript==
// @name         Telegram post summary
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Summarises telegram posts from channel
// @author       Sam Marshallsay
// @include https://web.telegram.org*
// @grant        none
// ==/UserScript==
// @require https://code.jquery.com/jquery-3.2.1.min.js
(function() {
    'use strict';

    $("body").keypress(function(e) {
        if(e.keyCode == 126) { // ~ key
            var scrollCount = 0;
            var scrollRepeat = 30;

            function scrollTop() {
                $('.im_history_scrollable_wrap').scrollTop(0);
                
                var chanCreateMsg = $('.im_message_service:contains(Channel created)').length > 0;
                if(scrollCount < scrollRepeat && chanCreateMsg !== true){
                    scrollCount++;
                    setTimeout(scrollTop, 300);
                }
                else {
                    getOutput();
                }
            }
            scrollTop();
            
            function getOutput() {
                var $msgs = $('.im_history_message_wrap');
                var output = "";
                console.log($msgs.length);
                $.each($msgs, function(i, val) {                
                    var $msg = $(val);
                    console.log($msg);
                    output += $msg.find('.im_message_date_split_text').html();
                    output += " - " + $msg.find('.im_message_date_text').data('content');                
                    output += " - " + $msg.find('.im_message_views_cnt').html();
                    output += " - " + $msg.find('.im_message_document_caption').html();
                    output += " <br />";
                });

                //alert(output);
                console.log(output);
                
                var outputdiv = '<div class="outputdiv" style="position:absolute;top:0px;left:0px;width:800px;height:800px;border:solid 1px red;overflow:scroll;background:white;z-index:10000;padding:20px;"><input type="button" value="CLOSE" class="outputclose"/><br /></div>';                
                $('body').prepend(outputdiv);
                $('.outputdiv').append(output);
                $('.outputclose').click(function(e) {
                    $('.outputdiv').remove();
                    $('.im_history_scrollable_wrap').scrollTop($('.im_history_scrollable_wrap')[0].scrollHeight);                    
                });
            }
        }
            
    });
    
    
    
    
})();

QingJ © 2025

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