<commit_before>/*global img_list emoticon_list triangle_img setClipboardText*/
//获取被@的用户
function get_at_name_list(comment_content){
    const name_list = new Set(),
        patt_at_name = RegExp("@<a href=\"/member/(.+?)\">", "g");
    
    let match;
    while (match = patt_at_name.exec(comment_content)) {
        name_list.add(match[1]);
    }

    return name_list;
}

//判断是否为相关的回复
function related_reply( reply_content, _reply_user_name, _reply_at_name ){
    let reply_related = false;
    const at_name_list = get_at_name_list(reply_content);

    if (at_name_list.size === 0){
        return true;
    }

    for (let at_name of at_name_list) {
        if (at_name == _reply_user_name || at_name == _reply_at_name){
            reply_related = true;
        }
    }

    return reply_related;
}

//插入图片
function input_img(input_img_base64, this_img_id){
    _upload_image.append("<div class='imgId"+ this_img_id +"'>\
                                <div><img src='"+ input_img_base64 +"' alt='上传图片'/></div>\
                                <span>上传中</span>\
                          </div>");
    _upload_image.slideDown(700);

    const img_base64 = input_img_base64.match("base64,(.*)")[1];
    chrome.runtime.sendMessage({img_base64: img_base64}, function(res) {
        const _img_preview = $(".imgId"+ this_img_id);

        if (res.img_status !== "Failed"){
            img_list["图片"+this_img_id] = ` ${res.img_status} `;
            _reply_textarea.val((i,origText) => origText+"[:图片"+this_img_id+":]");
            _img_preview.find("span").text("[:图片"+ this_img_id +":]");
            _img_preview.css({"background": "rgba(246, 246, 246, 0.5)","borderColor": "#A4FF94"});
        } else{
            alert("图片上传失败，可能是未登录微博/受 imgur 上传次数限制");
            _img_preview.find("span").text("请重新上传");
        }
        _upload_img_btn.text(" › 插入图片");
    });
}

//————————————————基本信息的获取及功能按钮初始化————————————————
//图片功能的初始化放在图片功能内

var page_current_num = $(".page_current").eq(0).text() || "1";
var page_previous_num = ~~(page_current_num)-1;
var _key_user = $(".header small a:first-of-type").text();
var _topic = $("#Main > div:nth-of-type(2)");
var _topic_content = $(".cell .topic_content", _topic);
var _topic_buttons = $(".topic_buttons");
var _reply_user_name_list = Array();
var _reply_content_list = Array();
var r_i = 1;
var maxNestDivCount = 1;

_topic_buttons.append(" &nbsp;<a href='#;' id='onlyKeyUser' class='tb'>只看楼主</a>");

$("div[id^=r_]").each(function(){
    var _this = $(this);
    var _reply = _this.find(".reply_content");

    //———回复空格修复———
    _reply.css("whiteSpace", "pre-wrap").html(function(i, o){
        return o.replace(/<br>/g, "");
    });
    //———回复空格修复———

    var _reply_content = _reply.html();
    var _reply_user_name = _this.find("strong a").text();
    var _reply_at_name = RegExp("<a href=\"/member/(.*?)\">").exec(_reply_content);

    if ( _key_user == _reply_user_name ){
        _this.addClass("keyUser");
    }else{
        _this.addClass("normalUser");
    }

    //判断高度是否超高
    var height = _reply.height();
    if ( height > 1000 ){
        _reply.addClass("waitForFold");
        _reply.attr("vPlus-height", height);
    }

    _reply_user_name_list[r_i] = _reply_user_name;
    _reply_content_list[r_i++] = _reply_content;<commit_msg>bug fix: newlines in third-party reply might be mistakenly replaced.<commit_after>/*global img_list emoticon_list triangle_img setClipboardText*/
//获取被@的用户
function get_at_name_list(comment_content){
    const name_list = new Set(),
        patt_at_name = RegExp("@<a href=\"/member/(.+?)\">", "g");

    let match;
    while (match = patt_at_name.exec(comment_content)) {
        name_list.add(match[1]);
    }

    return name_list;
}

//判断是否为相关的回复
function related_reply( reply_content, _reply_user_name, _reply_at_name ){
    let reply_related = false;
    const at_name_list = get_at_name_list(reply_content);

    if (at_name_list.size === 0){
        return true;
    }

    for (let at_name of at_name_list) {
        if (at_name == _reply_user_name || at_name == _reply_at_name){
            reply_related = true;
        }
    }

    return reply_related;
}

//插入图片
function input_img(input_img_base64, this_img_id){
    _upload_image.append("<div class='imgId"+ this_img_id +"'>\
                                <div><img src='"+ input_img_base64 +"' alt='上传图片'/></div>\
                                <span>上传中</span>\
                          </div>");
    _upload_image.slideDown(700);

    const img_base64 = input_img_base64.match("base64,(.*)")[1];
    chrome.runtime.sendMessage({img_base64: img_base64}, function(res) {
        const _img_preview = $(".imgId"+ this_img_id);

        if (res.img_status !== "Failed"){
            img_list["图片"+this_img_id] = ` ${res.img_status} `;
            _reply_textarea.val((i,origText) => origText+"[:图片"+this_img_id+":]");
            _img_preview.find("span").text("[:图片"+ this_img_id +":]");
            _img_preview.css({"background": "rgba(246, 246, 246, 0.5)","borderColor": "#A4FF94"});
        } else{
            alert("图片上传失败，可能是未登录微博/受 imgur 上传次数限制");
            _img_preview.find("span").text("请重新上传");
        }
        _upload_img_btn.text(" › 插入图片");
    });
}

//————————————————基本信息的获取及功能按钮初始化————————————————
//图片功能的初始化放在图片功能内

var page_current_num = $(".page_current").eq(0).text() || "1";
var page_previous_num = ~~(page_current_num)-1;
var _key_user = $(".header small a:first-of-type").text();
var _topic = $("#Main > div:nth-of-type(2)");
var _topic_content = $(".cell .topic_content", _topic);
var _topic_buttons = $(".topic_buttons");
var _reply_user_name_list = Array();
var _reply_content_list = Array();
var r_i = 1;
var maxNestDivCount = 1;

_topic_buttons.append(" &nbsp;<a href='#;' id='onlyKeyUser' class='tb'>只看楼主</a>");

$("div[id^=r_]").each(function(){
    var _this = $(this);
    var _reply = _this.find(".reply_content");

    //———回复空格修复———
    _reply.css("whiteSpace", "pre-wrap").html(function(i, o){
        return o.replace(/\n<br>/g, "\n").replace(/<br>/g, "\n");
    });
    //———回复空格修复———

    var _reply_content = _reply.html();
    var _reply_user_name = _this.find("strong a").text();
    var _reply_at_name = RegExp("<a href=\"/member/(.*?)\">").exec(_reply_content);

    if ( _key_user == _reply_user_name ){
        _this.addClass("keyUser");
    }else{
        _this.addClass("normalUser");
    }

    //判断高度是否超高
    var height = _reply.height();
    if ( height > 1000 ){
        _reply.addClass("waitForFold");
        _reply.attr("vPlus-height", height);
    }

    _reply_user_name_list[r_i] = _reply_user_name;
    _reply_content_list[r_i++] = _reply_content;
{'fraction_non_alphanumeric': 0.18516302722105893, 'fraction_numerical': 0.013161830690996112, 'mean_word_length': 3.1456912585244887, 'pattern_counts': {'":': 8, '<': 28, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2702876', 'n_tokens_mistral': 2580, 'n_tokens_neox': 2571, 'n_words': 390}