diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 5a1a0be0..143710eb 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -491,7 +491,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) { if (urlCont) { urlindv = urlindv.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&") var encoded = encodeURI(urlCont[4]) - var punycoded = "xn--"+punycode.encode(urlCont[2]) + var punycoded = "xn--" + punycode.encode(urlCont[2]) var eUrl = urlCont[1] + "://" + punycoded + "." + urlCont[3] + "/" + encoded var regExp = new RegExp('href="' + urlindv + '"', "g") console.log(eUrl, regExp) @@ -915,119 +915,122 @@ function userparse(obj, auth, acct_id, tlid, popup) { var datetype = localStorage.getItem("datetype"); Object.keys(obj).forEach(function (key) { var toot = obj[key]; - console.log(["Parsing", toot]) - if (!toot.username) { - var raw = toot; - toot = toot.account; - var notf = true; - } else { - var notf = false; - } - if (toot.locked) { - var locked = ' '; - } else { - var locked = ""; - } - if (auth == "request") { - var authhtml = 'person_add person_add_disabled'; - } else { - var authhtml = ""; - } - var ftxt = lang.lang_parse_followed; - if (!locale && localStorage.getItem("followlocale_" + acct_id)) { - ftxt = localStorage.getItem("followlocale_" + acct_id); - } - if (popup > 0 || popup == -1 || notf) { - var notftext = ftxt + '
'; - } else { - var notftext = ""; - } - var memory = localStorage.getItem("notice-mem"); - if (popup >= 0 && obj.length < 5 && notftext != memory) { - M.toast({ html: escapeHTML(toot.display_name) + ":" + ftxt, displayLength: popup * 1000 }) - $(".notf-icon_" + tlid).addClass("red-text"); - localStorage.setItem("notice-mem", notftext); - notftext = ""; - var native = localStorage.getItem("nativenotf"); - if (!native) { - native = "yes"; + if (toot) { + console.log(["Parsing", toot]) + if (!toot.username) { + var raw = toot; + toot = toot.account; + var notf = true; + } else { + var notf = false; } - if (native == "yes") { - var os = localStorage.getItem("platform"); - var options = { - body: toot.display_name + "(" + toot.acct + ")" + ftxt, - icon: toot.avatar - }; - var domain = localStorage.getItem("domain_" + acct_id); - if (os == "darwin") { - var n = new Notification('TheDesk:' + domain, options); - } else { - var nativeNotfOpt = [ - 'TheDesk:' + domain, - toot.display_name + "(" + toot.acct + ")" + ftxt, - toot.avatar, - "userdata", - acct_id, - toot.id - ] - postMessage(["nativeNotf", nativeNotfOpt], "*") + if (toot.locked) { + var locked = ' '; + } else { + var locked = ""; + } + if (auth == "request") { + var authhtml = 'person_add person_add_disabled'; + } else { + var authhtml = ""; + } + var ftxt = lang.lang_parse_followed; + if (!locale && localStorage.getItem("followlocale_" + acct_id)) { + ftxt = localStorage.getItem("followlocale_" + acct_id); + } + if (popup > 0 || popup == -1 || notf) { + var notftext = ftxt + '
'; + } else { + var notftext = ""; + } + var memory = localStorage.getItem("notice-mem"); + if (popup >= 0 && obj.length < 5 && notftext != memory) { + M.toast({ html: escapeHTML(toot.display_name) + ":" + ftxt, displayLength: popup * 1000 }) + $(".notf-icon_" + tlid).addClass("red-text"); + localStorage.setItem("notice-mem", notftext); + notftext = ""; + var native = localStorage.getItem("nativenotf"); + if (!native) { + native = "yes"; + } + if (native == "yes") { + var os = localStorage.getItem("platform"); + var options = { + body: toot.display_name + "(" + toot.acct + ")" + ftxt, + icon: toot.avatar + }; + var domain = localStorage.getItem("domain_" + acct_id); + if (os == "darwin") { + var n = new Notification('TheDesk:' + domain, options); + } else { + var nativeNotfOpt = [ + 'TheDesk:' + domain, + toot.display_name + "(" + toot.acct + ")" + ftxt, + toot.avatar, + "userdata", + acct_id, + toot.id + ] + postMessage(["nativeNotf", nativeNotfOpt], "*") + } } } - } - if (toot.display_name) { - var dis_name = escapeHTML(toot.display_name); - } else { - var dis_name = toot.username; - } - //ネイティブ通知 + if (toot.display_name) { + var dis_name = escapeHTML(toot.display_name); + } else { + var dis_name = toot.username; + } + //ネイティブ通知 - if (toot.emojis) { - var actemojick = toot.emojis[0]; - } else { - var actemojick = false; - } - //絵文字があれば - if (actemojick) { - 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"); - dis_name = dis_name.replace(regExp, emoji_url); - }); - } - if (dis_name) { - dis_name = twemoji.parse(dis_name); - } - if (toot.avatar) { - var avatar = toot.avatar; - } else { - var avatar = "../../img/missing.svg"; + if (toot.emojis) { + var actemojick = toot.emojis[0]; + } else { + var actemojick = false; + } + //絵文字があれば + if (actemojick) { + 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"); + dis_name = dis_name.replace(regExp, emoji_url); + }); + } + if (dis_name) { + dis_name = twemoji.parse(dis_name); + } + if (toot.avatar) { + var avatar = toot.avatar; + } else { + var avatar = "../../img/missing.svg"; + } + + templete = templete + + '
' + + notftext + + '
' + + '
' + + '
' + + dis_name + '' + + ' @' + + toot.acct + locked + '' + + '
' + + '
' + + '
Follows:' + + toot.following_count + + '
Followers:' + toot.followers_count + + '
' + authhtml + + '
' + + '
' + + ''; } - templete = templete + - '
' + - notftext + - '
' + - '
' + - '
' + - dis_name + '' + - ' @' + - toot.acct + locked + '' + - '
' + - '
' + - '
Follows:' + - toot.following_count + - '
Followers:' + toot.followers_count + - '
' + authhtml + - '
' + - '
' + - ''; }); return templete;