thedesk/app/js/userdata/his-data.js

742 lines
18 KiB
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11:00
//ユーザーデータ表示
//タイムライン
2020-05-07 01:31:11 +10:00
function utlShow(user, more, acct_id) {
2018-01-28 23:22:43 +11:00
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-01-28 23:22:43 +11:00
if (user == "--now") {
2020-08-02 17:08:07 +10:00
var user = $("#his-data").attr("user-id")
2018-01-28 23:22:43 +11:00
}
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) != "misskey") {
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-tl .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("toot-id")
var plus = "?max_id=" + sid
2018-07-30 21:03:49 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + plus
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
}
2019-05-19 17:39:30 +10:00
} else {
2020-08-02 17:08:07 +10:00
var req = { i: at }
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-tl .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("toot-id")
req.maxId = sid
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
req.userId = user
var start = "https://" + domain + "/api/users/notes"
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "POST",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +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(req)
2020-08-02 17:08:07 +10:00
}
2018-01-28 23:22:43 +11:00
}
2019-11-04 03:09:02 +11:00
fetch(start, i)
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var templete = misskeyParse(json, "", acct_id, "user")
2019-05-19 17:39:30 +10:00
} else {
2020-08-02 17:08:07 +10:00
var templete = parse(json, "", acct_id, "user")
2018-07-30 21:03:49 +10:00
}
2019-11-04 03:09:02 +11:00
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-tl-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
if (localStorage.getItem("mode_" + domain) != "misskey") {
2020-08-02 17:08:07 +10:00
pinutl(templete, user, acct_id)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-tl-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-01-28 23:22:43 +11:00
}
2020-05-07 01:31:11 +10:00
function utlAdd() {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
var user = $("#his-data").attr("user-id")
2020-05-07 01:31:11 +10:00
var add = {
domain: acct_id,
type: 'utl',
data: {
id: user,
acct: $("#his-acct").attr('fullname')
}
}
var multi = localStorage.getItem('column')
var obj = JSON.parse(multi)
localStorage.setItem('card_' + obj.length, 'true')
obj.push(add)
var json = JSON.stringify(obj)
localStorage.setItem('column', json)
parseColumn('add')
hisclose()
}
2018-03-27 13:39:35 +11:00
//ピン留めTL
2019-05-19 17:39:30 +10:00
function pinutl(before, user, acct_id) {
2018-03-27 13:39:35 +11:00
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-03-27 13:39:35 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-03-27 13:39:35 +11:00
if (user == "--now") {
2020-08-02 17:08:07 +10:00
var user = $("#his-data").attr("user-id")
2018-03-27 13:39:35 +11:00
}
2020-08-02 17:08:07 +10:00
var plus = "?pinned=1"
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + plus
2018-03-27 13:39:35 +11:00
fetch(start, {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-03-27 13:39:35 +11:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
2020-08-02 17:08:07 +10:00
var templete = parse(json, "pinned", acct_id, "user")
2019-11-04 03:09:02 +11:00
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = ""
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
$("#his-tl-contents").html(templete + before)
jQuery("time.timeago").timeago()
})
2018-03-27 13:39:35 +11:00
}
2018-01-28 23:22:43 +11:00
//フォローリスト
function flw(user, more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-01-28 23:22:43 +11:00
if (user == "--now") {
2020-08-02 17:08:07 +10:00
var user = $("#his-data").attr("user-id")
2018-01-28 23:22:43 +11:00
}
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var req = { i: at }
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-follow-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
req.maxId = sid
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
req.userId = user
var start = "https://" + domain + "/api/users/following"
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "POST",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +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(req)
2020-08-02 17:08:07 +10:00
}
2019-05-19 17:39:30 +10:00
} else {
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-follow-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-07-30 21:03:49 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/accounts/" + user + "/following" + plus
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
}
2018-01-28 23:22:43 +11:00
}
2019-11-04 03:09:02 +11:00
fetch(start, i)
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var templete = misskeyUserparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
var templete = userparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
}
if (templete == "") {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-follow-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-follow-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-01-28 23:22:43 +11:00
}
//フォロワーリスト
function fer(user, more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-01-28 23:22:43 +11:00
if (user == "--now") {
2020-08-02 17:08:07 +10:00
var user = $("#his-data").attr("user-id")
2018-01-28 23:22:43 +11:00
}
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var req = { i: at }
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-follower-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
req.maxId = sid
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
req.userId = user
var start = "https://" + domain + "/api/users/followers"
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "POST",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +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(req)
2020-08-02 17:08:07 +10:00
}
2019-05-19 17:39:30 +10:00
} else {
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-follower-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-07-30 21:03:49 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/accounts/" + user + "/followers" + plus
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
}
2018-01-28 23:22:43 +11:00
}
2019-11-04 03:09:02 +11:00
fetch(start, i)
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var templete = misskeyUserparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
var templete = userparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
}
if (templete == "") {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-follower-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-follower-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-01-28 23:22:43 +11:00
}
//以下自分のみ
//お気に入り一覧
function showFav(more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) != "misskey") {
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-fav-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("toot-id")
var plus = "?max_id=" + sid
2018-07-30 21:03:49 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/favourites" + plus
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
}
2019-05-19 17:39:30 +10:00
} else {
2020-08-02 17:08:07 +10:00
var req = { i: at }
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-fav-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("toot-id")
req.maxId = sid
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/i/favorites"
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "POST",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +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(req)
2020-08-02 17:08:07 +10:00
}
2018-01-28 23:22:43 +11:00
}
2019-05-19 17:39:30 +10:00
2019-11-04 03:09:02 +11:00
fetch(start, i)
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (localStorage.getItem("mode_" + domain) != "misskey") {
2020-08-02 17:08:07 +10:00
var templete = parse(json, "", acct_id, "user")
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
var templete = misskeyParse(json, "", acct_id, "user")
2019-11-04 03:09:02 +11:00
}
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-fav-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-fav-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-01-28 23:22:43 +11:00
}
//ミュートリスト
function showMut(more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var req = { i: at }
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-muting-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
req.maxId = sid
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/mute/list"
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "POST",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +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(req)
2020-08-02 17:08:07 +10:00
}
2019-05-19 17:39:30 +10:00
} else {
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-muting-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-07-30 21:03:49 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/mutes" + plus
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
}
2018-01-28 23:22:43 +11:00
}
2019-05-19 17:39:30 +10:00
2019-11-04 03:09:02 +11:00
fetch(start, i)
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
var templete = userparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-muting-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-muting-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
})
2018-01-28 23:22:43 +11:00
}
//ブロックリスト
function showBlo(more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
$("#his-blocking-list-contents").html(lang.lang_hisdata_notonmisskey + "<br>")
return false
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-01-28 23:22:43 +11:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-blocking-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-01-28 23:22:43 +11:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/blocks" + plus
2018-01-28 23:22:43 +11:00
fetch(start, {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-01-28 23:22:43 +11:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
var templete = userparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-blocking-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-blocking-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-01-28 23:22:43 +11:00
}
//フォロリクリスト
function showReq(more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
var req = { i: at }
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-request-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
req.maxId = sid
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/following/requests/list"
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "POST",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +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(req)
2020-08-02 17:08:07 +10:00
}
2019-05-19 17:39:30 +10:00
} else {
2018-07-30 21:03:49 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-request-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-07-30 21:03:49 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/follow_requests" + plus
2019-05-19 17:39:30 +10:00
var i = {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-30 21:03:49 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
}
2018-01-28 23:22:43 +11:00
}
2019-11-04 03:09:02 +11:00
fetch(start, i)
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (localStorage.getItem("mode_" + domain) != "misskey") {
2020-08-02 17:08:07 +10:00
var templete = userparse(json, "request", acct_id)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
var templete = misskeyUserparse(json, true, acct_id)
2019-11-04 03:09:02 +11:00
}
2019-05-19 17:39:30 +10:00
2019-11-04 03:09:02 +11:00
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-request-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-request-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-01-28 23:22:43 +11:00
}
//ドメインブロックリスト
function showDom(more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
$("#his-domain-list-contents").html(lang.lang_hisdata_notonmisskey + "<br>")
return false
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-01-28 23:22:43 +11:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-domain-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-01-28 23:22:43 +11:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-01-28 23:22:43 +11:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/domain_blocks" + plus
2018-01-28 23:22:43 +11:00
fetch(start, {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-01-28 23:22:43 +11:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
}
2018-01-28 23:22:43 +11:00
//body: JSON.stringify({})
2019-11-04 03:09:02 +11:00
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
2020-08-02 17:08:07 +10:00
var templete = ""
2019-11-04 03:09:02 +11:00
if (!json[0]) {
2020-08-02 17:08:07 +10:00
templete = lang.lang_details_nodata + "<br>"
2019-11-04 03:09:02 +11:00
}
Object.keys(json).forEach(function(key) {
2020-08-02 17:08:07 +10:00
var domain = json[key]
templete = templete + domain + '<i class="material-icons gray pointer" onclick="domainblock(\'' + domain + "','DELETE')\">cancel</i>" + '<div class="divider"></div>'
})
2019-11-04 03:09:02 +11:00
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-domain-list-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-domain-list-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
})
2018-01-28 23:22:43 +11:00
}
2018-07-07 03:51:48 +10:00
//フォローレコメンデーションリスト
function showFrl(more, acct_id) {
if (!acct_id) {
2020-08-02 17:08:07 +10:00
var acct_id = $("#his-data").attr("use-acct")
2018-07-07 03:51:48 +10:00
}
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("mode_" + domain) == "misskey") {
2020-08-02 17:08:07 +10:00
$("#his-follow-recom-contents").html(lang.lang_hisdata_notonmisskey + "<br>")
return false
2018-07-30 21:03:49 +10:00
}
2020-08-02 17:08:07 +10:00
var at = localStorage.getItem("acct_" + acct_id + "_at")
2018-07-07 03:51:48 +10:00
if (more) {
2019-11-04 03:09:02 +11:00
var sid = $("#his-follow-recom-list .cvo")
.last()
2020-08-02 17:08:07 +10:00
.attr("user-id")
var plus = "?max_id=" + sid
2018-07-07 03:51:48 +10:00
} else {
2020-08-02 17:08:07 +10:00
var plus = ""
2018-07-07 03:51:48 +10:00
}
2020-08-02 17:08:07 +10:00
var start = "https://" + domain + "/api/v1/suggestions" + plus
2018-07-07 03:51:48 +10:00
fetch(start, {
2019-11-04 03:09:02 +11:00
method: "GET",
2018-07-07 03:51:48 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
$("#his-follow-recom-contents").html(lang.lang_details_nodata + "(" + lang.lang_hisdata_frcreq + ")<br>")
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (!json[0]) {
2020-08-02 17:08:07 +10:00
console.warn("No suggestions(recommend) data")
templete = lang.lang_details_nodata + "(" + lang.lang_hisdata_frcwarn + ")<br>"
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
var templete = userparse(json, "", acct_id)
2019-11-04 03:09:02 +11:00
}
2019-05-19 17:39:30 +10:00
2019-11-04 03:09:02 +11:00
if (more) {
2020-08-02 17:08:07 +10:00
$("#his-follow-recom-contents").append(templete)
2019-11-04 03:09:02 +11:00
} else {
2020-08-02 17:08:07 +10:00
$("#his-follow-recom-contents").html(templete)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
jQuery("time.timeago").timeago()
})
2018-07-07 03:51:48 +10:00
}
2019-04-13 13:41:58 +10:00
//Keybase
2019-09-06 00:55:34 +10:00
function udAdd(acct_id, id, start) {
2020-08-02 17:08:07 +10:00
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
var proof = "https://" + domain + "/api/v1/accounts/" + id + "/identity_proofs"
2019-09-06 00:55:34 +10:00
fetch(proof, {
2019-11-04 03:09:02 +11:00
method: "GET",
2019-04-13 13:41:58 +10:00
headers: {
2019-11-04 03:09:02 +11:00
"content-type": "application/json",
Authorization: "Bearer " + at
2019-04-13 13:41:58 +10:00
}
2019-11-04 03:09:02 +11:00
//body: JSON.stringify({})
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
2020-08-02 17:08:07 +10:00
var fields = json
2019-11-04 03:09:02 +11:00
for (var i = 0; i < fields.length; i++) {
2020-08-02 17:08:07 +10:00
var html = '<a href="' + fields[i].proof_url + '" target="_blank" class="cbadge teal waves-effect" style="max-width:200px;" title="' + lang.lang_hisdata_key.replace("{{set}}", escapeHTML(fields[i].provider)) + '"><i class="fas fa-key" aria-hidden="true"></i>' + escapeHTML(fields[i].provider) + ":" + escapeHTML(fields[i].provider_username) + "</a>"
$("#his-proof-prof").append(html)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
})
2019-05-19 17:39:30 +10:00
fetch("https://notestock.osa-p.net/api/v1/isstock.json?id=" + start.replace("@", "users/"), {
2019-11-04 03:09:02 +11:00
method: "GET",
2019-05-06 02:28:00 +10:00
headers: {
2019-11-04 03:09:02 +11:00
Accept: "application/json"
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
2020-08-02 17:08:07 +10:00
setLog(response.url, response.status, text)
})
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
return response.json()
2019-11-04 03:09:02 +11:00
})
.catch(function(error) {
2020-08-02 17:08:07 +10:00
todo(error)
setLog(start, "JSON", error)
console.error(error)
2019-11-04 03:09:02 +11:00
})
.then(function(json) {
if (json.user.public_view) {
2020-08-02 17:08:07 +10:00
var html = '<a href="' + json.user.url + '" target="_blank" class="cbadge purple waves-effect" style="max-width:200px;" title="Notestock">Notestock</a>'
$("#his-proof-prof").append(html)
2019-11-04 03:09:02 +11:00
}
2020-08-02 17:08:07 +10:00
})
2019-04-13 13:41:58 +10:00
}