From 1710ab00350c952708732ede1d75b40e44e8300d Mon Sep 17 00:00:00 2001 From: cutls Date: Sun, 2 Aug 2020 16:08:07 +0900 Subject: [PATCH] [WIP] linting --- app/.eslintignore | 5 + app/.eslintrc.json | 14 + app/js/common/modal.js | 10 +- app/js/common/time.js | 154 +++---- app/js/emoji/emojipack.js | 16 +- app/js/login/instance.js | 4 +- app/js/login/logout.js | 8 +- app/js/tl/date.js | 78 ++-- app/js/tl/directory.js | 72 ++-- app/js/tl/dm.js | 488 ++++++++++----------- app/js/tl/misskeyparse.js | 792 +++++++++++++++++------------------ app/js/ui/img.js | 4 +- app/js/ui/menu.js | 66 +-- app/js/ui/pip.js | 32 +- app/js/ui/radio.js | 42 +- app/js/ui/sort.js | 90 ++-- app/js/userdata/his-data.js | 534 +++++++++++------------ app/js/userdata/prof-edit.js | 82 ++-- app/js/userdata/showOnTL.js | 632 ++++++++++++++-------------- app/package.json | 10 +- app/yarn.lock | 398 +++++++++++++++++- 21 files changed, 1971 insertions(+), 1560 deletions(-) create mode 100644 app/.eslintignore create mode 100644 app/.eslintrc.json diff --git a/app/.eslintignore b/app/.eslintignore new file mode 100644 index 00000000..32f095ab --- /dev/null +++ b/app/.eslintignore @@ -0,0 +1,5 @@ +js/common/blurhash.js +js/common/hammer.min.js +js/common/sha256.js +js/platform/punycode.js +js/platform/tj-deck.js \ No newline at end of file diff --git a/app/.eslintrc.json b/app/.eslintrc.json new file mode 100644 index 00000000..0cb1a0f1 --- /dev/null +++ b/app/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "extends": "eslint:recommended", + "env": {"browser": true}, + "rules": { + "no-console": "off", + "semi": ["error", "never"] + }, + "globals": { + "$": false, + "ver": true, + "pwa": true, + "lang": true + } +} \ No newline at end of file diff --git a/app/js/common/modal.js b/app/js/common/modal.js index bebc7dcb..d45b3478 100644 --- a/app/js/common/modal.js +++ b/app/js/common/modal.js @@ -10,7 +10,7 @@ $(document).ready(function () { belowOrigin: false, // Displays dropdown below the button alignment: 'left', // Displays dropdown with edge aligned to the left of button stopPropagation: false - }); + }) $('.dropdown-trigger').dropdown({ inDuration: 300, outDuration: 225, @@ -21,9 +21,9 @@ $(document).ready(function () { alignment: 'left', // Displays dropdown with edge aligned to the left of button stopPropagation: false // Stops event propagation } - ); - $('.collapsible').collapsible(); + ) + $('.collapsible').collapsible() $('#videomodal').modal({ onCloseEnd: stopVideo - }); -}); \ No newline at end of file + }) +}) \ No newline at end of file diff --git a/app/js/common/time.js b/app/js/common/time.js index 2516e6e3..fa72e335 100644 --- a/app/js/common/time.js +++ b/app/js/common/time.js @@ -17,26 +17,26 @@ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['jquery'], factory); + define(['jquery'], factory) } else if (typeof module === 'object' && typeof module.exports === 'object') { - factory(require('jquery')); + factory(require('jquery')) } else { // Browser globals - factory(jQuery); + factory(jQuery) } }(function ($) { $.timeago = function (timestamp) { if (timestamp instanceof Date) { - return inWords(timestamp); + return inWords(timestamp) } else if (typeof timestamp === "string") { - return inWords($.timeago.parse(timestamp)); + return inWords($.timeago.parse(timestamp)) } else if (typeof timestamp === "number") { - return inWords(new Date(timestamp)); + return inWords(new Date(timestamp)) } else { - return inWords($.timeago.datetime(timestamp)); + return inWords($.timeago.datetime(timestamp)) } - }; - var $t = $.timeago; + } + var $t = $.timeago $.extend($.timeago, { settings: { refreshMillis: 60000, @@ -69,33 +69,33 @@ inWords: function (distanceMillis) { if (!this.settings.allowPast && !this.settings.allowFuture) { - throw 'timeago allowPast and allowFuture settings can not both be set to false.'; + throw 'timeago allowPast and allowFuture settings can not both be set to false.' } - var $l = this.settings.strings; - var prefix = $l.prefixAgo; - var suffix = $l.suffixAgo; + var $l = this.settings.strings + var prefix = $l.prefixAgo + var suffix = $l.suffixAgo if (this.settings.allowFuture) { if (distanceMillis < 0) { - prefix = $l.prefixFromNow; - suffix = $l.suffixFromNow; + prefix = $l.prefixFromNow + suffix = $l.suffixFromNow } } if (!this.settings.allowPast && distanceMillis >= 0) { - return this.settings.strings.inPast; + return this.settings.strings.inPast } - var seconds = Math.abs(distanceMillis) / 1000; - var minutes = seconds / 60; - var hours = minutes / 60; - var days = hours / 24; - var years = days / 365; + var seconds = Math.abs(distanceMillis) / 1000 + var minutes = seconds / 60 + var hours = minutes / 60 + var days = hours / 24 + var years = days / 365 function substitute(stringOrFunction, number) { - var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction; - var value = ($l.numbers && $l.numbers[number]) || number; - return string.replace(/%d/i, value); + var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction + var value = ($l.numbers && $l.numbers[number]) || number + return string.replace(/%d/i, value) } var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) || @@ -108,124 +108,124 @@ days < 45 && substitute($l.month, 1) || days < 365 && substitute($l.months, Math.round(days / 30)) || years < 1.5 && substitute($l.year, 1) || - substitute($l.years, Math.round(years)); + substitute($l.years, Math.round(years)) - var separator = $l.wordSeparator || ""; - if ($l.wordSeparator === undefined) { separator = " "; } - return $.trim([prefix, words, suffix].join(separator)); + var separator = $l.wordSeparator || "" + if ($l.wordSeparator === undefined) { separator = " " } + return $.trim([prefix, words, suffix].join(separator)) }, parse: function (iso8601) { - var s = $.trim(iso8601); - s = s.replace(/\.\d+/, ""); // remove milliseconds - s = s.replace(/-/, "/").replace(/-/, "/"); - s = s.replace(/T/, " ").replace(/Z/, " UTC"); - s = s.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2"); // -04:00 -> -0400 - s = s.replace(/([\+\-]\d\d)$/, " $100"); // +09 -> +0900 - return new Date(s); + var s = $.trim(iso8601) + s = s.replace(/\.\d+/, "") // remove milliseconds + s = s.replace(/-/, "/").replace(/-/, "/") + s = s.replace(/T/, " ").replace(/Z/, " UTC") + s = s.replace(/([\+\-]\d\d)\:?(\d\d)/, " $1$2") // -04:00 -> -0400 + s = s.replace(/([\+\-]\d\d)$/, " $100") // +09 -> +0900 + return new Date(s) }, datetime: function (elem) { - var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title"); - return $t.parse(iso8601); + var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title") + return $t.parse(iso8601) }, isTime: function (elem) { // jQuery's `is()` doesn't play well with HTML5 in IE - return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time"); + return $(elem).get(0).tagName.toLowerCase() === "time" // $(elem).is("time"); } - }); + }) // functions that can be called via $(el).timeago('action') // init is default when no action is given // functions are called with context of a single element var functions = { init: function () { - functions.dispose.call(this); - var refresh_el = $.proxy(refresh, this); - refresh_el(); - var $s = $t.settings; + functions.dispose.call(this) + var refresh_el = $.proxy(refresh, this) + refresh_el() + var $s = $t.settings if ($s.refreshMillis > 0) { - this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis); + this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis) } }, update: function (timestamp) { - var date = (timestamp instanceof Date) ? timestamp : $t.parse(timestamp); - $(this).data('timeago', { datetime: date }); + var date = (timestamp instanceof Date) ? timestamp : $t.parse(timestamp) + $(this).data('timeago', { datetime: date }) if ($t.settings.localeTitle) { - $(this).attr("title", date.toLocaleString()); + $(this).attr("title", date.toLocaleString()) } - refresh.apply(this); + refresh.apply(this) }, updateFromDOM: function () { - $(this).data('timeago', { datetime: $t.parse($t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title")) }); - refresh.apply(this); + $(this).data('timeago', { datetime: $t.parse($t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title")) }) + refresh.apply(this) }, dispose: function () { if (this._timeagoInterval) { - window.clearInterval(this._timeagoInterval); - this._timeagoInterval = null; + window.clearInterval(this._timeagoInterval) + this._timeagoInterval = null } } - }; + } $.fn.timeago = function (action, options) { - var fn = action ? functions[action] : functions.init; + var fn = action ? functions[action] : functions.init if (!fn) { - throw new Error("Unknown function name '" + action + "' for timeago"); + throw new Error("Unknown function name '" + action + "' for timeago") } // each over objects here and call the requested function this.each(function () { - fn.call(this, options); - }); - return this; - }; + fn.call(this, options) + }) + return this + } function refresh() { - var $s = $t.settings; + var $s = $t.settings //check if it's still visible if ($s.autoDispose && !$.contains(document.documentElement, this)) { //stop if it has been removed - $(this).timeago("dispose"); - return this; + $(this).timeago("dispose") + return this } - var data = prepareData(this); + var data = prepareData(this) if (!isNaN(data.datetime)) { if ($s.cutoff === 0 || Math.abs(distance(data.datetime)) < $s.cutoff) { - $(this).text(inWords(data.datetime)); + $(this).text(inWords(data.datetime)) } else { if ($(this).attr('title').length > 0) { - $(this).text($(this).attr('title')); + $(this).text($(this).attr('title')) } } } - return this; + return this } function prepareData(element) { - element = $(element); + element = $(element) if (!element.data("timeago")) { - element.data("timeago", { datetime: $t.datetime(element) }); - var text = $.trim(element.text()); + element.data("timeago", { datetime: $t.datetime(element) }) + var text = $.trim(element.text()) if ($t.settings.localeTitle) { - element.attr("title", element.data('timeago').datetime.toLocaleString()); + element.attr("title", element.data('timeago').datetime.toLocaleString()) } else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) { - element.attr("title", text); + element.attr("title", text) } } - return element.data("timeago"); + return element.data("timeago") } function inWords(date) { - return $t.inWords(distance(date)); + return $t.inWords(distance(date)) } function distance(date) { - return (new Date().getTime() - date.getTime()); + return (new Date().getTime() - date.getTime()) } // fix for IE6 suckage - document.createElement("abbr"); - document.createElement("time"); -})); \ No newline at end of file + document.createElement("abbr") + document.createElement("time") +})) \ No newline at end of file diff --git a/app/js/emoji/emojipack.js b/app/js/emoji/emojipack.js index db0d5646..08c9302e 100644 --- a/app/js/emoji/emojipack.js +++ b/app/js/emoji/emojipack.js @@ -92,7 +92,7 @@ var activity=[ {shortcode:"man-rowing-boat",css:"95.8333% 14.5833%"}, {shortcode:"man-biking",css:"95.8333% 39.5833%"}, {shortcode:"man-mountain-biking",css:"95.8333% 64.5833%"} - ]; + ] var flag=[ {shortcode:"checkered_flag",css:"16.6667% 58.3333%"}, {shortcode:"crossed_flags",css:"14.5833% 60.4167%"}, @@ -356,7 +356,7 @@ var flag=[ {shortcode:"rainbow-flag",css:"83.3333% 100%"}, {shortcode:"triangular_flag_on_post",css:"54.1667% 6.25%"}, {shortcode:"waving_black_flag",css:"20.8333% 29.1667%"}, - {shortcode:"waving_white_flag",css:"20.8333% 27.0833%"}]; + {shortcode:"waving_white_flag",css:"20.8333% 27.0833%"}] var food=[ {shortcode:"green_apple",css:"12.5% 25%"}, {shortcode:"apple",css:"12.5% 22.9167%"}, @@ -444,7 +444,7 @@ var food=[ {shortcode:"spoon",css:"62.5% 14.5833%"}, {shortcode:"fork_and_knife",css:"14.5833% 0%"}, {shortcode:"knife_fork_plate",css:"14.5833% 18.75%"} - ]; + ] var nature=[ {shortcode:"dog",css:"22.9167% 62.5%"}, {shortcode:"cat",css:"22.9167% 52.0833%"}, @@ -605,7 +605,7 @@ var nature=[ {shortcode:"droplet",css:"35.4167% 39.5833%"}, {shortcode:"sweat_drops",css:"35.4167% 37.5%"}, {shortcode:"umbrella_with_rain_drops",css:"0% 100%"} - ]; + ] var object=[ {shortcode:"watch",css:"0% 29.1667%"}, {shortcode:"iphone",css:"39.5833% 0%"}, @@ -780,7 +780,7 @@ var object=[ {shortcode:"closed_lock_with_key",css:"39.5833% 62.5%"}, {shortcode:"lock",css:"39.5833% 66.6667%"}, {shortcode:"unlock",css:"39.5833% 68.75%"} - ]; + ] var people=[ {shortcode:"grinning",css:"45.8333% 68.75%"}, {shortcode:"smiley",css:"45.8333% 75%"}, @@ -1096,7 +1096,7 @@ var people=[ {shortcode:"woman-raising-hand",css:"93.75% 29.1667%"}, {shortcode:"woman-frowning",css:"93.75% 54.1667%"}, {shortcode:"woman-pouting",css:"93.75% 79.1667%"} - ]; + ] var place=[ {shortcode:"car",css:"52.0833% 60.4167%"}, {shortcode:"taxi",css:"52.0833% 56.25%"}, @@ -1217,7 +1217,7 @@ var place=[ {shortcode:"milky_way",css:"8.33333% 93.75%"}, {shortcode:"bridge_at_night",css:"8.33333% 87.5%"}, {shortcode:"foggy",css:"8.33333% 70.8333%"} - ]; + ] var symbol=[ {shortcode:"heart",css:"6.25% 62.5%"}, {shortcode:"yellow_heart",css:"35.4167% 14.5833%"}, @@ -1492,7 +1492,7 @@ var symbol=[ {shortcode:"female_sign",css:"2.08333% 37.5%"}, {shortcode:"male_sign",css:"2.08333% 39.5833%"}, {shortcode:"staff_of_aesculapius",css:"2.08333% 87.5%"} -]; +] var faicons=[ "fa-500px", "fa-address-book", diff --git a/app/js/login/instance.js b/app/js/login/instance.js index 4ac052b7..cfa52881 100644 --- a/app/js/login/instance.js +++ b/app/js/login/instance.js @@ -83,6 +83,6 @@ var idata = { "nitiasa.com_quote":"enabled", "biwakodon.com_quote":"enabled", "comm.cx_quote":"enabled" -}; +} -localStorage.setItem("instance", JSON.stringify(idata)); +localStorage.setItem("instance", JSON.stringify(idata)) diff --git a/app/js/login/logout.js b/app/js/login/logout.js index 56b71c23..c2960d6e 100644 --- a/app/js/login/logout.js +++ b/app/js/login/logout.js @@ -1,7 +1,7 @@ //ログアウトします function logout() { - localStorage.removeItem("acct_" + acct_id + "_at"); - localStorage.removeItem("domain_" + acct_id); - location.href = "index.html"; - todc(); + localStorage.removeItem("acct_" + acct_id + "_at") + localStorage.removeItem("domain_" + acct_id) + location.href = "index.html" + todc() } \ No newline at end of file diff --git a/app/js/tl/date.js b/app/js/tl/date.js index cbc3a329..054aeaba 100644 --- a/app/js/tl/date.js +++ b/app/js/tl/date.js @@ -1,95 +1,95 @@ //日付パーサー function date(str, datetype) { if (datetype == "relative") { - return ''; + return '' } else { - var date = new Date(str); + var date = new Date(str) if (datetype == "unix") { - var unixm = date.getTime(); - return Math.floor(unixm / 1000); + var unixm = date.getTime() + return Math.floor(unixm / 1000) } - var now = new Date(); - var month = date.getMonth() + 1; + var now = new Date() + var month = date.getMonth() + 1 if (date.getMinutes() < 10) { - var min = "0" + date.getMinutes(); + var min = "0" + date.getMinutes() } else { - var min = date.getMinutes(); + var min = date.getMinutes() } - var sec = null; + var sec = null if (date.getSeconds() < 10) { - sec = "0" + date.getSeconds(); + sec = "0" + date.getSeconds() } else { - sec = date.getSeconds(); + sec = date.getSeconds() } if (datetype == "full") { var ret = date.getFullYear() + "/" + month + "/" + date.getDate() + "/ " + - date.getHours() + ":" + min + ":" + sec; + date.getHours() + ":" + min + ":" + sec } if (date.getFullYear() == now.getFullYear()) { if (date.getMonth() == now.getMonth()) { if (date.getDate() == now.getDate()) { if (datetype == "medium") { - var ret = ''; + var ret = '' } else { - var ret = date.getHours() + ":" + min + ":" + sec; + var ret = date.getHours() + ":" + min + ":" + sec } } else { var ret = month + "/" + date.getDate() + " " + date.getHours() + ":" + - min + ":" + sec; + min + ":" + sec } } else { var ret = month + "/" + date.getDate() + " " + date.getHours() + ":" + min + - ":" + sec; + ":" + sec } } else { var ret = date.getFullYear() + "/" + month + "/" + date.getDate() + " " + - date.getHours() + ":" + min + ":" + sec; + date.getHours() + ":" + min + ":" + sec } if (datetype == "double") { - return '/' + ret; + return '/' + ret } else { - return ret; + return ret } } } //特殊フォーマット(インスタンス情報で利用) function crat(str) { - var date = new Date(str); - var mnt = null; + var date = new Date(str) + var mnt = null if (date.getMonth() < 9) { - mnt = "0" + (date.getMonth() + 1); + mnt = "0" + (date.getMonth() + 1) } else { - mnt = date.getMonth() + 1; + mnt = date.getMonth() + 1 } if (date.getDate() < 10) { - var dat = "0" + date.getDate(); + var dat = "0" + date.getDate() } else { - var dat = date.getDate(); + var dat = date.getDate() } if (date.getHours() < 10) { - var hrs = "0" + date.getHours(); + var hrs = "0" + date.getHours() } else { - var hrs = date.getHours(); + var hrs = date.getHours() } if (date.getMinutes() < 10) { - var mns = "0" + date.getMinutes(); + var mns = "0" + date.getMinutes() } else { - var mns = date.getMinutes(); + var mns = date.getMinutes() } if (date.getSeconds() < 10) { - var sec = "0" + date.getSeconds(); + var sec = "0" + date.getSeconds() } else { - var sec = date.getSeconds(); + var sec = date.getSeconds() } - format_str = 'YYYY-MM-DD hh:mm:ss'; - format_str = format_str.replace(/YYYY/g, date.getFullYear()); - format_str = format_str.replace(/MM/g, mnt); - format_str = format_str.replace(/DD/g, dat); - format_str = format_str.replace(/hh/g, hrs); - format_str = format_str.replace(/mm/g, mns); - format_str = format_str.replace(/ss/g, sec); + format_str = 'YYYY-MM-DD hh:mm:ss' + format_str = format_str.replace(/YYYY/g, date.getFullYear()) + format_str = format_str.replace(/MM/g, mnt) + format_str = format_str.replace(/DD/g, dat) + format_str = format_str.replace(/hh/g, hrs) + format_str = format_str.replace(/mm/g, mns) + format_str = format_str.replace(/ss/g, sec) - return format_str; + return format_str } diff --git a/app/js/tl/directory.js b/app/js/tl/directory.js index e7d81d50..5c7c318a 100644 --- a/app/js/tl/directory.js +++ b/app/js/tl/directory.js @@ -1,49 +1,49 @@ //ディレクトリ //ディレクトリトグル function dirMenu() { - $("#dir-contents").html(""); - directory(); - $("#left-menu a").removeClass("active"); - $("#dirMenu").addClass("active"); - $(".menu-content").addClass("hide"); - $("#dir-box").removeClass("hide"); + $("#dir-contents").html("") + directory() + $("#left-menu a").removeClass("active") + $("#dirMenu").addClass("active") + $(".menu-content").addClass("hide") + $("#dir-box").removeClass("hide") } function dirselCk() { - var acct = $("#dir-acct-sel").val(); + var acct = $("#dir-acct-sel").val() if (acct == "noauth") { - $("#dirNoAuth").removeClass("hide"); + $("#dirNoAuth").removeClass("hide") } else { - $("#dirNoAuth").addClass("hide"); - directory(); + $("#dirNoAuth").addClass("hide") + directory() } } function directory(isMore) { - var order = $("[name=sort]:checked").val(); + var order = $("[name=sort]:checked").val() if (!order) { - order = "active"; + order = "active" } - var local_only = $("#local_only:checked").val(); + var local_only = $("#local_only:checked").val() if (local_only) { - local_only = "true"; + local_only = "true" } else { - local_only = "false"; + local_only = "false" } - var acct_id = $("#dir-acct-sel").val(); + var acct_id = $("#dir-acct-sel").val() if (acct_id == "noauth") { - var domain = $("#dirNoAuth-url").val(); - var at = ""; + var domain = $("#dirNoAuth-url").val() + var at = "" } else { - var domain = localStorage.getItem("domain_" + acct_id); - var at = localStorage.getItem("acct_" + acct_id + "_at"); + var domain = localStorage.getItem("domain_" + acct_id) + var at = localStorage.getItem("acct_" + acct_id + "_at") } if (isMore) { - var addOffset = $("#dir-contents .cvo").length; + var addOffset = $("#dir-contents .cvo").length } else { - var addOffset = 0; - $("#dir-contents").html(""); + var addOffset = 0 + $("#dir-contents").html("") } - var start = "https://" + domain + "/api/v1/directory?order=" + order + "&local=" + local_only + "&offset=" + addOffset; - console.log(start); + var start = "https://" + domain + "/api/v1/directory?order=" + order + "&local=" + local_only + "&offset=" + addOffset + console.log(start) fetch(start, { method: "GET", headers: { @@ -54,23 +54,23 @@ function directory(isMore) { .then(function(response) { if (!response.ok) { response.text().then(function(text) { - setLog(response.url, response.status, text); - }); + setLog(response.url, response.status, text) + }) } - return response.json(); + return response.json() }) .catch(function(error) { - setLog(start, "JSON", error); - console.error(error); + setLog(start, "JSON", error) + console.error(error) }) .then(function(json) { if (json) { - $("#moreDir").removeClass("disabled"); - var html = userparse(json, null, acct_id, "dir", null); - $("#dir-contents").append(html); - jQuery("time.timeago").timeago(); + $("#moreDir").removeClass("disabled") + var html = userparse(json, null, acct_id, "dir", null) + $("#dir-contents").append(html) + jQuery("time.timeago").timeago() } else { - $("#moreDir").addClass("disabled"); + $("#moreDir").addClass("disabled") } - }); + }) } diff --git a/app/js/tl/dm.js b/app/js/tl/dm.js index 8c1f7078..3c5d77d2 100644 --- a/app/js/tl/dm.js +++ b/app/js/tl/dm.js @@ -1,8 +1,8 @@ //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"; + 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: { @@ -13,38 +13,38 @@ function dm(acct_id, tlid, type, delc, voice) { .then(function(response) { if (!response.ok) { response.text().then(function(text) { - setLog(response.url, response.status, text); - }); + setLog(response.url, response.status, text) + }) } - return response.json(); + return response.json() }) .catch(function(error) { - todo(error); - setLog(start, "JSON", error); - console.error(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(); + 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); - }); + $(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 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"; + .attr("unique-id") + var start = "https://" + domain + "/api/v1/conversations?max_id=" + sid + var type = "dm" fetch(start, { method: "GET", headers: { @@ -55,444 +55,444 @@ function dmmore(tlid) { .then(function(response) { if (!response.ok) { response.text().then(function(text) { - setLog(response.url, response.status, text); - }); + setLog(response.url, response.status, text) + }) } - return response.json(); + return response.json() }) .catch(function(error) { - todo(error); - setLog(start, "JSON", error); - console.error(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; - }); + 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 = ""; + var templete = "" if (obj[0]) { - localStorage.setItem("lastunix_" + tlid, date(obj[0].created_at, "unix")); + 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"; + var actb = localStorage.getItem("action_btns") + var actb = "re,rt,fav,qt,del,pin,red" if (actb) { - var actb = actb.split(","); - var disp = {}; + var actb = actb.split(",") + var disp = {} for (var k = 0; k < actb.length; k++) { if (k < 4) { - var tp = "type-a"; + var tp = "type-a" } else { - var tp = "type-b"; + var tp = "type-b" } - disp[actb[k]] = tp; + 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 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"); + var locale = localStorage.getItem("locale") if (locale == "yes") { - var locale = false; + var locale = false } //ネイティブ通知 - var native = localStorage.getItem("nativenotf"); + var native = localStorage.getItem("nativenotf") if (!native) { - native = "yes"; + native = "yes" } //クライアント強調 - var emp = localStorage.getItem("client_emp"); + var emp = localStorage.getItem("client_emp") if (emp) { - var emp = JSON.parse(emp); + var emp = JSON.parse(emp) } //クライアントミュート - var mute = localStorage.getItem("client_mute"); + var mute = localStorage.getItem("client_mute") if (mute) { - var mute = JSON.parse(mute); + var mute = JSON.parse(mute) } //ユーザー強調 - var useremp = localStorage.getItem("user_emp"); + var useremp = localStorage.getItem("user_emp") if (useremp) { - var useremp = JSON.parse(useremp); + var useremp = JSON.parse(useremp) } //ワード強調 - var wordemp = localStorage.getItem("word_emp"); + var wordemp = localStorage.getItem("word_emp") if (wordemp) { - var wordemp = JSON.parse(wordemp); + var wordemp = JSON.parse(wordemp) } //ワードミュート - var wordmute = localStorage.getItem("word_mute"); + var wordmute = localStorage.getItem("word_mute") if (wordmute) { - var wordmute = JSON.parse(wordmute); - wordmute = wordmute.concat(mutefilter); + var wordmute = JSON.parse(wordmute) + wordmute = wordmute.concat(mutefilter) } else { - wordmute = mutefilter; + wordmute = mutefilter } //Ticker - var tickerck = localStorage.getItem("ticker_ok"); + var tickerck = localStorage.getItem("ticker_ok") if (tickerck) { - var ticker = true; + var ticker = true } else { - var ticker = false; + var ticker = false } //Cards - var card = localStorage.getItem("card_" + tlid); + var card = localStorage.getItem("card_" + tlid) if (!sent) { - var sent = 500; + var sent = 500 } if (!ltr) { - var ltr = 500; + var ltr = 500 } if (!nsfwtype || nsfwtype == "yes") { - var nsfw = "ok"; + var nsfw = "ok" } else { - var nsfw; + var nsfw } - var cwtype = localStorage.getItem("cw"); + var cwtype = localStorage.getItem("cw") if (!cwtype || cwtype == "yes") { - var cw = "ok"; + var cw = "ok" } else { - var cw; + var cw } if (!datetype) { - datetype = "absolute"; + datetype = "absolute" } if (!gif) { - var gif = "yes"; + var gif = "yes" } if (!imh) { - var imh = "200"; + var imh = "200" } if (!emp) { - var emp = []; + var emp = [] } if (!mute) { - var mute = []; + var mute = [] } if (!useremp) { - var useremp = []; + var useremp = [] } if (!wordemp) { - var wordemp = []; + var wordemp = [] } if (!wordmute) { - var wordmute = []; + var wordmute = [] } //via通知 - var viashow = localStorage.getItem("viashow"); + var viashow = localStorage.getItem("viashow") if (!viashow) { - viashow = "via-hide"; + viashow = "via-hide" } if (viashow == "hide") { - viashow = "via-hide"; + viashow = "via-hide" } //認証なしTL if (mix == "noauth") { - var noauth = "hide"; - var antinoauth = ""; + var noauth = "hide" + var antinoauth = "" } else { - var noauth = ""; - var antinoauth = "hide"; + var noauth = "" + var antinoauth = "hide" } //マウスオーバーのみ - var mouseover = localStorage.getItem("mouseover"); + var mouseover = localStorage.getItem("mouseover") if (!mouseover) { - mouseover = ""; + mouseover = "" } else if (mouseover == "yes" || mouseover == "click") { - mouseover = "hide"; + mouseover = "hide" } else if (mouseover == "no") { - mouseover = ""; + mouseover = "" } - var local = []; - var times = []; + 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); + 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]; + var actemojick = toot.account.emojis[0] } else { - var actemojick = false; + 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 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 = ""; + 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; + var fullname = toot.account.acct } else { - var domain = localStorage.getItem("domain_" + acct_id); - var fullname = toot.account.acct + "@" + domain; + 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]; + var user = useremp[key10] if (user == fullname) { - boostback = "emphasized"; + boostback = "emphasized" } - }); + }) } - var id = toot.id; - var home = ""; + var id = toot.id + var home = "" if (toot.account.locked) { - var locked = ' '; + var locked = ' ' } else { - var locked = ""; + var locked = "" } if (!toot.application) { - var via = ""; - viashow = "hide"; + var via = "" + viashow = "hide" } else { - var via = escapeHTML(toot.application.name); + var via = escapeHTML(toot.application.name) //強調チェック Object.keys(emp).forEach(function(key6) { - var cli = emp[key6]; + var cli = emp[key6] if (cli == via) { - boostback = "emphasized"; + boostback = "emphasized" } - }); + }) //ミュートチェック Object.keys(mute).forEach(function(key7) { - var cli = mute[key7]; + var cli = mute[key7] if (cli == via) { - boostback = "hide"; + boostback = "hide" } - }); + }) } if (mix == "pinned") { - boostback = "emphasized"; + 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 + "
"; + 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; + 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; + var ct = ct1 } else { - var ct = ct2; + 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 + "
"; + 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 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;\/?:\@&=+\$,%#]+)?/); + .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/) if (urls) { - var analyze = "' + lang.lang_parse_url + "
"; + var analyze = "' + lang.lang_parse_url + "
" } else { - var analyze = ""; + var analyze = "" } - var viewer = ""; - var hasmedia = ""; - var youtube = ""; + var viewer = "" + var hasmedia = "" + var youtube = "" if (toot.emojis) { - var emojick = toot.emojis[0]; + var emojick = toot.emojis[0] } else { - var emojick = false; + 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); - }); + 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]; + var nicoemojick = toot.profile_emojis[0] } else { - var nicoemojick = false; + 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); - }); + 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); + content = twemoji.parse(content) if (dis_name) { - dis_name = twemoji.parse(dis_name); + dis_name = twemoji.parse(dis_name) } if (spoil) { - spoil = twemoji.parse(spoil); + spoil = twemoji.parse(spoil) } - var mediack = toot.media_attachments[0]; + var mediack = toot.media_attachments[0] //メディアがあれば - var media_ids = ""; + var media_ids = "" if (mediack) { - hasmedia = "hasmedia"; - var cwdt = 100 / toot.media_attachments.length; + 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; + 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"; + var sense = "sensitive" } else { - var sense = ""; + var sense = "" } - viewer = viewer + "'; - }); - media_ids = media_ids.slice(0, -1); + viewer = viewer + "' + }) + media_ids = media_ids.slice(0, -1) } else { - viewer = ""; - hasmedia = "nomedia"; + viewer = "" + hasmedia = "nomedia" } - var menck = toot.mentions[0]; - var mentions = ""; + var menck = toot.mentions[0] + var mentions = "" //メンションであれば if (menck) { - mentions = ""; + mentions = "" Object.keys(toot.mentions).forEach(function(key3) { - var mention = toot.mentions[key3]; - mentions = mentions + "@' + mention.acct + " "; - }); - mentions = '
' + mentions + "
"; + var mention = toot.mentions[key3] + mentions = mentions + "@' + mention.acct + " " + }) + mentions = '
' + mentions + "
" } - var tagck = toot.tags[0]; - var tags = ""; + 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 + "
"; + var tag = toot.tags[key4] + tags = tags + '#' + tag.name + ":TL Toot ' + "Pin ' + }) + tags = '
' + tags + "
" } //アニメ再生 if (gif == "yes") { - var avatar = toot.account.avatar; + var avatar = toot.account.avatar } else { - var avatar = toot.account.avatar_static; + var avatar = toot.account.avatar_static } //ワードミュート if (wordmute) { Object.keys(wordmute).forEach(function(key8) { - var worde = wordmute[key8]; + var worde = wordmute[key8] if (worde) { if (worde.tag) { - var word = worde.tag; + var word = worde.tag } else { - var word = worde; + var word = worde } - var regExp = new RegExp(word, "g"); + var regExp = new RegExp(word, "g") if ($.strip_tags(content).match(regExp)) { - boostback = "hide by_filter"; + boostback = "hide by_filter" } } - }); + }) } //ワード強調 if (wordemp) { Object.keys(wordemp).forEach(function(key9) { - var word = wordemp[key9]; + var word = wordemp[key9] if (word) { - var word = word.tag; - var regExp = new RegExp(word, "g"); - content = content.replace(regExp, '' + escapeHTML(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
'; + var trans = '
g_translate
' } else { - var trans = ""; + var trans = "" } if (toot.favourited) { - var if_fav = " yellow-text"; - var fav_app = "faved"; + var if_fav = " yellow-text" + var fav_app = "faved" } else { - var if_fav = ""; - var fav_app = ""; + var if_fav = "" + var fav_app = "" } //Cards if (!card && toot.card) { - var cards = toot.card; + var cards = toot.card if (cards.provider_name == "Twitter") { if (cards.image) { - var twiImg = '
'; + var twiImg = '
' } else { - var twiImg = ""; + var twiImg = "" } - analyze = '
' + escapeHTML(cards.author_name) + "
" + escapeHTML(cards.description) + 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) + "
"; + analyze = 'URL' + lang.lang_cards_check + ":
Title:" + escapeHTML(cards.title) + "
" + escapeHTML(cards.description) + "
" } if (cards.html) { - analyze = cards.html + 'picture_in_picture_alt'; + analyze = cards.html + 'picture_in_picture_alt' } } //Ticker - var tickerdom = ""; + var tickerdom = "" if (ticker) { - var tickerdata = localStorage.getItem("ticker"); + var tickerdata = localStorage.getItem("ticker") if (tickerdata) { - var tickerdata = JSON.parse(tickerdata); + var tickerdata = JSON.parse(tickerdata) - var thisdomain = toot.account.acct.split("@"); + var thisdomain = toot.account.acct.split("@") if (thisdomain.length > 1) { - thisdomain = thisdomain[1]; + thisdomain = thisdomain[1] } for (var i = 0; i < tickerdata.length; i++) { - var value = tickerdata[i]; + var value = tickerdata[i] if (value.domain == thisdomain) { - var tickerdom = '
' + escapeHTML(value.name) + "
"; - break; + 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; + 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 } diff --git a/app/js/tl/misskeyparse.js b/app/js/tl/misskeyparse.js index 32e95077..b3054db4 100644 --- a/app/js/tl/misskeyparse.js +++ b/app/js/tl/misskeyparse.js @@ -1,205 +1,205 @@ function escapeHTMLtemp(str) { if (!str) { - return ""; + return "" } return str.replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') - .replace(/'/g, '''); + .replace(/'/g, ''') } $.strip_tagstemp = function (str, allowed) { if (!str) { - return ""; + return "" } allowed = (((allowed || '') + '').toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []) - .join(''); + .join('') var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>?/gi, - commentsAndPhpTags = /|<\?(?:php)?[\s\S]*?\?>/gi; + commentsAndPhpTags = /|<\?(?:php)?[\s\S]*?\?>/gi return str.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) { - return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''; - }); -}; + 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'; + 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 = {}; + var actb = actb.split(',') + var disp = {} for (var k = 0; k < actb.length; k++) { if (k < 4) { - var tp = "type-a"; + var tp = "type-a" } else { - var tp = "type-b"; + var tp = "type-b" } - disp[actb[k]] = tp; + 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 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"); + var native = localStorage.getItem("nativenotf") if (!native) { - native = "yes"; + native = "yes" } //クライアント強調 - var empCli = localStorage.getItem("client_emp"); + var empCli = localStorage.getItem("client_emp") if (empCli) { - var empCli = JSON.parse(empCli); + var empCli = JSON.parse(empCli) } else { - var empCli = []; + var empCli = [] } //クライアントミュート - var muteCli = localStorage.getItem("client_mute"); + var muteCli = localStorage.getItem("client_mute") if (muteCli) { - var muteCli = JSON.parse(muteCli); + var muteCli = JSON.parse(muteCli) } else { - var muteCli = []; + var muteCli = [] } //ユーザー強調 - var useremp = localStorage.getItem("user_emp"); + var useremp = localStorage.getItem("user_emp") if (useremp) { - var useremp = JSON.parse(useremp); + var useremp = JSON.parse(useremp) } //ワード強調 - var wordempList = localStorage.getItem("word_emp"); + var wordempList = localStorage.getItem("word_emp") if (wordempList) { - var wordempList = JSON.parse(wordempList); + var wordempList = JSON.parse(wordempList) } //ワードミュート - var wordmuteList = localStorage.getItem("word_mute"); + var wordmuteList = localStorage.getItem("word_mute") if (wordmuteList) { - var wordmuteList = JSON.parse(wordmuteList); + var wordmuteList = JSON.parse(wordmuteList) if (wordmuteList) { - wordmuteList = wordmuteList.concat(mutefilter); + wordmuteList = wordmuteList.concat(mutefilter) } } else { - wordmuteList = mutefilter; + wordmuteList = mutefilter } //Ticker - var tickerck = localStorage.getItem("ticker_ok"); + var tickerck = localStorage.getItem("ticker_ok") if (tickerck) { - var ticker = true; + var ticker = true } else { - var ticker = false; + var ticker = false } if (!sent) { - var sent = 500; + var sent = 500 } if (!ltr) { - var ltr = 500; + var ltr = 500 } if (!nsfwtype || nsfwtype == "yes") { - var nsfw = "ok"; + var nsfw = "ok" } else { - var nsfw; + var nsfw } - var cwtype = localStorage.getItem("cw"); + var cwtype = localStorage.getItem("cw") if (!cwtype || cwtype == "yes") { - var cw = "ok"; + var cw = "ok" } else { - var cw; + var cw } if (!datetype) { - datetype = "absolute"; + datetype = "absolute" } if (!gif) { - var gif = "yes"; + var gif = "yes" } if (!imh) { - var imh = "200"; + var imh = "200" } if (!emp) { - var emp = []; + var emp = [] } if (!mute) { - var mute = []; + var mute = [] } if (!useremp) { - var useremp = []; + var useremp = [] } if (!wordemp) { - var wordemp = []; + var wordemp = [] } if (!wordmute) { - var wordmute = []; + var wordmute = [] } //via通知 - var viashow = localStorage.getItem("viashow"); + var viashow = localStorage.getItem("viashow") if (!viashow) { - viashow = "via-hide"; + viashow = "via-hide" } if (viashow == "hide") { - viashow = "via-hide"; + viashow = "via-hide" } //認証なしTL if (mix == "noauth") { - var noauth = "hide"; - var antinoauth = ""; + var noauth = "hide" + var antinoauth = "" } else { - var noauth = ""; - var antinoauth = "hide"; + var noauth = "" + var antinoauth = "hide" } //マウスオーバーのみ - var mouseover = localStorage.getItem("mouseover"); + var mouseover = localStorage.getItem("mouseover") if (!mouseover) { - mouseover = ""; + mouseover = "" } else if (mouseover == "yes" || mouseover == "click") { - mouseover = "hide"; + mouseover = "hide" } else if (mouseover == "no") { - mouseover = ""; + mouseover = "" } - var local = []; - var times = []; + var local = [] + var times = [] Object.keys(obj).forEach(function (key) { - var toot = obj[key]; - var dis_name = toot.user.name; + var toot = obj[key] + var dis_name = toot.user.name if (dis_name) { - dis_name = escapeHTMLtemp(dis_name); + dis_name = escapeHTMLtemp(dis_name) } else { - disname = ""; + 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 = toot.user.emojis[key5] + var shortcode = emoji.name var emoji_url = ' :' + shortcode + ': '; - var regExp = new RegExp(":" + shortcode + ":", "g"); - dis_name = dis_name.replace(regExp, emoji_url); - }); + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">' + var regExp = new RegExp(":" + shortcode + ":", "g") + dis_name = dis_name.replace(regExp, emoji_url) + }) } if (mix == "notf") { if (gif == "yes") { - noticeavatar = toot.user.avatarUrl; + noticeavatar = toot.user.avatarUrl } else { - noticeavatar = toot.user.avatarUrl; + noticeavatar = toot.user.avatarUrl } noticeavatar = '' + ''; + '">' if (toot.type == "reply") { - var what = lang.lang_parse_mentioned; - var icon = ''; - noticeavatar = ""; + var what = lang.lang_parse_mentioned + var icon = '' + noticeavatar = "" } else if (toot.type == "renote") { - var what = lang.lang_misskeyparse_renoted; - var icon = ''; + var what = lang.lang_misskeyparse_renoted + var icon = '' } else if (toot.type == "quote") { - var what = lang.lang_misskeyparse_quoted; - var icon = ''; + var what = lang.lang_misskeyparse_quoted + var icon = '' } else if (toot.type == "reaction") { - var what = lang.lang_misskeyparse_reacted; + var what = lang.lang_misskeyparse_reacted var reactions = { "like": "👍", "love": "💓", @@ -211,24 +211,24 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { "confused": "😥", "rip": "😇" } - var icon = reactions[toot.reaction]; - var emojisData = JSON.parse(localStorage.getItem("emoji_" + acct_id)); + var icon = reactions[toot.reaction] + var emojisData = JSON.parse(localStorage.getItem("emoji_" + acct_id)) if (!icon) { if (emojisData) { - var num = emojisData.length; - var ehtml = ""; + var num = emojisData.length + var ehtml = "" for (i = 0; i < num; i++) { - var emoji = emojisData[i]; + var emoji = emojisData[i] if (":" + emoji.shortcode + ":" == toot.reaction) { if (emoji) { - icon = ''; + icon = '' } } } } } } else { - var icon = 'info'; + var icon = 'info' } var noticetext = '' + date(toot.createdAt, @@ -236,92 +236,92 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { '' + icon + '' + dis_name + "(@" + toot.user.username + - ")"; - var notice = noticetext; - var memory = localStorage.getItem("notice-mem"); + ")" + 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)); + $(".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); + $(".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)); + $(".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); + var domain = localStorage.getItem("domain_" + acct_id) if (popup > 0) { M.toast({ html: "[" + domain + "]" + escapeHTMLtemp(toot.user.name) + what, displayLength: popup * 1000 }) } if (native == "yes") { - var os = localStorage.getItem("platform"); + 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); + } + var n = new Notification('TheDesk:' + domain, options) } if (localStorage.getItem("hasNotfC_" + acct_id) != "true") { - $(".notf-icon_" + acct_id).addClass("red-text"); + $(".notf-icon_" + acct_id).addClass("red-text") } - localStorage.setItem("notice-mem", noticetext); - noticetext = ""; + 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); + var if_notf = 'data-notfIndv="' + acct_id + "_" + toot.id + '"' + var toot = toot.note + var dis_name = escapeHTML(toot.user.name) } else { - var if_notf = ""; + var if_notf = "" if (toot.renote) { - var rebtxt = lang.lang_parse_btedsimple; - var rticon = "fa-retweet light-blue-text"; + 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; + ")
" + var boostback = "shared" + var uniqueid = toot.id if (!toot.text) { - var toot = toot.renote; + var toot = toot.renote } - var dis_name = escapeHTML(toot.user.name); - var uniqueid = toot.id; + var dis_name = escapeHTML(toot.user.name) + var uniqueid = toot.id var actemojick = false } else { - var uniqueid = toot.id; - var notice = ""; - var boostback = ""; + var uniqueid = toot.id + var notice = "" + var boostback = "" //ユーザー強調 if (toot.user.host) { - var fullname = toot.user.username + "@" + 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; + 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]; + var user = useremp[key10] if (user == fullname) { - boostback = "emphasized"; + boostback = "emphasized" } - }); + }) } } } - var id = toot.id; + var id = toot.id if (mix == "home") { var home = "" - var divider = '
'; + var divider = '
' } else { - var home = ""; - var divider = '
'; + var home = "" + var divider = '
' } /* if (toot.account.locked) { @@ -332,77 +332,77 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { */ if (!toot.app) { if (toot.viaMobile) { - var via = 'Mobile'; + var via = 'Mobile' } else { - var via = ''; - viashow = "via-hide"; + var via = '' + viashow = "via-hide" } } else { - var via = escapeHTML(toot.app.name); + var via = escapeHTML(toot.app.name) if (!toot.app.name) { - viashow = "via-hide"; + viashow = "via-hide" } //強調チェック Object.keys(empCli).forEach(function (key6) { - var empCliList = empCli[key6]; + var empCliList = empCli[key6] if (empCliList == via) { - boostback = "emphasized"; + boostback = "emphasized" } - }); + }) //ミュートチェック Object.keys(muteCli).forEach(function (key7) { - var muteCliList = muteCli[key7]; + var muteCliList = muteCli[key7] if (muteCliList == via) { - boostback = "hide"; + 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 + '
'; + 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; } + 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 + '
'; + '' + lang.lang_parse_autofold + '' + var spoiler = "cw cw_hide" + var spoiler_show = '' + lang.lang_parse_more + '
' } else { - var content = escapeHTMLtemp(toot.text); + var content = escapeHTMLtemp(toot.text) if (toot.cw) { - var spoil = escapeHTMLtemp(toot.cw); + var spoil = escapeHTMLtemp(toot.cw) } else { - var spoil = ""; + var spoil = "" } - var spoiler = ""; - var spoiler_show = ""; + var spoiler = "" + var spoiler_show = "" } } - var analyze = ''; + 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 + '
'; + ',\'' + id + '\')" class="add-show pointer">' + lang.lang_parse_url + '
' } else { - var analyze = ''; + var analyze = '' } - var viewer = "
"; - var hasmedia = ""; - var youtube = ""; + var viewer = "
" + var hasmedia = "" + var youtube = "" if (toot.emojis) { - var emojick = toot.emojis[0]; + var emojick = toot.emojis[0] } else { - var emojick = false; + var emojick = false } //デフォ絵文字 if (content) { @@ -415,7 +415,7 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { content = content.replace(/\*\*\*([^*]+)\*\*\*/gi, '$1') content = content.replace(/\*\*([^*]+)\*\*/gi, '$1') content = content.replace(/^(.+)\s(検索|search)$/gmi, '
search
') - content = content.replace(/\[(.+)\]\($1'); + content = content.replace(/\[(.+)\]\($1') content = content.replace(/<center>/gi, '
') content = content.replace(/<\/center>/gi, '
') content = content.replace(/<flip>(.+)<\/flip>/gi, '$1') @@ -424,58 +424,58 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { content = content.replace(/<spin>(.+)<\/spin>/gi, '$1') content = content.replace(/\*\*(.+)\*\*/gi, '$1') content = content.replace(/<jump>(.+)<\/jump>/gi, '$1') - content = twemoji.parse(content); + content = twemoji.parse(content) } else { - content = ""; + content = "" } //絵文字があれば if (emojick) { Object.keys(toot.emojis).forEach(function (key5) { - var emoji = toot.emojis[key5]; - var shortcode = emoji.name; + var emoji = toot.emojis[key5] + var shortcode = emoji.name var emoji_url = ' :' + shortcode + ': '; - var regExp = new RegExp(":" + shortcode + ":", "g"); - content = content.replace(regExp, emoji_url); - spoil = spoil.replace(regExp, emoji_url); - }); + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">' + 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); + dis_name = twemoji.parse(dis_name) } else { - dis_name = ""; + dis_name = "" } if (spoil) { - spoil = twemoji.parse(spoil); + spoil = twemoji.parse(spoil) } if (noticetext) { - noticetext = twemoji.parse(noticetext); + noticetext = twemoji.parse(noticetext) } if (notice) { - notice = twemoji.parse(notice); + notice = twemoji.parse(notice) } if (toot.files) { - var mediack = toot.files[0]; - var useparam = "files"; + var mediack = toot.files[0] + var useparam = "files" } else { if (toot.media) { - var mediack = toot.media[0]; - var useparam = "media"; + var mediack = toot.media[0] + var useparam = "media" } else { - var mediack = false; + var mediack = false } } //メディアがあれば - var media_ids = ""; + var media_ids = "" if (mediack) { - hasmedia = "hasmedia"; - var cwdt = 100 / toot[useparam].length; + 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; + 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 { @@ -486,85 +486,85 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) { acct_id + ')" id="' + id + '-image-' + key2 + '" data-url="' + url + '" data-type="video" class="img-parsed">'; + ' toot-img pointer" style="max-width:100%;">' } else if (media.type.indexOf("audio") !== -1) { viewer = viewer + '