//DM(Conv) TL function dm(acct_id, tlid, type, delc, voice) { var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_" + acct_id + "_at"); var start = "https://" + domain + "/api/v1/conversations"; fetch(start, { method: "GET", headers: { "content-type": "application/json", Authorization: "Bearer " + at } }) .then(function(response) { if (!response.ok) { response.text().then(function(text) { setLog(response.url, response.status, text); }); } return response.json(); }) .catch(function(error) { todo(error); setLog(start, "JSON", error); console.error(error); }) .then(function(json) { var templete = '
' + dmListParse(json, type, acct_id, tlid, "", mute) + "
"; localStorage.setItem("lastobj_" + tlid, json[0].id); $("#timeline_" + tlid).html(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); todc(); //reload(type, '', acct_id, tlid, data, mute, delc,voice); $(window).scrollTop(0); }); } function dmmore(tlid) { var multi = localStorage.getItem("column"); var obj = JSON.parse(multi); var acct_id = obj[tlid].domain; var domain = localStorage.getItem("domain_" + acct_id); var at = localStorage.getItem("acct_" + acct_id + "_at"); var sid = $("#timeline_" + tlid + " .cvo") .last() .attr("unique-id"); var start = "https://" + domain + "/api/v1/conversations?max_id=" + sid; var type = "dm"; fetch(start, { method: "GET", headers: { "content-type": "application/json", Authorization: "Bearer " + at } }) .then(function(response) { if (!response.ok) { response.text().then(function(text) { setLog(response.url, response.status, text); }); } return response.json(); }) .catch(function(error) { todo(error); setLog(start, "JSON", error); console.error(error); }) .then(function(json) { var templete = '
' + dmListParse(json, type, acct_id, tlid, "", mute) + "
"; $("#timeline_" + tlid).append(templete); additional(acct_id, tlid); jQuery("time.timeago").timeago(); moreloading = false; }); } //DMオブジェクトパーサー(トゥート) function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) { var templete = ""; if (obj[0]) { localStorage.setItem("lastunix_" + tlid, date(obj[0].created_at, "unix")); } var actb = localStorage.getItem("action_btns"); var actb = "re,rt,fav,qt,del,pin,red"; if (actb) { var actb = actb.split(","); var disp = {}; for (var k = 0; k < actb.length; k++) { if (k < 4) { var tp = "type-a"; } else { var tp = "type-b"; } disp[actb[k]] = tp; } } var datetype = localStorage.getItem("datetype"); var nsfwtype = localStorage.getItem("nsfw"); var sent = localStorage.getItem("sentence"); var ltr = localStorage.getItem("letters"); var gif = localStorage.getItem("gif"); var imh = localStorage.getItem("img-height"); //独自ロケール var locale = localStorage.getItem("locale"); if (locale == "yes") { var locale = false; } //ネイティブ通知 var native = localStorage.getItem("nativenotf"); if (!native) { native = "yes"; } //クライアント強調 var emp = localStorage.getItem("client_emp"); if (emp) { var emp = JSON.parse(emp); } //クライアントミュート var mute = localStorage.getItem("client_mute"); if (mute) { var mute = JSON.parse(mute); } //ユーザー強調 var useremp = localStorage.getItem("user_emp"); if (useremp) { var useremp = JSON.parse(useremp); } //ワード強調 var wordemp = localStorage.getItem("word_emp"); if (wordemp) { var wordemp = JSON.parse(wordemp); } //ワードミュート var wordmute = localStorage.getItem("word_mute"); if (wordmute) { var wordmute = JSON.parse(wordmute); wordmute = wordmute.concat(mutefilter); } else { wordmute = mutefilter; } //Ticker var tickerck = localStorage.getItem("ticker_ok"); if (tickerck) { var ticker = true; } else { var ticker = false; } //Cards var card = localStorage.getItem("card_" + tlid); if (!sent) { var sent = 500; } if (!ltr) { var ltr = 500; } if (!nsfwtype || nsfwtype == "yes") { var nsfw = "ok"; } else { var nsfw; } var cwtype = localStorage.getItem("cw"); if (!cwtype || cwtype == "yes") { var cw = "ok"; } else { var cw; } if (!datetype) { datetype = "absolute"; } if (!gif) { var gif = "yes"; } if (!imh) { var imh = "200"; } if (!emp) { var emp = []; } if (!mute) { var mute = []; } if (!useremp) { var useremp = []; } if (!wordemp) { var wordemp = []; } if (!wordmute) { var wordmute = []; } //via通知 var viashow = localStorage.getItem("viashow"); if (!viashow) { viashow = "via-hide"; } if (viashow == "hide") { viashow = "via-hide"; } //認証なしTL if (mix == "noauth") { var noauth = "hide"; var antinoauth = ""; } else { var noauth = ""; var antinoauth = "hide"; } //マウスオーバーのみ var mouseover = localStorage.getItem("mouseover"); if (!mouseover) { mouseover = ""; } else if (mouseover == "yes" || mouseover == "click") { mouseover = "hide"; } else if (mouseover == "no") { mouseover = ""; } var local = []; var times = []; Object.keys(obj).forEach(function(key) { var conv_id = obj[key].id; var toot = obj[key].last_status; var dis_name = escapeHTML(toot.account.display_name); if (toot.account.emojis) { var actemojick = toot.account.emojis[0]; } else { var actemojick = false; } //絵文字があれば if (actemojick) { Object.keys(toot.account.emojis).forEach(function(key5) { var emoji = toot.account.emojis[key5]; var shortcode = emoji.shortcode; var emoji_url = ' :' + shortcode + ': '; var regExp = new RegExp(":" + shortcode + ":", "g"); dis_name = dis_name.replace(regExp, emoji_url); }); } var noticeavatar = ""; var if_notf = ""; var uniqueid = toot.id; var notice = ""; var boostback = ""; //ユーザー強調 if (toot.account.username != toot.account.acct) { var fullname = toot.account.acct; } else { var domain = localStorage.getItem("domain_" + acct_id); var fullname = toot.account.acct + "@" + domain; } if (useremp) { Object.keys(useremp).forEach(function(key10) { var user = useremp[key10]; if (user == fullname) { boostback = "emphasized"; } }); } var id = toot.id; var home = ""; if (toot.account.locked) { var locked = ' '; } else { var locked = ""; } if (!toot.application) { var via = ""; viashow = "hide"; } else { var via = escapeHTML(toot.application.name); //強調チェック Object.keys(emp).forEach(function(key6) { var cli = emp[key6]; if (cli == via) { boostback = "emphasized"; } }); //ミュートチェック Object.keys(mute).forEach(function(key7) { var cli = mute[key7]; if (cli == via) { boostback = "hide"; } }); } if (mix == "pinned") { boostback = "emphasized"; } if (toot.spoiler_text && cw) { var content = toot.content; var spoil = escapeHTML(toot.spoiler_text); var spoiler = "cw cw_hide_" + toot.id; var api_spoil = "gray"; var spoiler_show = '' + lang.lang_parse_cwshow + "
"; } else { var ct1 = toot.content.split("

").length + toot.content.split("
").length - 2; var ct2 = toot.content.split("

").length + toot.content.split("
").length - 2; if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; } if ((sent < ct && $.mb_strlen($.strip_tags(toot.content)) > 5) || ($.strip_tags(toot.content).length > ltr && $.mb_strlen($.strip_tags(toot.content)) > 5)) { var content = '' + lang.lang_parse_fulltext + "
" + toot.content; var spoil = '' + $.mb_substr($.strip_tags(toot.content), 0, 100) + '' + lang.lang_parse_autofold + ""; var spoiler = "cw cw_hide_" + toot.id; var spoiler_show = '' + lang.lang_parse_more + "
"; } else { var content = toot.content; var spoil = escapeHTML(toot.spoiler_text); var spoiler = ""; var spoiler_show = ""; } } var urls = $.strip_tags(content) .replace(/\n/g, " ") .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/); if (urls) { var analyze = "' + lang.lang_parse_url + "
"; } else { var analyze = ""; } var viewer = ""; var hasmedia = ""; var youtube = ""; if (toot.emojis) { var emojick = toot.emojis[0]; } else { var emojick = false; } //絵文字があれば if (emojick) { Object.keys(toot.emojis).forEach(function(key5) { var emoji = toot.emojis[key5]; var shortcode = emoji.shortcode; var emoji_url = ' :' + shortcode + ': '; var regExp = new RegExp(":" + shortcode + ":", "g"); content = content.replace(regExp, emoji_url); spoil = spoil.replace(regExp, emoji_url); }); } //ニコフレ絵文字 if (toot.profile_emojis) { var nicoemojick = toot.profile_emojis[0]; } else { var nicoemojick = false; } //絵文字があれば if (nicoemojick) { Object.keys(toot.profile_emojis).forEach(function(keynico) { var emoji = toot.profile_emojis[keynico]; var shortcode = emoji.shortcode; var emoji_url = ' :' + shortcode + ': '; var regExp = new RegExp(":" + shortcode + ":", "g"); content = content.replace(regExp, emoji_url); spoil = spoil.replace(regExp, emoji_url); }); } //デフォ絵文字 content = twemoji.parse(content); if (dis_name) { dis_name = twemoji.parse(dis_name); } if (spoil) { spoil = twemoji.parse(spoil); } var mediack = toot.media_attachments[0]; //メディアがあれば var media_ids = ""; if (mediack) { hasmedia = "hasmedia"; var cwdt = 100 / toot.media_attachments.length; Object.keys(toot.media_attachments).forEach(function(key2) { var media = toot.media_attachments[key2]; var purl = media.preview_url; media_ids = media_ids + media.id + ","; var url = media.url; if (toot.sensitive && nsfw) { var sense = "sensitive"; } else { var sense = ""; } viewer = viewer + "'; }); media_ids = media_ids.slice(0, -1); } else { viewer = ""; hasmedia = "nomedia"; } var menck = toot.mentions[0]; var mentions = ""; //メンションであれば if (menck) { mentions = ""; Object.keys(toot.mentions).forEach(function(key3) { var mention = toot.mentions[key3]; mentions = mentions + "@' + mention.acct + " "; }); mentions = '
' + mentions + "
"; } var tagck = toot.tags[0]; var tags = ""; //タグであれば if (tagck) { Object.keys(toot.tags).forEach(function(key4) { var tag = toot.tags[key4]; tags = tags + '#' + tag.name + ":TL Toot ' + "Pin '; }); tags = '
' + tags + "
"; } //アニメ再生 if (gif == "yes") { var avatar = toot.account.avatar; } else { var avatar = toot.account.avatar_static; } //ワードミュート if (wordmute) { Object.keys(wordmute).forEach(function(key8) { var worde = wordmute[key8]; if (worde) { if (worde.tag) { var word = worde.tag; } else { var word = worde; } var regExp = new RegExp(word, "g"); if ($.strip_tags(content).match(regExp)) { boostback = "hide by_filter"; } } }); } //ワード強調 if (wordemp) { Object.keys(wordemp).forEach(function(key9) { var word = wordemp[key9]; if (word) { var word = word.tag; var regExp = new RegExp(word, "g"); content = content.replace(regExp, '' + escapeHTML(word) + ""); } }); } //日本語じゃない if (toot.language != "ja") { var trans = '
g_translate
'; } else { var trans = ""; } if (toot.favourited) { var if_fav = " yellow-text"; var fav_app = "faved"; } else { var if_fav = ""; var fav_app = ""; } //Cards if (!card && toot.card) { var cards = toot.card; if (cards.provider_name == "Twitter") { if (cards.image) { var twiImg = '
'; } else { var twiImg = ""; } analyze = '
' + escapeHTML(cards.author_name) + "
" + escapeHTML(cards.description) + twiImg + "
"; } if (cards.title) { analyze = 'URL' + lang.lang_cards_check + ":
Title:" + escapeHTML(cards.title) + "
" + escapeHTML(cards.description) + "
"; } if (cards.html) { analyze = cards.html + 'picture_in_picture_alt'; } } //Ticker var tickerdom = ""; if (ticker) { var tickerdata = localStorage.getItem("ticker"); if (tickerdata) { var tickerdata = JSON.parse(tickerdata); var thisdomain = toot.account.acct.split("@"); if (thisdomain.length > 1) { thisdomain = thisdomain[1]; } for (var i = 0; i < tickerdata.length; i++) { var value = tickerdata[i]; if (value.domain == thisdomain) { var tickerdom = '
' + escapeHTML(value.name) + "
"; break; } } } } templete = templete + '
' + '
' + notice + home + "
" + '
' + '' + noticeavatar + "
" + '
' + dis_name + ' @' + toot.account.acct + locked + "
" + '
' + date(toot.created_at, datetype) + "" + "
" + '
' + tickerdom + '' + spoil + "" + spoiler_show + '' + content + "" + "" + viewer + "" + "
" + lang.lang_parse_thread + "
" + '
' + "
"; }); return templete; }