2018-01-28 23:22:43 +11:00
|
|
|
//トゥートの詳細
|
2022-10-10 19:19:30 +11:00
|
|
|
async function details(id, acct_id, tlid, mode) {
|
2019-11-09 00:52:54 +11:00
|
|
|
if (mode == 'dm') {
|
|
|
|
$('.dm-hide').hide()
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
$('.dm-hide').show()
|
2019-03-16 21:06:03 +11:00
|
|
|
}
|
2021-04-01 14:47:13 +11:00
|
|
|
const context = localStorage.getItem('moreContext')
|
2022-10-10 19:19:30 +11:00
|
|
|
if (context != 'yes') {
|
2021-04-01 14:47:13 +11:00
|
|
|
$('.contextTool').hide()
|
|
|
|
} else {
|
|
|
|
$('.contextTool').show()
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('.toot-reset').html('<span class="no-data">' + lang.lang_details_nodata + '</span>')
|
|
|
|
var html = $('#timeline_' + tlid + ' [toot-id=' + id + ']').html()
|
|
|
|
$('#toot-this').html(html)
|
|
|
|
$('#tootmodal').modal('open')
|
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var start = 'https://' + domain + '/api/notes/show'
|
2019-05-19 17:39:30 +10:00
|
|
|
var i = {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'POST',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2018-07-30 21:03:49 +10:00
|
|
|
},
|
2019-05-19 17:39:30 +10:00
|
|
|
body: JSON.stringify({
|
|
|
|
i: at,
|
|
|
|
noteId: id
|
2018-07-30 21:03:49 +10:00
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
var start = 'https://' + domain + '/api/v1/statuses/' + id
|
2019-05-19 17:39:30 +10:00
|
|
|
var i = {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
}
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2022-10-10 19:19:30 +11:00
|
|
|
try {
|
|
|
|
const response = await fetch(start, i)
|
|
|
|
if (!response.ok) {
|
|
|
|
response.text().then(function (text) {
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
const json = await response.json()
|
|
|
|
console.log(['Toot data:', json])
|
|
|
|
if (!$('#timeline_' + tlid + ' #pub_' + id).length) {
|
2022-11-19 13:29:02 +11:00
|
|
|
var mute = getFilterTypeByAcct(acct_id, 'thread')
|
2022-10-10 19:19:30 +11:00
|
|
|
var html = parse([json], '', acct_id, '', '', mute)
|
|
|
|
$('#toot-this').html(html)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
}
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var url = 'https://' + domain + '/notes/' + json.id
|
|
|
|
var scn = json.user.username
|
|
|
|
if (!json.user.host) {
|
|
|
|
var local = true
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2022-10-10 19:19:30 +11:00
|
|
|
var local = false
|
|
|
|
scn = scn + '@' + host
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2022-10-10 19:19:30 +11:00
|
|
|
var rep = ''
|
|
|
|
var uid = json.user.id
|
|
|
|
if (json._replyIds) {
|
|
|
|
replyTL(json._replyIds[0], acct_id)
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2022-10-10 19:19:30 +11:00
|
|
|
} else {
|
|
|
|
var url = json.url
|
|
|
|
if (json.account.acct == json.account.username) {
|
|
|
|
var local = true
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2022-10-10 19:19:30 +11:00
|
|
|
var local = false
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2022-10-10 19:19:30 +11:00
|
|
|
var scn = json.account.acct
|
|
|
|
var uid = json.account.id
|
|
|
|
if (json['in_reply_to_id']) {
|
|
|
|
replyTL(json['in_reply_to_id'], acct_id)
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2022-10-10 19:19:30 +11:00
|
|
|
}
|
|
|
|
$('#toot-this .fav_ct').text(json.favourites_count)
|
|
|
|
$('#toot-this .rt_ct').text(json.reblogs_count)
|
|
|
|
$('#tootmodal').attr('data-url', url)
|
|
|
|
$('#tootmodal').attr('data-id', json.id)
|
|
|
|
$('#tootmodal').attr('data-acct', acct_id)
|
|
|
|
if (local) {
|
|
|
|
$('#tootmodal').attr('data-user', scn + '@' + domain)
|
|
|
|
} else {
|
|
|
|
$('#tootmodal').attr('data-user', scn)
|
|
|
|
}
|
|
|
|
getContext(id, acct_id)
|
|
|
|
var dom = null
|
|
|
|
if (!local) {
|
|
|
|
dom = scn.replace(/.+@/g, '')
|
|
|
|
} else {
|
|
|
|
dom = domain
|
|
|
|
}
|
|
|
|
beforeToot(id, acct_id, dom)
|
|
|
|
userToot(id, acct_id, uid)
|
|
|
|
afterToot(id, acct_id, dom)
|
|
|
|
afterUserToot(id, acct_id, uid)
|
|
|
|
afterFTLToot(id, acct_id, dom)
|
|
|
|
faved(id, acct_id)
|
|
|
|
rted(id, acct_id)
|
|
|
|
if (json.edited_at) {
|
|
|
|
$('.edited-hide').show()
|
|
|
|
try {
|
|
|
|
const history = await (await fetch(`https://${domain}/api/v1/statuses/${id}/history`, i)).json()
|
|
|
|
const temp = parse(history, 'noauth', acct_id)
|
|
|
|
console.log(temp)
|
|
|
|
$('#toot-edit').html(temp)
|
|
|
|
} catch(e) { console.error(e) }
|
|
|
|
} else {
|
|
|
|
$('#toot-edit').html('')
|
|
|
|
$('.edited-hide').hide()
|
|
|
|
}
|
|
|
|
if ($('#toot-this div').hasClass('cvo')) {
|
|
|
|
$('#toot-this').removeClass('cvo')
|
|
|
|
} else {
|
|
|
|
if (!$('#toot-this .cvo').hasClass('cvo')) {
|
|
|
|
$('#toot-this').addClass('cvo')
|
2019-07-13 01:01:09 +10:00
|
|
|
}
|
2022-10-10 19:19:30 +11:00
|
|
|
}
|
|
|
|
if (!$('#activator').hasClass('active')) {
|
|
|
|
$('#det-col').collapsible('open', 4)
|
|
|
|
}
|
2022-11-19 13:29:02 +11:00
|
|
|
} catch (error) {
|
2022-10-10 19:19:30 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//返信タイムライン
|
|
|
|
function replyTL(id, acct_id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var start = 'https://' + domain + '/api/notes/show'
|
2019-05-19 17:39:30 +10:00
|
|
|
var i = {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'POST',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2018-07-30 21:03:49 +10:00
|
|
|
},
|
2019-05-19 17:39:30 +10:00
|
|
|
body: JSON.stringify({
|
|
|
|
i: at,
|
|
|
|
noteId: id
|
2018-07-30 21:03:49 +10:00
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
return false
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
fetch(start, i)
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 04:05:15 +11:00
|
|
|
var mute = getFilterTypeByAcct(acct_id, 'thread')
|
2019-11-09 00:52:54 +11:00
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var templete = misskeyParse([json], '', acct_id, '', '', mute)
|
|
|
|
$('#toot-after').prepend(templete)
|
|
|
|
$('#toot-after .hide').html(lang.lang_details_filtered)
|
|
|
|
$('#toot-after .by_filter').css('display', 'block')
|
|
|
|
$('#toot-after .by_filter').removeClass('hide')
|
|
|
|
var rep = '_replyIds'
|
2019-11-04 03:10:06 +11:00
|
|
|
if (json[rep]) {
|
2019-11-09 00:52:54 +11:00
|
|
|
replyTL(json[rep][0], acct_id)
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//コンテクストってなんですか
|
2019-07-29 02:09:12 +10:00
|
|
|
function getContext(id, acct_id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var start = 'https://' + domain + '/api/notes/conversation'
|
2019-05-19 17:39:30 +10:00
|
|
|
var i = {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'POST',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2018-07-30 21:03:49 +10:00
|
|
|
},
|
2019-05-19 17:39:30 +10:00
|
|
|
body: JSON.stringify({
|
|
|
|
i: at,
|
|
|
|
noteId: id
|
2018-07-30 21:03:49 +10:00
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
var start = 'https://' + domain + '/api/v1/statuses/' + id + '/context'
|
2019-05-19 17:39:30 +10:00
|
|
|
var i = {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
fetch(start, i)
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-03-16 21:06:03 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
json.reverse()
|
|
|
|
var templete = misskeyParse(json, '', acct_id, '', '', [])
|
|
|
|
$('#toot-reply').html(templete)
|
|
|
|
$('#toot-reply .hide').html(lang.lang_details_filtered)
|
|
|
|
$('#toot-reply .by_filter').css('display', 'block')
|
|
|
|
$('#toot-reply .by_filter').removeClass('hide')
|
|
|
|
jQuery('time.timeago').timeago()
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-11-09 04:05:15 +11:00
|
|
|
var mute = getFilterTypeByAcct(acct_id, 'thread')
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = parse(json.descendants, '', acct_id, '', '', mute)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#toot-after .no-data').hide()
|
2021-04-01 14:47:13 +11:00
|
|
|
$('#toot-after-new').removeClass('hide')
|
|
|
|
} else {
|
|
|
|
$('#toot-after-new').addClass('hide')
|
|
|
|
$('#toot-after').html('<span class="no-data">' + lang.lang_details_nodata + '</span>')
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#toot-after').html(templete)
|
|
|
|
$('#toot-after .hide').html(lang.lang_details_filtered)
|
|
|
|
$('#toot-after .by_filter').css('display', 'block')
|
|
|
|
$('#toot-after .by_filter').removeClass('hide')
|
|
|
|
var templete = parse(json.ancestors, '', acct_id, '', '', mute)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#toot-reply .no-data').hide()
|
2021-04-01 14:47:13 +11:00
|
|
|
$('#toot-reply-new').removeClass('hide')
|
|
|
|
} else {
|
|
|
|
$('#toot-reply-new').addClass('hide')
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#toot-reply').prepend(templete)
|
|
|
|
$('#toot-reply .hide').html(lang.lang_details_filtered)
|
|
|
|
$('#toot-reply .by_filter').css('display', 'block')
|
|
|
|
$('#toot-reply .by_filter').removeClass('hide')
|
|
|
|
jQuery('time.timeago').timeago()
|
2019-07-13 01:01:09 +10:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//前のトゥート(Back TL)
|
2018-05-20 16:17:10 +10:00
|
|
|
function beforeToot(id, acct_id, domain) {
|
|
|
|
//var domain = localStorage.getItem("domain_" + acct_id);
|
2019-11-09 00:52:54 +11:00
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var start = 'https://' + domain + '/api/notes/local-timeline'
|
2018-07-30 21:03:49 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'POST',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2018-07-30 21:03:49 +10:00
|
|
|
},
|
2019-05-19 17:39:30 +10:00
|
|
|
body: JSON.stringify({
|
|
|
|
i: at,
|
|
|
|
untilID: id
|
2018-07-30 21:03:49 +10:00
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = misskeyParse(json, 'noauth', acct_id)
|
|
|
|
$('#toot-before').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
var start = 'https://' + domain + '/api/v1/timelines/public?local=true&max_id=' + id
|
2018-07-30 21:03:49 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2019-03-16 21:06:03 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = parse(json, 'noauth', acct_id)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#toot-before .no-data').hide()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#toot-before').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-05-02 14:14:03 +10:00
|
|
|
//前のユーザーのトゥート
|
|
|
|
function userToot(id, acct_id, user) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
var start = 'https://' + domain + '/api/users/notes'
|
2018-07-30 21:03:49 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'POST',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2018-07-30 21:03:49 +10:00
|
|
|
},
|
2019-05-19 17:39:30 +10:00
|
|
|
body: JSON.stringify({
|
|
|
|
i: at,
|
|
|
|
untilID: id,
|
|
|
|
userId: user
|
2018-07-30 21:03:49 +10:00
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = misskeyParse(json, 'noauth', acct_id)
|
|
|
|
$('#user-before').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
var start = 'https://' + domain + '/api/v1/accounts/' + user + '/statuses?max_id=' + id
|
2018-07-30 21:03:49 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-07-30 21:03:49 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-03-16 21:06:03 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = parse(json, '', acct_id)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#user-before .no-data').hide()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#user-before').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2018-07-30 21:03:49 +10:00
|
|
|
}
|
2018-05-02 14:14:03 +10:00
|
|
|
}
|
2019-05-06 20:10:03 +10:00
|
|
|
//後のLTL
|
|
|
|
function afterToot(id, acct_id, domain) {
|
|
|
|
//var domain = localStorage.getItem("domain_" + acct_id);
|
2019-11-09 00:52:54 +11:00
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var start = 'https://' + domain + '/api/v1/timelines/public?local=true&min_id=' + id
|
2019-05-19 17:39:30 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2019-05-19 17:39:30 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = parse(json, 'noauth', acct_id)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#ltl-after .no-data').hide()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#ltl-after').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2019-05-06 20:10:03 +10:00
|
|
|
}
|
|
|
|
//後のUTL
|
|
|
|
function afterUserToot(id, acct_id, user) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var start = 'https://' + domain + '/api/v1/accounts/' + user + '/statuses?min_id=' + id
|
2019-05-19 17:39:30 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2019-05-19 17:39:30 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-10-31 02:30:26 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = parse(json, '', acct_id)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#user-after .no-data').hide()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#user-after').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2019-05-06 20:10:03 +10:00
|
|
|
}
|
|
|
|
//後のFTL
|
|
|
|
function afterFTLToot(id, acct_id, domain) {
|
|
|
|
//var domain = localStorage.getItem("domain_" + acct_id);
|
2019-11-09 00:52:54 +11:00
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var start = 'https://' + domain + '/api/v1/timelines/public?min_id=' + id
|
2019-05-19 17:39:30 +10:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2019-05-19 17:39:30 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json'
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = parse(json, 'noauth', acct_id)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#ftl-after .no-data').hide()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#ftl-after').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2019-05-06 20:10:03 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
|
|
|
//ふぁぼ一覧
|
|
|
|
function faved(id, acct_id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
return false
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var start = 'https://' + domain + '/api/v1/statuses/' + id + '/favourited_by'
|
2018-01-28 23:22:43 +11:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-01-28 23:22:43 +11:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-03-16 21:06:03 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = userparse(json, '', acct_id)
|
|
|
|
if (templete != '') {
|
|
|
|
$('#toot-fav .no-data').hide()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#toot-fav').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//ブースト一覧
|
|
|
|
function rted(id, acct_id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
return false
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var start = 'https://' + domain + '/api/v1/statuses/' + id + '/reblogged_by'
|
2018-01-28 23:22:43 +11:00
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-01-28 23:22:43 +11:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-10-31 02:30:26 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var templete = userparse(json, '', acct_id)
|
|
|
|
$('#toot-rt').html(templete)
|
|
|
|
jQuery('time.timeago').timeago()
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-02-18 03:44:03 +11:00
|
|
|
//URL等のコピー
|
2019-05-19 17:39:30 +10:00
|
|
|
function cbCopy(mode) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var url = $('#tootmodal').attr('data-url')
|
|
|
|
var urls = url.match(/https?:\/\/([-.a-zA-Z0-9]+)/)
|
|
|
|
var domain = urls[1]
|
|
|
|
if (mode == 'emb') {
|
|
|
|
var emb =
|
|
|
|
`<iframe src="${url}/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400"></iframe>
|
|
|
|
<script src="https://${domain}/embed.js" async="async"></script>`
|
|
|
|
execCopy(emb)
|
|
|
|
M.toast({ html: lang.lang_details_embed, displayLength: 1500 })
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
if (execCopy(url)) {
|
2019-11-09 00:52:54 +11:00
|
|
|
M.toast({ html: lang.lang_details_url, displayLength: 1500 })
|
2018-02-25 19:41:34 +11:00
|
|
|
}
|
2018-02-18 03:44:03 +11:00
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
}
|
2018-03-27 13:39:35 +11:00
|
|
|
//本文のコピー
|
2019-05-19 17:39:30 +10:00
|
|
|
function staCopy(id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var html = $('[toot-id=' + id + '] .toot').html()
|
|
|
|
html = html.replace(/^<p>(.+)<\/p>$/, '$1')
|
|
|
|
html = html.replace(/<br\s?\/?>/, '\n')
|
|
|
|
html = html.replace(/<p>/, '\n')
|
|
|
|
html = html.replace(/<\/p>/, '\n')
|
|
|
|
console.log('Copy it:\n' + html)
|
|
|
|
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, '$1')
|
|
|
|
html = $.strip_tags(html)
|
2019-05-19 17:39:30 +10:00
|
|
|
if (execCopy(html)) {
|
2019-11-09 00:52:54 +11:00
|
|
|
M.toast({ html: lang.lang_details_txt, displayLength: 1500 })
|
2018-03-27 13:39:35 +11:00
|
|
|
}
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
//翻訳
|
2019-11-18 03:08:25 +11:00
|
|
|
function trans(tar, to, elem) {
|
2022-12-06 01:43:15 +11:00
|
|
|
var id = elem.parents('.cvo').attr('toot-id')
|
|
|
|
alert(id)
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#toot-this .additional').text('Loading...(Powered by Google Translate)')
|
2022-12-06 01:43:15 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
if (localStorage.getItem('mode_' + domain) == 'misskey') {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var exec = `https://${domain}/api/v1/statuses/${id}/translate`
|
2018-03-31 13:39:06 +11:00
|
|
|
fetch(exec, {
|
2022-12-06 01:43:15 +11:00
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (response) {
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!response.ok) {
|
2022-10-10 19:19:30 +11:00
|
|
|
response.text().then(function (text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.catch(function (error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2022-10-10 19:19:30 +11:00
|
|
|
.then(function (text) {
|
2022-12-06 01:43:15 +11:00
|
|
|
console.log(text)
|
|
|
|
elem.parents('.cvo').find('.toot').append('<span class="gray translate">' + text.content + '</span>')
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
2018-04-07 14:31:09 +10:00
|
|
|
}
|
|
|
|
//ブラウザで開く
|
2019-05-19 17:39:30 +10:00
|
|
|
function brws() {
|
2019-11-09 00:52:54 +11:00
|
|
|
var url = $('#tootmodal').attr('data-url')
|
|
|
|
postMessage(['openUrl', url], '*')
|
2018-04-07 14:31:09 +10:00
|
|
|
}
|
|
|
|
//外部からトゥート開く
|
2021-04-18 20:11:39 +10:00
|
|
|
async function detEx(url, acct_id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
if (acct_id == 'main') {
|
|
|
|
acct_id = localStorage.getItem('main')
|
2018-05-20 16:17:10 +10:00
|
|
|
}
|
2021-04-18 20:11:39 +10:00
|
|
|
Swal.fire({
|
|
|
|
title: 'Loading...',
|
|
|
|
html: lang.lang_details_fetch,
|
|
|
|
showConfirmButton: false,
|
|
|
|
showCloseButton: true,
|
|
|
|
onBeforeOpen: () => {
|
|
|
|
Swal.showLoading()
|
|
|
|
},
|
|
|
|
onClose: () => { },
|
|
|
|
}).then((result) => { })
|
|
|
|
const json = await detExCore(url, acct_id)
|
|
|
|
Swal.close()
|
|
|
|
if (!json.statuses) {
|
|
|
|
postMessage(['openUrl', url], '*')
|
|
|
|
} else {
|
|
|
|
var id = json.statuses[0].id
|
|
|
|
$('.loadp').text($('.loadp').attr('href'))
|
|
|
|
$('.loadp').removeClass('loadp')
|
|
|
|
details(id, acct_id, 0)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
async function detExCore(url, acct_id) {
|
|
|
|
const domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
const start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + encodeURIComponent(url)
|
|
|
|
const at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
let promise = await fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
method: 'GET',
|
2018-04-07 14:31:09 +10:00
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-10-31 02:30:26 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2021-04-18 20:11:39 +10:00
|
|
|
|
|
|
|
const json = await promise.json()
|
|
|
|
if (json) {
|
|
|
|
return json
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|