function escapeHTMLtemp(str) {
if (!str) {
return "";
}
return str.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
$.strip_tagstemp = function (str, allowed) {
if (!str) {
return "";
}
allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || [])
.join('');
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi,
commentsAndPhpTags = /|<\?(?:php)?[\s\S]*?\?>/gi;
return str.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) {
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
});
};
//オブジェクトパーサー(トゥート)
function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var templete = '';
localStorage.setItem("lastunix_" + tlid, date(obj[0].createdAt, '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 native = localStorage.getItem("nativenotf");
if (!native) {
native = "yes";
}
//クライアント強調
var empCli = localStorage.getItem("client_emp");
if (empCli) {
var empCli = JSON.parse(empCli);
} else {
var empCli = [];
}
//クライアントミュート
var muteCli = localStorage.getItem("client_mute");
if (muteCli) {
var muteCli = JSON.parse(muteCli);
} else {
var muteCli = [];
}
//ユーザー強調
var useremp = localStorage.getItem("user_emp");
if (useremp) {
var useremp = JSON.parse(useremp);
}
//ワード強調
var wordempList = localStorage.getItem("word_emp");
if (wordempList) {
var wordempList = JSON.parse(wordempList);
}
//ワードミュート
var wordmuteList = localStorage.getItem("word_mute");
if (wordmuteList) {
var wordmuteList = JSON.parse(wordmuteList);
if (wordmuteList) {
wordmuteList = wordmuteList.concat(mutefilter);
}
} else {
wordmuteList = mutefilter;
}
//Ticker
var tickerck = localStorage.getItem("ticker_ok");
if (tickerck) {
var ticker = true;
} else {
var ticker = false;
}
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 toot = obj[key];
var dis_name = toot.user.name;
if (dis_name) {
dis_name = escapeHTMLtemp(dis_name);
} else {
disname = "";
}
//絵文字があれば
if (toot.user.emojis) {
Object.keys(toot.user.emojis).forEach(function (key5) {
var emoji = toot.user.emojis[key5];
var shortcode = emoji.name;
var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
if (mix == "notf") {
if (gif == "yes") {
noticeavatar = toot.user.avatarUrl;
} else {
noticeavatar = toot.user.avatarUrl;
}
noticeavatar = '' +
'';
if (toot.type == "reply") {
var what = lang.lang_parse_mentioned;
var icon = '';
noticeavatar = "";
} else if (toot.type == "renote") {
var what = lang.lang_misskeyparse_renoted;
var icon = '';
} else if (toot.type == "quote") {
var what = lang.lang_misskeyparse_quoted;
var icon = '';
} else if (toot.type == "reaction") {
var what = lang.lang_misskeyparse_reacted;
var reactions = {
"like": "👍",
"love": "💓",
"laugh": "😁",
"hmm": "🤔",
"surprise": "😮",
"congrats": "🎉",
"amgry": "💢",
"confused": "😥",
"rip": "😇"
}
var icon = reactions[toot.reaction];
var emojisData = JSON.parse(localStorage.getItem("emoji_" + acct_id));
if (!icon) {
if (emojisData) {
var num = emojisData.length;
var ehtml = "";
for (i = 0; i < num; i++) {
var emoji = emojisData[i];
if (":" + emoji.shortcode + ":" == toot.reaction) {
if (emoji) {
icon = '';
}
}
}
}
}
} else {
var icon = 'info';
}
var noticetext = '' + date(toot.createdAt,
datetype) +
'' + icon + '' + dis_name +
"(@" + toot.user.username +
")";
var notice = noticetext;
var memory = localStorage.getItem("notice-mem");
if (popup >= 0 && obj.length < 5 && noticetext != memory) {
if (localStorage.getItem("hasNotfC_" + acct_id) != "true") {
if (toot.type == "reply") {
var replyct = localStorage.getItem("notf-reply_" + acct_id)
$(".notf-reply_" + acct_id).text(replyct * 1 - (-1));
localStorage.setItem("notf-reply_" + acct_id, replyct * 1 - (-1))
$(".notf-reply_" + acct_id).removeClass("hide")
} else if (toot.type == "renote" || toot.type == "quote") {
var btct = localStorage.getItem("notf-bt_" + acct_id)
$(".notf-bt_" + acct_id).text(btct * 1 + 1);
localStorage.setItem("notf-bt_" + acct_id, btct * 1 - (-1))
$(".notf-bt_" + acct_id).removeClass("hide")
} else if (toot.type == "reaction") {
var favct = localStorage.getItem("notf-fav_" + acct_id)
$(".notf-fav_" + acct_id).text(favct * 1 - (-1));
localStorage.setItem("notf-fav_" + acct_id, favct * 1 - (-1))
$(".notf-fav_" + acct_id).removeClass("hide")
}
}
var domain = localStorage.getItem("domain_" + acct_id);
if (popup > 0) {
Mtoast({ html: "[" + domain + "]" + escapeHTMLtemp(toot.user.name) + what, displayLength: popup * 1000 })
}
if (native == "yes") {
var os = localStorage.getItem("platform");
var options = {
body: toot.user.name + "(" + toot.user.username + ")" + what + "\n\n" + $.strip_tagstemp(toot.note.text),
icon: toot.user.avatarUrl
};
var n = new Notification('TheDesk:' + domain, options);
}
if (localStorage.getItem("hasNotfC_" + acct_id) != "true") {
$(".notf-icon_" + acct_id).addClass("red-text");
}
localStorage.setItem("notice-mem", noticetext);
noticetext = "";
}
var if_notf = 'data-notfIndv="' + acct_id + "_" + toot.id + '"';
var toot = toot.note;
var dis_name = escapeHTML(toot.user.name);
} else {
var if_notf = "";
if (toot.renote) {
var rebtxt = lang.lang_parse_btedsimple;
var rticon = "fa-retweet light-blue-text";
var notice = '' + dis_name + "(@" + toot.user.username +
")
";
var boostback = "shared";
var uniqueid = toot.id;
if (!toot.text) {
var toot = toot.renote;
}
var dis_name = escapeHTML(toot.user.name);
var uniqueid = toot.id;
var actemojick = false
} else {
var uniqueid = toot.id;
var notice = "";
var boostback = "";
//ユーザー強調
if (toot.user.host) {
var fullname = toot.user.username + "@" + toot.user.host;
} else {
var domain = localStorage.getItem("domain_" + acct_id);
var fullname = toot.user.username + "@" + domain;
}
if (useremp) {
Object.keys(useremp).forEach(function (key10) {
var user = useremp[key10];
if (user == fullname) {
boostback = "emphasized";
}
});
}
}
}
var id = toot.id;
if (mix == "home") {
var home = ""
var divider = '
';
} else {
var home = "";
var divider = '';
}
/*
if (toot.account.locked) {
var locked = ' ';
} else {
var locked = "";
}
*/
if (!toot.app) {
if (toot.viaMobile) {
var via = 'Mobile';
} else {
var via = '';
viashow = "via-hide";
}
} else {
var via = escapeHTML(toot.app.name);
if (!toot.app.name) {
viashow = "via-hide";
}
//強調チェック
Object.keys(empCli).forEach(function (key6) {
var empCliList = empCli[key6];
if (empCliList == via) {
boostback = "emphasized";
}
});
//ミュートチェック
Object.keys(muteCli).forEach(function (key7) {
var muteCliList = muteCli[key7];
if (muteCliList == via) {
boostback = "hide";
}
});
}
if ((toot.cw || toot.cw == "") && cw) {
var content = escapeHTML(toot.text);
var spoil = escapeHTMLtemp(toot.cw);
var spoiler = "cw cw_hide";
var api_spoil = "gray";
var spoiler_show = '' + lang.lang_parse_cwshow + '
';
} else {
var ct1 = nl2br(toot.text).split('
').length - 2;
var ct2 = nl2br(toot.text).split('
').length - 2;
if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; }
if ((sent < ct && $.mb_strlen($.strip_tagstemp(toot.text)) > 5) || ($.strip_tagstemp(toot.text).length > ltr && $.mb_strlen($.strip_tagstemp(toot.text)) > 5)) {
var content = '' + lang.lang_parse_fulltext + '
' + escapeHTMLtemp(toot.text)
var spoil = '' + $.mb_substr($.strip_tagstemp(
toot.text), 0, 100) +
'' + lang.lang_parse_autofold + '';
var spoiler = "cw cw_hide";
var spoiler_show = '' + lang.lang_parse_more + '
';
} else {
var content = escapeHTMLtemp(toot.text);
if (toot.cw) {
var spoil = escapeHTMLtemp(toot.cw);
} else {
var spoil = "";
}
var spoiler = "";
var spoiler_show = "";
}
}
var analyze = '';
var urls = $.strip_tagstemp(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 (content) {
//MFM
content = content.replace(/^"([^"]+)"$/gmi, '$1
')
content = content.replace(/`(.+)`/gi, '$1
')
content = content.replace(/(http(s)?:\/\/[\x21-\x7e]+)/gi, '$1')
content = content.replace(/\(\(\((.+)\)\)\)/gi, '$1')
content = content.replace(/<motion>(.+)<\/motion>/gi, '$1')
content = content.replace(/\*\*\*([^*]+)\*\*\*/gi, '$1')
content = content.replace(/\*\*([^*]+)\*\*/gi, '$1')
content = content.replace(/^(.+)\s(検索|search)$/gmi, 'search
')
content = content.replace(/\[(.+)\]\($1');
content = content.replace(/<center>/gi, '')
content = content.replace(/<\/center>/gi, '
')
content = content.replace(/<flip>(.+)<\/flip>/gi, '$1')
content = content.replace(/<small>(.+)<\/small>/gi, '$1')
content = content.replace(/<i>(.+)<\/i>/gi, '$1')
content = content.replace(/<spin>(.+)<\/spin>/gi, '$1')
content = content.replace(/\*\*(.+)\*\*/gi, '$1')
content = content.replace(/<jump>(.+)<\/jump>/gi, '$1')
content = twemoji.parse(content);
} else {
content = "";
}
//絵文字があれば
if (emojick) {
Object.keys(toot.emojis).forEach(function (key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.name;
var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
});
}
if (dis_name) {
dis_name = twemoji.parse(dis_name);
} else {
dis_name = "";
}
if (spoil) {
spoil = twemoji.parse(spoil);
}
if (noticetext) {
noticetext = twemoji.parse(noticetext);
}
if (notice) {
notice = twemoji.parse(notice);
}
if (toot.files) {
var mediack = toot.files[0];
var useparam = "files";
} else {
if (toot.media) {
var mediack = toot.media[0];
var useparam = "media";
} else {
var mediack = false;
}
}
//メディアがあれば
var media_ids = "";
if (mediack) {
hasmedia = "hasmedia";
var cwdt = 100 / toot[useparam].length;
Object.keys(toot[useparam]).forEach(function (key2) {
var media = toot[useparam][key2];
var purl = media.url;
media_ids = media_ids + media.id + ",";
var url = media.url;
if (media.isSensitive && nsfw) {
var sense = "sensitive"
} else {
var sense = ""
}
if (media.type.indexOf("video") !== -1) {
viewer = viewer + '';
} else if (media.type.indexOf("audio") !== -1) {
viewer = viewer + '