Fix: follow on cross-acct

This commit is contained in:
cutls 2019-11-04 01:09:02 +09:00
parent 9977c009e0
commit 25d24ddef0
4 changed files with 1424 additions and 1298 deletions

View File

@ -18,7 +18,9 @@ function fav(id, acct_id, remote) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
if (json.reblog) { if (json.reblog) {
json = json.reblog; json = json.reblog;
} }
@ -76,7 +78,9 @@ function rt(id, acct_id, remote, vis) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
if (json.reblog) { if (json.reblog) {
json = json.reblog; json = json.reblog;
} }
@ -113,13 +117,13 @@ function boostWith(vis) {
} }
//フォロー //フォロー
function follow(acct_id, remote) { async function follow(acct_id, resolve) {
if (!acct_id && acct_id != "selector") { if (!acct_id && acct_id != "selector") {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} else if (acct_id == "selector") { } else if (acct_id == "selector") {
var acct_id = $("#user-acct-sel").val(); var acct_id = $("#user-acct-sel").val();
} }
if (!remote && $("#his-data").hasClass("following")) { if (!resolve && $("#his-data").hasClass("following")) {
var flag = "unfollow"; var flag = "unfollow";
var flagm = "delete"; var flagm = "delete";
} else { } else {
@ -127,17 +131,18 @@ function follow(acct_id, remote) {
var flagm = "create"; var flagm = "create";
} }
var id = $("#his-data").attr("user-id"); var id = $("#his-data").attr("user-id");
if (!remote) { if (resolve == "selector") {
var remote = $("#his-data").attr("remote"); var fullacct = $("#his-acct").attr("fullname");
var id = await acctResolve(acct_id, fullacct);
console.log(id);
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var user = $("#his-acct").text();
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/following/" + flagm; var start = "https://" + domain + "/api/following/" + flagm;
var ent = { i: at, userId: id }; var ent = { i: at, userId: id };
} else if (remote == "true" && flag == "follow") { } else if (flag == "follow") {
var ent = {}; var ent = {};
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
@ -149,7 +154,9 @@ function follow(acct_id, remote) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
console.log(["Success: folllow", json]); console.log(["Success: folllow", json]);
if ($("#his-data").hasClass("following")) { if ($("#his-data").hasClass("following")) {
$("#his-data").removeClass("following"); $("#his-data").removeClass("following");
@ -161,6 +168,29 @@ function follow(acct_id, remote) {
} }
}; };
} }
async function acctResolve(acct_id, user) {
console.log("Get user data of " + user);
var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") {
return false;
}
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + user;
let promise = await fetch(start, {
method: "GET",
headers: {
"content-type": "application/json",
Authorization: "Bearer " + at
}
});
var idJson = await promise.json();
if (idJson.accounts[0]) {
var id = idJson.accounts[0].id;
} else {
M.toast({ html: lang.lang_fatalerroroccured, displayLength: 2000 });
}
return id;
}
//ブロック //ブロック
function block(acct_id) { function block(acct_id) {
@ -197,7 +227,9 @@ function block(acct_id) {
httpreq.send(); httpreq.send();
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
if ($("#his-data").hasClass("blocking")) { if ($("#his-data").hasClass("blocking")) {
$("#his-data").removeClass("blocking"); $("#his-data").removeClass("blocking");
$("#his-block-btn-text").text(lang.lang_status_block); $("#his-block-btn-text").text(lang.lang_status_block);
@ -255,7 +287,9 @@ function muteDo(acct_id) {
httpreq.send(rq); httpreq.send(rq);
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
if ($("#his-data").hasClass("muting")) { if ($("#his-data").hasClass("muting")) {
$("#his-data").removeClass("muting"); $("#his-data").removeClass("muting");
$("#his-mute-btn-text").text(lang.lang_status_mute); $("#his-mute-btn-text").text(lang.lang_status_mute);
@ -293,7 +327,9 @@ function del(id, acct_id) {
} }
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
} }
}; };
} }
@ -325,9 +361,7 @@ function redraft(id, acct_id) {
if (i < ct) { if (i < ct) {
var url = $(elem).attr("src"); var url = $(elem).attr("src");
console.log("Play back image data:" + url); console.log("Play back image data:" + url);
$("#preview").append( $("#preview").append('<img src="' + url + '" style="width:50px; max-height:100px;">');
'<img src="' + url + '" style="width:50px; max-height:100px;">'
);
} }
}); });
var html = $("[toot-id=" + id + "] .toot").html(); var html = $("[toot-id=" + id + "] .toot").html();
@ -368,7 +402,9 @@ function pin(id, acct_id) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
console.log(["Success: pinned", json]); console.log(["Success: pinned", json]);
if ($("[toot-id=" + id + "]").hasClass("pined")) { if ($("[toot-id=" + id + "]").hasClass("pined")) {
$("[toot-id=" + id + "]").removeClass("pined"); $("[toot-id=" + id + "]").removeClass("pined");
@ -385,8 +421,7 @@ function pin(id, acct_id) {
function request(id, flag, acct_id) { function request(id, flag, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = var start = "https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag;
"https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag;
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open("POST", start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader("Content-Type", "application/json"); httpreq.setRequestHeader("Content-Type", "application/json");
@ -396,7 +431,9 @@ function request(id, flag, acct_id) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
console.log(["Success: request", "type:" + flag, json]); console.log(["Success: request", "type:" + flag, json]);
showReq(); showReq();
} }
@ -420,7 +457,9 @@ function domainblock(add, flag, acct_id) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
console.log(["Success: domain block", json]); console.log(["Success: domain block", json]);
showDom(); showDom();
} }
@ -477,7 +516,9 @@ function pinUser() {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
if ($("#his-end-btn").hasClass("endorsed")) { if ($("#his-end-btn").hasClass("endorsed")) {
$("#his-end-btn").removeClass("endorsed"); $("#his-end-btn").removeClass("endorsed");
$("#his-end-btn").text(lang.lang_status_endorse); $("#his-end-btn").text(lang.lang_status_endorse);
@ -518,6 +559,7 @@ function staEx(mode) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {

View File

@ -2,60 +2,67 @@
//タイムライン //タイムライン
function utl(user, more, acct_id) { function utl(user, more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (user == "--now") { if (user == "--now") {
var user = $('#his-data').attr("user-id"); var user = $("#his-data").attr("user-id");
} }
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
if (more) { if (more) {
var sid = $("#his-tl .cvo").last().attr("toot-id"); var sid = $("#his-tl .cvo")
.last()
.attr("toot-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + plus;
plus;
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}
} }
};
} else { } else {
var req = { i: at } var req = { i: at };
if (more) { if (more) {
var sid = $("#his-tl .cvo").last().attr("toot-id"); var sid = $("#his-tl .cvo")
.last()
.attr("toot-id");
req.maxId = sid; req.maxId = sid;
} }
req.userId = user; req.userId = user;
var start = "https://" + domain + "/api/users/notes" var start = "https://" + domain + "/api/users/notes";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify(req) body: JSON.stringify(req)
};
} }
} fetch(start, i)
fetch(start, i).then(function (response) { .then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var templete = misskeyParse(json, '', acct_id, 'user'); var templete = misskeyParse(json, "", acct_id, "user");
} else { } else {
var templete = parse(json, '', acct_id, 'user'); var templete = parse(json, "", acct_id, "user");
} }
if (!json[0]) { if (!json[0]) {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
@ -64,7 +71,7 @@ function utl(user, more, acct_id) {
$("#his-tl-contents").append(templete); $("#his-tl-contents").append(templete);
} else { } else {
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
pinutl(templete, user, acct_id) pinutl(templete, user, acct_id);
} else { } else {
$("#his-tl-contents").html(templete); $("#his-tl-contents").html(templete);
} }
@ -75,34 +82,37 @@ function utl(user, more, acct_id) {
//ピン留めTL //ピン留めTL
function pinutl(before, user, acct_id) { function pinutl(before, user, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (user == "--now") { if (user == "--now") {
var user = $('#his-data').attr("user-id"); var user = $("#his-data").attr("user-id");
} }
var plus = "?pinned=1"; var plus = "?pinned=1";
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses" + plus;
plus
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = parse(json, 'pinned', acct_id, 'user'); .then(function(json) {
var templete = parse(json, "pinned", acct_id, "user");
if (!json[0]) { if (!json[0]) {
templete = ""; templete = "";
} }
@ -114,60 +124,67 @@ function pinutl(before, user, acct_id) {
//フォローリスト //フォローリスト
function flw(user, more, acct_id) { function flw(user, more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (user == "--now") { if (user == "--now") {
var user = $('#his-data').attr("user-id"); var user = $("#his-data").attr("user-id");
} }
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var req = { i: at } var req = { i: at };
if (more) { if (more) {
var sid = $("#his-follow-list .cvo").last().attr("user-id"); var sid = $("#his-follow-list .cvo")
.last()
.attr("user-id");
req.maxId = sid; req.maxId = sid;
} }
req.userId = user; req.userId = user;
var start = "https://" + domain + "/api/users/following" var start = "https://" + domain + "/api/users/following";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify(req) body: JSON.stringify(req)
} };
} else { } else {
if (more) { if (more) {
var sid = $("#his-follow-list .cvo").last().attr("user-id"); var sid = $("#his-follow-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/accounts/" + user + "/following" + var start = "https://" + domain + "/api/v1/accounts/" + user + "/following" + plus;
plus
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
} }
};
} }
} fetch(start, i)
fetch(start, i).then(function (response) { .then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var templete = misskeyUserparse(json, '', acct_id); var templete = misskeyUserparse(json, "", acct_id);
} else { } else {
var templete = userparse(json, '', acct_id); var templete = userparse(json, "", acct_id);
} }
if (templete == "") { if (templete == "") {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
@ -178,67 +195,73 @@ function flw(user, more, acct_id) {
$("#his-follow-list-contents").html(templete); $("#his-follow-list-contents").html(templete);
} }
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
} }
//フォロワーリスト //フォロワーリスト
function fer(user, more, acct_id) { function fer(user, more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (user == "--now") { if (user == "--now") {
var user = $('#his-data').attr("user-id"); var user = $("#his-data").attr("user-id");
} }
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var req = { i: at } var req = { i: at };
if (more) { if (more) {
var sid = $("#his-follower-list .cvo").last().attr("user-id"); var sid = $("#his-follower-list .cvo")
.last()
.attr("user-id");
req.maxId = sid; req.maxId = sid;
} }
req.userId = user; req.userId = user;
var start = "https://" + domain + "/api/users/followers" var start = "https://" + domain + "/api/users/followers";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify(req) body: JSON.stringify(req)
} };
} else { } else {
if (more) { if (more) {
var sid = $("#his-follower-list .cvo").last().attr("user-id"); var sid = $("#his-follower-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/accounts/" + user + "/followers" + var start = "https://" + domain + "/api/v1/accounts/" + user + "/followers" + plus;
plus
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
} }
};
} }
} fetch(start, i)
fetch(start, i).then(function (response) { .then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var templete = misskeyUserparse(json, '', acct_id); var templete = misskeyUserparse(json, "", acct_id);
} else { } else {
var templete = userparse(json, '', acct_id); var templete = userparse(json, "", acct_id);
} }
if (templete == "") { if (templete == "") {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
@ -256,56 +279,64 @@ function fer(user, more, acct_id) {
//お気に入り一覧 //お気に入り一覧
function showFav(more, acct_id) { function showFav(more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
if (more) { if (more) {
var sid = $("#his-fav-list .cvo").last().attr("toot-id"); var sid = $("#his-fav-list .cvo")
.last()
.attr("toot-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/favourites" + plus var start = "https://" + domain + "/api/v1/favourites" + plus;
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}
} }
};
} else { } else {
var req = { i: at } var req = { i: at };
if (more) { if (more) {
var sid = $("#his-fav-list .cvo").last().attr("toot-id"); var sid = $("#his-fav-list .cvo")
.last()
.attr("toot-id");
req.maxId = sid; req.maxId = sid;
} }
var start = "https://" + domain + "/api/i/favorites" var start = "https://" + domain + "/api/i/favorites";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify(req) body: JSON.stringify(req)
} };
} }
fetch(start, i).then(function (response) { fetch(start, i)
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var templete = parse(json, '', acct_id, 'user'); var templete = parse(json, "", acct_id, "user");
} else { } else {
var templete = misskeyParse(json, '', acct_id, 'user'); var templete = misskeyParse(json, "", acct_id, "user");
} }
if (!json[0]) { if (!json[0]) {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
@ -322,69 +353,76 @@ function showFav(more, acct_id) {
//ミュートリスト //ミュートリスト
function showMut(more, acct_id) { function showMut(more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var req = { i: at } var req = { i: at };
if (more) { if (more) {
var sid = $("#his-muting-list .cvo").last().attr("user-id"); var sid = $("#his-muting-list .cvo")
.last()
.attr("user-id");
req.maxId = sid; req.maxId = sid;
} }
var start = "https://" + domain + "/api/mute/list" var start = "https://" + domain + "/api/mute/list";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify(req) body: JSON.stringify(req)
} };
} else { } else {
if (more) { if (more) {
var sid = $("#his-muting-list .cvo").last().attr("user-id"); var sid = $("#his-muting-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/mutes" + plus var start = "https://" + domain + "/api/v1/mutes" + plus;
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}
} }
};
} }
fetch(start, i).then(function (response) { fetch(start, i)
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (!json[0]) { if (!json[0]) {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
} }
var templete = userparse(json, '', acct_id); var templete = userparse(json, "", acct_id);
if (more) { if (more) {
$("#his-muting-list-contents").append(templete); $("#his-muting-list-contents").append(templete);
} else { } else {
$("#his-muting-list-contents").html(templete); $("#his-muting-list-contents").html(templete);
} }
}); });
} }
//ブロックリスト //ブロックリスト
function showBlo(more, acct_id) { function showBlo(more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
@ -393,33 +431,39 @@ function showBlo(more, acct_id) {
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (more) { if (more) {
var sid = $("#his-blocking-list .cvo").last().attr("user-id"); var sid = $("#his-blocking-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/blocks" + plus var start = "https://" + domain + "/api/v1/blocks" + plus;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (!json[0]) { if (!json[0]) {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
} }
var templete = userparse(json, '', acct_id); var templete = userparse(json, "", acct_id);
if (more) { if (more) {
$("#his-blocking-list-contents").append(templete); $("#his-blocking-list-contents").append(templete);
} else { } else {
@ -431,54 +475,60 @@ function showBlo(more, acct_id) {
//フォロリクリスト //フォロリクリスト
function showReq(more, acct_id) { function showReq(more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var req = { i: at } var req = { i: at };
if (more) { if (more) {
var sid = $("#his-request-list .cvo").last().attr("user-id"); var sid = $("#his-request-list .cvo")
.last()
.attr("user-id");
req.maxId = sid; req.maxId = sid;
} }
var start = "https://" + domain + "/following/requests/list" var start = "https://" + domain + "/following/requests/list";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify(req) body: JSON.stringify(req)
} };
} else { } else {
if (more) { if (more) {
var sid = $("#his-request-list .cvo").last().attr("user-id"); var sid = $("#his-request-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/follow_requests" + plus var start = "https://" + domain + "/api/v1/follow_requests" + plus;
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
} }
};
} }
} fetch(start, i)
fetch(start, i).then(function (response) { .then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var templete = userparse(json, "request", acct_id); var templete = userparse(json, "request", acct_id);
} else { } else {
@ -500,7 +550,7 @@ function showReq(more, acct_id) {
//ドメインブロックリスト //ドメインブロックリスト
function showDom(more, acct_id) { function showDom(more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
@ -509,54 +559,56 @@ function showDom(more, acct_id) {
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (more) { if (more) {
var sid = $("#his-domain-list .cvo").last().attr("user-id"); var sid = $("#his-domain-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/domain_blocks" + plus var start = "https://" + domain + "/api/v1/domain_blocks" + plus;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
var templete = ""; var templete = "";
if (!json[0]) { if (!json[0]) {
templete = lang.lang_details_nodata + "<br>"; templete = lang.lang_details_nodata + "<br>";
} }
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var domain = json[key]; var domain = json[key];
templete = templete + domain + templete = templete + domain + '<i class="material-icons gray pointer" onclick="domainblock(\'' + domain + "','DELETE')\">cancel</i>" + '<div class="divider"></div>';
'<i class="material-icons gray pointer" onclick="domainblock(\'' +
domain + '\',\'DELETE\')">cancel</i>' +
'<div class="divider"></div>';
}); });
if (more) { if (more) {
$("#his-domain-list-contents").append(templete); $("#his-domain-list-contents").append(templete);
} else { } else {
$("#his-domain-list-contents").html(templete); $("#his-domain-list-contents").html(templete);
} }
}); });
} }
//フォローレコメンデーションリスト //フォローレコメンデーションリスト
function showFrl(more, acct_id) { function showFrl(more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
@ -565,34 +617,39 @@ function showFrl(more, acct_id) {
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (more) { if (more) {
var sid = $("#his-follow-recom-list .cvo").last().attr("user-id"); var sid = $("#his-follow-recom-list .cvo")
.last()
.attr("user-id");
var plus = "?max_id=" + sid; var plus = "?max_id=" + sid;
} else { } else {
var plus = ""; var plus = "";
} }
var start = "https://" + domain + "/api/v1/suggestions" + plus var start = "https://" + domain + "/api/v1/suggestions" + plus;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
$("#his-follow-recom-contents").html(lang.lang_details_nodata + "(" + lang.lang_hisdata_frcreq + ")<br>"); $("#his-follow-recom-contents").html(lang.lang_details_nodata + "(" + lang.lang_hisdata_frcreq + ")<br>");
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (!json[0]) { if (!json[0]) {
console.warn("No suggestions(recommend) data"); console.warn("No suggestions(recommend) data");
templete = lang.lang_details_nodata + "(" + lang.lang_hisdata_frcwarn + ")<br>"; templete = lang.lang_details_nodata + "(" + lang.lang_hisdata_frcwarn + ")<br>";
} else { } else {
var templete = userparse(json, '', acct_id); var templete = userparse(json, "", acct_id);
} }
if (more) { if (more) {
@ -607,103 +664,99 @@ function showFrl(more, acct_id) {
function udAdd(acct_id, id, start) { function udAdd(acct_id, id, start) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var proof = "https://" + domain + "/api/v1/accounts/" + id + "/identity_proofs" var proof = "https://" + domain + "/api/v1/accounts/" + id + "/identity_proofs";
fetch(proof, { fetch(proof, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
var fields = json; var fields = json;
for (var i = 0; i < fields.length; i++) { for (var i = 0; i < fields.length; i++) {
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>'; 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) $("#his-proof-prof").append(html);
} }
}); });
fetch("https://notestock.osa-p.net/api/v1/isstock.json?id=" + start.replace("@", "users/"), { fetch("https://notestock.osa-p.net/api/v1/isstock.json?id=" + start.replace("@", "users/"), {
method: 'GET', method: "GET",
headers: { headers: {
'Accept': 'application/json' Accept: "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.user.public_view) { if (json.user.public_view) {
var html = '<a href="' + json.user.url + '" target="_blank" class="cbadge purple waves-effect" style="max-width:200px;" title="Notestock">Notestock</a>'; 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) $("#his-proof-prof").append(html);
} }
}); });
} }
//ユーザーマッチングリスト //ユーザーマッチングリスト
function showMat() { function showMat() {
$("#his-matching-list-contents").html(lang.lang_hisdata_taketime); $("#his-matching-list-contents").html(lang.lang_hisdata_taketime);
var full = $("#his-acct").attr("fullname"); var full = $("#his-acct").attr("fullname");
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
full = full.split("@"); full = full.split("@");
var start = "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-filtered-api.cgi?" + full[1] + "+" + full[0]; var start = "https://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-filtered-api.cgi?" + full[1] + "+" + full[0];
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
var templete = ""; var templete = "";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var user = json[key]; var user = json[key];
if (user.avatar) { if (user.avatar) {
var avatar = user.avatar var avatar = user.avatar;
} else { } else {
var avatar = "../../img/loading.svg" var avatar = "../../img/loading.svg";
} }
templete = templete + templete = templete + '<div class="" style="padding-top:5px;">' + '<div style="padding:0; margin:0; width:400px; max-width:100%; display:flex; align-items:flex-end;">' + '<div style="flex-basis:40px;"><a onclick="udgEx(\'' + user.user + "'," + acct_id + ');" user="' + user.user + '" class="udg">' + '<img src="' + avatar + '" width="40" class="prof-img" user="' + user.user + '"></a></div>' + '<div style="flex-grow:3; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"><big>' + escapeHTML(user.screen_name) + "</big></div>" + '<div class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' + user.user + "@" + user.host + "</div>" + "</div>" + '<div class="divider"></div>' + "</div>" + "</div>";
'<div class="" style="padding-top:5px;">' +
'<div style="padding:0; margin:0; width:400px; max-width:100%; display:flex; align-items:flex-end;">' +
'<div style="flex-basis:40px;"><a onclick="udgEx(\'' + user.user + '\',' +
acct_id + ');" user="' + user.user + '" class="udg">' +
'<img src="' + avatar + '" width="40" class="prof-img" user="' + user.user + '"></a></div>' +
'<div style="flex-grow:3; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"><big>' +
escapeHTML(user.screen_name) + '</big></div>' +
'<div class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
user.user + '@' + user.host + '</div>' +
'</div>' +
'<div class="divider"></div>' +
'</div>' +
'</div>';
}); });
$("#his-matching-list").css("height", $("#his-float-data").height() - $("#his-basic-prof").height() - $("#his-des").height() - $("#his-plus-action").height() + "px"); $("#his-matching-list").css("height", $("#his-float-data").height() - $("#his-basic-prof").height() - $("#his-des").height() - $("#his-plus-action").height() + "px");
$("#his-matching-list-contents").html(templete); $("#his-matching-list-contents").html(templete);

View File

@ -6,12 +6,12 @@ if (location.search) {
var mode = m[1]; var mode = m[1];
var codex = m[2]; var codex = m[2];
if (mode == "user") { if (mode == "user") {
udgEx(codex, 'main'); udgEx(codex, "main");
} }
} }
function udgEx(user, acct_id) { function udgEx(user, acct_id) {
if (user == "selector") { if (user == "selector") {
user = $("#his-acct").attr('fullname'); user = $("#his-acct").attr("fullname");
} }
if (acct_id == "selector") { if (acct_id == "selector") {
acct_id = $("#user-acct-sel").val(); acct_id = $("#user-acct-sel").val();
@ -21,31 +21,37 @@ function udgEx(user, acct_id) {
} }
console.log("Get user data of " + user); console.log("Get user data of " + user);
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { return false; } if (localStorage.getItem("mode_" + domain) == "misskey") {
var at = localStorage.getItem("acct_" + acct_id + "_at"); return false;
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + user
fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
} }
}).then(function (response) { var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + user;
fetch(start, {
method: "GET",
headers: {
"content-type": "application/json",
Authorization: "Bearer " + at
}
})
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.accounts[0]) { if (json.accounts[0]) {
var id = json.accounts[0].id; var id = json.accounts[0].id;
udg(id, acct_id); udg(id, acct_id);
} else { } else {
postMessage(["openUrl", user], "*") postMessage(["openUrl", user], "*");
} }
}); });
return true; return true;
@ -58,56 +64,60 @@ function udg(user, acct_id) {
todo("User Data Loading..."); todo("User Data Loading...");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
misskeyUdg(user, acct_id) misskeyUdg(user, acct_id);
return; return;
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + user; var start = "https://" + domain + "/api/v1/accounts/" + user;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
//一つ前のユーザーデータ //一つ前のユーザーデータ
if (!localStorage.getItem("history")) { if (!localStorage.getItem("history")) {
$("#his-history-btn").prop("disabled", true); $("#his-history-btn").prop("disabled", true);
} else { } else {
$("#his-history-btn").prop("disabled", false); $("#his-history-btn").prop("disabled", false);
$('#his-data').attr("history", localStorage.getItem("history")); $("#his-data").attr("history", localStorage.getItem("history"));
} }
//moved設定時 //moved設定時
if (json.moved) { if (json.moved) {
M.toast({ M.toast({
html: lang.lang_showontl_movetxt + '<button class="btn-flat toast-action" onclick="udg(\'' + html: lang.lang_showontl_movetxt + '<button class="btn-flat toast-action" onclick="udg(\'' + json.moved.id + "','" + acct_id + "')\">" + lang.lang_showontl_movebtn + "</button>",
json.moved.id + '\',\'' + acct_id + '\')">' + lang.lang_showontl_movebtn + '</button>', displayLength: 4000 displayLength: 4000
}) });
} }
$('#his-data').modal('open'); $("#his-data").modal("open");
$('#his-data').attr("user-id", user); $("#his-data").attr("user-id", user);
$('#his-data').attr("use-acct", acct_id); $("#his-data").attr("use-acct", acct_id);
if (json.username != json.acct) { if (json.username != json.acct) {
//Remote //Remote
$('#his-data').attr("remote", "true"); $("#his-data").attr("remote", "true");
var fullname = json.acct; var fullname = json.acct;
} else { } else {
$('#his-data').attr("remote", "false"); $("#his-data").attr("remote", "false");
var fullname = json.acct + "@" + domain; var fullname = json.acct + "@" + domain;
} }
utl(json.id, '', acct_id); utl(json.id, "", acct_id);
flw(json.id, '', acct_id); flw(json.id, "", acct_id);
fer(json.id, '', acct_id); fer(json.id, "", acct_id);
var dis_name = escapeHTML(json.display_name); var dis_name = escapeHTML(json.display_name);
dis_name = twemoji.parse(dis_name); dis_name = twemoji.parse(dis_name);
@ -122,8 +132,7 @@ function udg(user, acct_id) {
Object.keys(json.emojis).forEach(function(key5) { Object.keys(json.emojis).forEach(function(key5) {
var emoji = json.emojis[key5]; var emoji = json.emojis[key5];
var shortcode = emoji.shortcode; var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url + var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" draggable="false">';
'" class="emoji-img" data-emoji="' + shortcode + '" draggable="false">';
var regExp = new RegExp(":" + shortcode + ":", "g"); var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url); dis_name = dis_name.replace(regExp, emoji_url);
note = note.replace(regExp, emoji_url); note = note.replace(regExp, emoji_url);
@ -138,7 +147,7 @@ function udg(user, acct_id) {
$("#his-acct").text(json.acct); $("#his-acct").text(json.acct);
$("#his-acct").attr("fullname", fullname); $("#his-acct").attr("fullname", fullname);
$("#his-prof").attr("src", json.avatar); $("#his-prof").attr("src", json.avatar);
$('#his-data').css('background-image', 'url(' + json.header + ')'); $("#his-data").css("background-image", "url(" + json.header + ")");
$("#his-sta").text(json.statuses_count); $("#his-sta").text(json.statuses_count);
$("#his-follow").text(json.following_count); $("#his-follow").text(json.following_count);
var flerc = json.followers_count; var flerc = json.followers_count;
@ -149,23 +158,23 @@ function udg(user, acct_id) {
$("#his-since").text(crat(json.created_at)); $("#his-since").text(crat(json.created_at));
$("#his-openin").attr("data-href", json.url); $("#his-openin").attr("data-href", json.url);
if (json.fields) { if (json.fields) {
var table ="" var table = "";
if (json.fields.length > 0) { if (json.fields.length > 0) {
$("#his-des").css("max-height", "250px"); $("#his-des").css("max-height", "250px");
table = '<table id="his-field">' table = '<table id="his-field">';
for (var i = 0; i < json.fields.length; i++) { for (var i = 0; i < json.fields.length; i++) {
var fname = json.fields[i].name; var fname = json.fields[i].name;
var fval = json.fields[i].value; var fval = json.fields[i].value;
if (json.fields[i].verified_at) { if (json.fields[i].verified_at) {
var when = lang.lang_showontl_verified + ":" + crat(json.fields[i].verified_at); var when = lang.lang_showontl_verified + ":" + crat(json.fields[i].verified_at);
var color = "rgba(121,189,154,.25);" var color = "rgba(121,189,154,.25);";
} else { } else {
var when = ""; var when = "";
var color = "inherit" var color = "inherit";
} }
table = table + '<tr><td class="his-field-title">' + escapeHTML(fname) + '</td><td class="his-field-content" title="' + when + '" style="background-color:' + color + '">' + fval + '</td></tr>'; table = table + '<tr><td class="his-field-title">' + escapeHTML(fname) + '</td><td class="his-field-content" title="' + when + '" style="background-color:' + color + '">' + fval + "</td></tr>";
} }
table = table + '</table>' table = table + "</table>";
$("#his-des").html(twemoji.parse(note)); $("#his-des").html(twemoji.parse(note));
} else { } else {
$("#his-des").css("max-height", "400px"); $("#his-des").css("max-height", "400px");
@ -179,26 +188,38 @@ function udg(user, acct_id) {
$("#his-bot").html(lang.lang_showontl_botacct); $("#his-bot").html(lang.lang_showontl_botacct);
} }
$("#his-des").attr("data-acct", acct_id); $("#his-des").attr("data-acct", acct_id);
$('#his-data').css('background-size', 'cover'); $("#his-data").css("background-size", "cover");
$("#his-float-timeline").css("height", $("#his-data-show").height() + "px") $("#his-float-timeline").css("height", $("#his-data-show").height() + "px");
localStorage.setItem("history", user); localStorage.setItem("history", user);
//自分の時 //自分の時
if (json.acct == localStorage.getItem("user_" + acct_id)) { if (json.acct == localStorage.getItem("user_" + acct_id)) {
showFav('', acct_id); showFav("", acct_id);
showBlo('', acct_id); showBlo("", acct_id);
showMut('', acct_id); showMut("", acct_id);
showDom('', acct_id); showDom("", acct_id);
showReq('', acct_id); showReq("", acct_id);
showFrl('', acct_id); showFrl("", acct_id);
$("#his-name-val").val(json.display_name); $("#his-name-val").val(json.display_name);
if (json.fields.length > 0) { if (json.fields.length > 0) {
if (json.fields[0]) { $("#his-f1-name").val(json.fields[0].name); $("#his-f1-val").val($.strip_tags(json.fields[0].value)); } if (json.fields[0]) {
if (json.fields[1]) { $("#his-f2-name").val(json.fields[1].name); $("#his-f2-val").val($.strip_tags(json.fields[1].value)); } $("#his-f1-name").val(json.fields[0].name);
if (json.fields[2]) { $("#his-f3-name").val(json.fields[2].name); $("#his-f3-val").val($.strip_tags(json.fields[2].value)); } $("#his-f1-val").val($.strip_tags(json.fields[0].value));
if (json.fields[3]) { $("#his-f4-name").val(json.fields[3].name); $("#his-f4-val").val($.strip_tags(json.fields[3].value)); } }
if (json.fields[1]) {
$("#his-f2-name").val(json.fields[1].name);
$("#his-f2-val").val($.strip_tags(json.fields[1].value));
}
if (json.fields[2]) {
$("#his-f3-name").val(json.fields[2].name);
$("#his-f3-val").val($.strip_tags(json.fields[2].value));
}
if (json.fields[3]) {
$("#his-f4-name").val(json.fields[3].name);
$("#his-f4-val").val($.strip_tags(json.fields[3].value));
}
} }
var des = json.note; var des = json.note;
des = des.replace(/<br \/>/g, "\n") des = des.replace(/<br \/>/g, "\n");
des = $.strip_tags(des); des = $.strip_tags(des);
$("#his-des-val").val(des); $("#his-des-val").val(des);
$("#his-follow-btn").hide(); $("#his-follow-btn").hide();
@ -230,63 +251,67 @@ function misskeyUdg(user, acct_id) {
todo("User Data Loading..."); todo("User Data Loading...");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
udg(user, acct_id) udg(user, acct_id);
return; return;
} }
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/users/show"; var start = "https://" + domain + "/api/users/show";
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
userId: user userId: user
}) })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
//一つ前のユーザーデータ //一つ前のユーザーデータ
if (!localStorage.getItem("history")) { if (!localStorage.getItem("history")) {
$("#his-history-btn").prop("disabled", true); $("#his-history-btn").prop("disabled", true);
} else { } else {
$("#his-history-btn").prop("disabled", false); $("#his-history-btn").prop("disabled", false);
$('#his-data').attr("history", localStorage.getItem("history")); $("#his-data").attr("history", localStorage.getItem("history"));
} }
$('#his-data').modal('open'); $("#his-data").modal("open");
$('#his-data').attr("user-id", user); $("#his-data").attr("user-id", user);
$('#his-data').attr("use-acct", acct_id); $("#his-data").attr("use-acct", acct_id);
if (json.host) { if (json.host) {
//Remote //Remote
$('#his-data').attr("remote", "false"); $("#his-data").attr("remote", "false");
var fullname = json.username + "@" + json.host; var fullname = json.username + "@" + json.host;
} else { } else {
$('#his-data').attr("remote", "false"); $("#his-data").attr("remote", "false");
var fullname = json.acct + "@" + domain; var fullname = json.acct + "@" + domain;
} }
utl(json.id, '', acct_id); utl(json.id, "", acct_id);
flw(json.id, '', acct_id); flw(json.id, "", acct_id);
fer(json.id, '', acct_id); fer(json.id, "", acct_id);
if (json.name) { if (json.name) {
var dis_name = escapeHTML(json.name); var dis_name = escapeHTML(json.name);
dis_name = twemoji.parse(dis_name); dis_name = twemoji.parse(dis_name);
} else { } else {
var dis_name = json.name var dis_name = json.name;
} }
$("#his-name").html(dis_name); $("#his-name").html(dis_name);
$("#his-acct").text(json.username); $("#his-acct").text(json.username);
$("#his-acct").attr("fullname", fullname); $("#his-acct").attr("fullname", fullname);
$("#his-prof").attr("src", json.avatarUrl); $("#his-prof").attr("src", json.avatarUrl);
$('#his-data').css('background-image', 'url(' + json.bannerUrl + ')'); $("#his-data").css("background-image", "url(" + json.bannerUrl + ")");
$("#his-sta").text(json.notesCount); $("#his-sta").text(json.notesCount);
$("#his-follow").text(json.followingCount); $("#his-follow").text(json.followingCount);
$("#his-follower").text(json.followersCount); $("#his-follower").text(json.followersCount);
@ -296,17 +321,17 @@ function misskeyUdg(user, acct_id) {
if (json.isCat) { if (json.isCat) {
$("#his-bot").html("Cat" + twemoji.parse("😺")); $("#his-bot").html("Cat" + twemoji.parse("😺"));
} }
$('#his-data').css('background-size', 'cover'); $("#his-data").css("background-size", "cover");
localStorage.setItem("history", user); localStorage.setItem("history", user);
//自分の時 //自分の時
if (json.username == localStorage.getItem("user_" + acct_id) && !json.host) { if (json.username == localStorage.getItem("user_" + acct_id) && !json.host) {
//showFav('', acct_id); //showFav('', acct_id);
//showMut('', acct_id); //showMut('', acct_id);
//showReq('', acct_id); //showReq('', acct_id);
showFrl('', acct_id); showFrl("", acct_id);
$("#his-name-val").val(json.name); $("#his-name-val").val(json.name);
var des = json.note; var des = json.note;
des = nl2br(des) des = nl2br(des);
des = $.strip_tags(des); des = $.strip_tags(des);
$("#his-des-val").val(des); $("#his-des-val").val(des);
$("#his-follow-btn").hide(); $("#his-follow-btn").hide();
@ -348,15 +373,15 @@ function misskeyUdg(user, acct_id) {
} }
//一つ前のユーザーデータ表示 //一つ前のユーザーデータ表示
function historyShow() { function historyShow() {
var acct_id = $('#his-data').attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
var user = $('#his-data').attr("history"); var user = $("#his-data").attr("history");
udg(user, acct_id, "true") udg(user, acct_id, "true");
} }
//選択アカウントのプロフ //選択アカウントのプロフ
function profShow() { function profShow() {
var acct_id = $("#post-acct-sel").val(); var acct_id = $("#post-acct-sel").val();
var user = localStorage.getItem("user-id_" + acct_id); var user = localStorage.getItem("user-id_" + acct_id);
udg(user, acct_id) udg(user, acct_id);
hide(); hide();
} }
@ -366,22 +391,26 @@ function relations(user, acct_id) {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/relationships?id=" + user; var start = "https://" + domain + "/api/v1/accounts/relationships?id=" + user;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { 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) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
var json = json[0]; var json = json[0];
if (json.following) { if (json.following) {
//自分がフォローしている //自分がフォローしている
@ -422,53 +451,52 @@ function relations(user, acct_id) {
//Endorsed //Endorsed
if (json.endorsed) { if (json.endorsed) {
$("#his-end-btn").addClass("endorsed"); $("#his-end-btn").addClass("endorsed");
$("#his-end-btn-text").text(lang.lang_status_unendorse) $("#his-end-btn-text").text(lang.lang_status_unendorse);
} else { } else {
$("#his-end-btn").removeClass("endorsed"); $("#his-end-btn").removeClass("endorsed");
$("#his-end-btn-text").text(lang.lang_status_endorse) $("#his-end-btn-text").text(lang.lang_status_endorse);
} }
//Blocked //Blocked
if (json.blocked_by) { if (json.blocked_by) {
$("#my-data-nav .btn").addClass("disabled") $("#my-data-nav .btn").addClass("disabled");
$(".his-var-content").hide(); $(".his-var-content").hide();
$("#his-float-blocked").show() $("#his-float-blocked").show();
$("#his-follow-btn").hide() $("#his-follow-btn").hide();
} }
}); });
} }
function profbrws() { function profbrws() {
var url = $("#his-openin").attr("data-href") var url = $("#his-openin").attr("data-href");
postMessage(["openUrl", url], "*") postMessage(["openUrl", url], "*");
} }
function setMain() { function setMain() {
var acct_id = $("#his-data").attr("use-acct") var acct_id = $("#his-data").attr("use-acct");
localStorage.setItem("main", acct_id); localStorage.setItem("main", acct_id);
multiSelector(true) multiSelector(true);
M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 }) M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 });
} }
//オールリセット //オールリセット
function hisclose() { function hisclose() {
$('#his-data').modal('close'); $("#his-data").modal("close");
reset(); reset();
$('#his-data').attr("history", ""); $("#his-data").attr("history", "");
localStorage.removeItem("history"); localStorage.removeItem("history");
} }
function reset() { function reset() {
$(".his-var-content:eq(0)").show(); $(".his-var-content:eq(0)").show();
$(".his-var-content:gt(0)").hide(); $(".his-var-content:gt(0)").hide();
$("#my-data-nav .btn").removeClass("disabled") $("#my-data-nav .btn").removeClass("disabled");
$(".active-back").removeClass("active-back"); $(".active-back").removeClass("active-back");
$(".column-first").addClass("active-back"); $(".column-first").addClass("active-back");
$("#his-name").text("Loading"); $("#his-name").text("Loading");
$("#his-acct").text(""); $("#his-acct").text("");
$("#his-prof").attr("src", "../../img/loading.svg"); $("#his-prof").attr("src", "../../img/loading.svg");
$('#his-data').css('background-image', 'url(../../img/loading.svg)'); $("#his-data").css("background-image", "url(../../img/loading.svg)");
$("#his-sta").text(""); $("#his-sta").text("");
$("#his-follow").text(""); $("#his-follow").text("");
$("#his-follower").text(""); $("#his-follower").text("");
$("#his-des").html(""); $("#his-des").html("");
$('#his-data').css('background-size', 'cover'); $("#his-data").css("background-size", "cover");
$("#his-since").text(""); $("#his-since").text("");
$("#his-data").removeClass("following"); $("#his-data").removeClass("following");
$("#his-data").removeClass("muting"); $("#his-data").removeClass("muting");
@ -493,21 +521,25 @@ function reset() {
$(".cont-series").html(""); $(".cont-series").html("");
$("#domainblock").val(""); $("#domainblock").val("");
$("#his-lists-a").html(lang.lang_showontl_listwarn); $("#his-lists-a").html(lang.lang_showontl_listwarn);
$("#his-lists-b").html(''); $("#his-lists-b").html("");
$("#his-name-val").val(""); $("#his-name-val").val("");
$("#his-des-val").val(""); $("#his-des-val").val("");
$("#his-f1-name").val(""); $("#his-f1-val").val(""); $("#his-f1-name").val("");
$("#his-f2-name").val(""); $("#his-f2-val").val(""); $("#his-f1-val").val("");
$("#his-f3-name").val(""); $("#his-f3-val").val(""); $("#his-f2-name").val("");
$("#his-f4-name").val(""); $("#his-f4-val").val(""); $("#his-f2-val").val("");
$("#his-f3-name").val("");
$("#his-f3-val").val("");
$("#his-f4-name").val("");
$("#his-f4-val").val("");
$("#his-endorse").html(""); $("#his-endorse").html("");
$("#his-openin").attr("data-href", ""); $("#his-openin").attr("data-href", "");
$("#his-float-timeline").show(); $("#his-float-timeline").show();
$("#his-float-blocked").hide(); $("#his-float-blocked").hide();
$("#his-main-acct").show(); $("#his-main-acct").show();
$("#his-proof-prof").html("") $("#his-proof-prof").html("");
} }
$('#my-data-nav .anc-link').on('click', function () { $("#my-data-nav .anc-link").on("click", function() {
var target = $(this).attr("go"); var target = $(this).attr("go");
if (target) { if (target) {
$("#my-data-nav .anc-link").removeClass("active-back"); $("#my-data-nav .anc-link").removeClass("active-back");
@ -515,5 +547,4 @@ $('#my-data-nav .anc-link').on('click', function () {
$(target).show(); $(target).show();
$(".his-var-content:not(" + target + ")").hide(); $(".his-var-content:not(" + target + ")").hide();
} }
}); });

View File

@ -593,7 +593,7 @@
@@useOtherAcct1@@@@revoverJP@@@@follow@@(@@warnUseOtherAcct@@)<br> @@useOtherAcct1@@@@revoverJP@@@@follow@@(@@warnUseOtherAcct@@)<br>
<div style="max-width:500px;"><select id="user-acct-sel" class="acct-sel"></select></div> <div style="max-width:500px;"><select id="user-acct-sel" class="acct-sel"></select></div>
@@revoverJPde@@ @@revoverJPde@@
<a href="#!" class="waves-effect btn" onclick="follow('selector','true')">@@follow@@</a><br> <a href="#!" class="waves-effect btn" onclick="follow('selector','selector')">@@follow@@</a><br>
@@or@@<br> @@or@@<br>
<a href="#!" class="waves-effect btn" <a href="#!" class="waves-effect btn"
onclick="udgEx('selector', 'selector')">@@openProf@@</a><br> onclick="udgEx('selector', 'selector')">@@openProf@@</a><br>