//オブジェクトパーサー(トゥート) function parse(obj, mix, acct_id) { var templete = ''; var datetype = localStorage.getItem("datetype"); var nsfwtype = localStorage.getItem("nsfw"); var sent = localStorage.getItem("sentence"); if (!sent) { var sent = 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"; } var local = []; Object.keys(obj).forEach(function(key) { var toot = obj[key]; var id = toot.id; //Integratedである場合はUnix時間をキーに配列を生成しておく if (mix == "mix") { local[date(obj[key].created_at, 'unix')] = toot.id; } if (mix == "home") { var home = "Home TLより" } else { var home = ""; } if (toot.reblog) { var notice = toot.account.display_name + "(" + toot.account.acct + ")がブースト
"; var boostback = "shared"; var toot = toot.reblog; } else { var notice = ""; var boostback = ""; } if (toot.account.locked) { var locked = ' '; } else { var locked = ""; } if (!toot.application) { var via = "Unknown"; } else { var via = toot.application.name; } if (toot.spoiler_text && cw) { var content = toot.content; var spoil = toot.spoiler_text; var spoiler = "cw cw_hide_" + toot.id; var api_spoil = "gray"; var spoiler_show = '見る'; } else { var ct = toot.content.split('

').length + toot.content.split('
').length - 2; if (sent < ct && $.mb_strlen(toot.content) > 5) { var content = '以下全文
' + toot.content var spoil = $.strip_tags($.mb_substr(toot.content, 0, 100)) + '自動折りたたみ'; var spoiler = "cw cw_hide_" + toot.id; var spoiler_show = '続き…'; } else { var content = toot.content; var spoil = toot.spoiler_text; var spoiler = ""; var spoiler_show = ""; } } var viewer = ""; var youtube = ""; var emojick = toot.emojis[0]; //絵文字があれば if (emojick) { Object.keys(toot.emojis).forEach(function(key5) { var emoji = toot.emojis[key5]; var shortcode = emoji.shortcode; var emoji_url = ''; var regExp = new RegExp(":" + shortcode + ":", "g"); content = content.replace(regExp, emoji_url); }); } var mediack = toot.media_attachments[0]; //メディアがあれば if (mediack) { 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; var url = media.url; if (toot.sensitive && nsfw) { var sense = "sensitive" } else { var sense = "" } viewer = viewer + ''; }); } else { viewer = ""; } var menck = toot.mentions[0]; var mentions = ""; //メンションであれば if (menck) { mentions = "Links: "; Object.keys(toot.mentions).forEach(function(key3) { var mention = toot.mentions[key3]; mentions = mentions + '@' + mention.acct + ' '; }); } var tagck = toot.tags[0]; var tags = ""; //タグであれば if (tagck) { if (!menck) { tags = "Links: "; } Object.keys(toot.tags).forEach(function(key4) { var tag = toot.tags[key4]; tags = tags + '#' + tag.name + ' '; }); } if (toot.account.acct == localStorage.getItem("user_" + acct_id)) { var if_mine = ""; } else { var if_mine = "hide"; } if (toot.favourited) { var if_fav = " yellow-text"; var fav_app = "faved"; } else { var if_fav = ""; var fav_app = ""; } if (toot.reblogged) { var if_rt = "teal-text"; var rt_app = "rted"; } else { var if_rt = ""; var rt_app = ""; } templete = templete + '
' + '' + notice + home + '' + '
' + '
' + '
' + '
' + toot.account.display_name + '
' + '
@' + toot.account.acct + locked + '
' + '
' + '' + '' + content + '' + spoil + spoiler_show + '' + '' + viewer + '' + '
URL解析
' + date(toot.created_at, datetype) + '' + 'via ' + via + 'どこから投稿したか' + mentions + tags + '
' + '
' + '
' + toot.reblogs_count + '
' + '
' + toot.favourites_count + '
' + '
' + '
more_vert
' + '
' + '
' + '
' + ''; }); if (mix == "mix") { return [templete, local] } else { return templete; } } //オブジェクトパーサー(ユーザーデータ) function userparse(obj, auth) { var templete = ''; Object.keys(obj).forEach(function(key) { var toot = obj[key]; if (toot.locked) { var locked = ' '; } else { var locked = ""; } if (auth) { var auth = 'person_add'; } else { var auth = ""; } templete = templete + '
' + '
' + '
' + '
' + '
' + toot.display_name + '
' + '
@' + toot.acct + locked + '
' + '
' + auth + '
Follows:' + toot.following_count + '
Followers:' + toot.followers_count + '
' + '
' + '
' + '
'; }); return templete; }