Add: logger

This commit is contained in:
cutls 2019-10-31 00:30:26 +09:00
parent 9f9e4d6d6e
commit 4f7eb88a13
34 changed files with 910 additions and 311 deletions

View File

@ -1,13 +1,13 @@
//バージョンチェッカー //バージョンチェッカー
function verck(ver, jp) { function verck(ver, jp) {
console.log("%c Welcome😊", "color: red;font-size:200%;") console.log("%c Welcome😊", "color: red;font-size:200%;");
var date = new Date(); var date = new Date();
var show = false var show = false;
if (localStorage.getItem("ver") != ver && localStorage.getItem("winstore")) { if (localStorage.getItem("ver") != ver && localStorage.getItem("winstore")) {
//ちょっと削除とリンク解析の都合上アレ(s) //ちょっと削除とリンク解析の都合上アレ(s)
//対象外のアプデ:storageが20の最初まで"Usamin (18.6.5)" //対象外のアプデ:storageが20の最初まで"Usamin (18.6.5)"
if (!localStorage.getItem("usamin_18_6_5_flag")) { if (!localStorage.getItem("usamin_18_6_5_flag")) {
localStorage.setItem("usamin_18_6_5_flag", true) localStorage.setItem("usamin_18_6_5_flag", true);
var multi = localStorage.getItem("column"); var multi = localStorage.getItem("column");
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
for (var i = 0; i < obj.length; i++) { for (var i = 0; i < obj.length; i++) {
@ -15,19 +15,19 @@ function verck(ver, jp) {
} }
} }
//ちょっと削除とリンク解析の都合上アレ(e) //ちょっと削除とリンク解析の都合上アレ(e)
show = true show = true;
console.log("%c Thank you for your update🎉", "color: red;font-size:200%;"); console.log("%c Thank you for your update🎉", "color: red;font-size:200%;");
$(document).ready(function() { $(document).ready(function() {
if (localStorage.getItem("winstore")) { if (localStorage.getItem("winstore")) {
$('#releasenote').modal('open'); $("#releasenote").modal("open");
} }
verp = ver.replace('(', ''); verp = ver.replace("(", "");
verp = verp.replace('.', '-'); verp = verp.replace(".", "-");
verp = verp.replace('.', '-'); verp = verp.replace(".", "-");
verp = verp.replace('[', '-'); verp = verp.replace("[", "-");
verp = verp.replace(']', ''); verp = verp.replace("]", "");
verp = verp.replace(')', ''); verp = verp.replace(")", "");
verp = verp.replace(' ', '_'); verp = verp.replace(" ", "_");
console.log("%c " + verp, "color: red;font-size:200%;"); console.log("%c " + verp, "color: red;font-size:200%;");
if (lang.language == "ja") { if (lang.language == "ja") {
$("#release-" + verp).show(); $("#release-" + verp).show();
@ -38,30 +38,33 @@ function verck(ver, jp) {
} }
localStorage.setItem("ver", ver); localStorage.setItem("ver", ver);
if (!show) { if (!show) {
console.log(show) console.log(show);
if (date.getMonth() + 1 >= localStorage.getItem("showSupportMe") || !localStorage.getItem("showSupportMe")) { if (date.getMonth() + 1 >= localStorage.getItem("showSupportMe") || !localStorage.getItem("showSupportMe")) {
if (date.getMonth() == 11) { if (date.getMonth() == 11) {
var nextmonth = 1 var nextmonth = 1;
} else { } else {
var nextmonth = date.getMonth() + 2 var nextmonth = date.getMonth() + 2;
} }
if (lang.language != "ja") { if (lang.language != "ja") {
$("#support-btm-ja").addClass("hide"); $("#support-btm-ja").addClass("hide");
$("#support-btm-en").removeClass("hide"); $("#support-btm-en").removeClass("hide");
} }
localStorage.setItem("showSupportMe", nextmonth) localStorage.setItem("showSupportMe", nextmonth);
$("#support-btm").removeClass("hide") $("#support-btm").removeClass("hide");
$("#support-btm").animate({ $("#support-btm").animate(
'bottom': '0' {
}, { bottom: "0"
'duration': 300 },
}); {
duration: 300
}
);
} }
} }
var platform = localStorage.getItem("platform"); var platform = localStorage.getItem("platform");
console.log("Your platform:" + platform) console.log("Your platform:" + platform);
if (!localStorage.getItem("winstore")) { if (!localStorage.getItem("winstore")) {
$("#start").css('display', 'flex'); $("#start").css("display", "flex");
} }
if (localStorage.getItem("winstore") == "brewcask" || localStorage.getItem("winstore") == "snapcraft" || localStorage.getItem("winstore") == "winstore") { if (localStorage.getItem("winstore") == "brewcask" || localStorage.getItem("winstore") == "snapcraft" || localStorage.getItem("winstore") == "winstore") {
var winstore = true; var winstore = true;
@ -78,19 +81,27 @@ function verck(ver, jp) {
} }
var start = "https://thedesk.top/ver.json"; var start = "https://thedesk.top/ver.json";
fetch(start, { fetch(start, {
method: 'GET' method: "GET"
}).then(function (response) { })
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
console.error(error); console.error(error);
}).then(function (mess) { })
.then(function(mess) {
console.table(mess); console.table(mess);
if (mess) { if (mess) {
//askjp_jp_ua: 2019年10月24日、mstdn.jpによるユーザーエージェントアクセス制限 //askjp_jp_ua: 2019年10月24日、mstdn.jpによるユーザーエージェントアクセス制限
if (jp && mess.jp_ua && !localStorage.getItem("askjp_jp_ua")) { if (jp && mess.jp_ua && !localStorage.getItem("askjp_jp_ua")) {
localStorage.setItem("askjp_jp_ua", true) localStorage.setItem("askjp_jp_ua", true);
$("#askjp_jp_ua").removeClass("hide") $("#askjp_jp_ua").removeClass("hide");
} }
var platform = localStorage.getItem("platform"); var platform = localStorage.getItem("platform");
if (platform == "darwin") { if (platform == "darwin") {
@ -102,39 +113,46 @@ function verck(ver, jp) {
todo(lang.lang_version_usever.replace("{{ver}}", mess.desk)); todo(lang.lang_version_usever.replace("{{ver}}", mess.desk));
//betaかWinstoreならアプデチェックしない //betaかWinstoreならアプデチェックしない
} else if (ver.indexOf("beta") != -1 || winstore) { } else if (ver.indexOf("beta") != -1 || winstore) {
} else { } else {
localStorage.removeItem("instance") localStorage.removeItem("instance");
if (localStorage.getItem("new-ver-skip")) { if (localStorage.getItem("new-ver-skip")) {
if (localStorage.getItem("next-ver") != newest) { if (localStorage.getItem("next-ver") != newest) {
postMessage(["sendSinmpleIpc", "update"], "*") postMessage(["sendSinmpleIpc", "update"], "*");
} else { } else {
console.warn(lang.lang_version_skipver); console.warn(lang.lang_version_skipver);
todo(lang.lang_version_skipver); todo(lang.lang_version_skipver);
} }
} else { } else {
postMessage(["sendSinmpleIpc", "update"], "*") postMessage(["sendSinmpleIpc", "update"], "*");
} }
} }
} }
}); });
if (!localStorage.getItem("last-notice-id")) { if (!localStorage.getItem("last-notice-id")) {
localStorage.setItem("last-notice-id", 0) localStorage.setItem("last-notice-id", 0);
} }
var start = "https://thedesk.top/notice?since_id=" + localStorage.getItem("last-notice-id"); var start = "https://thedesk.top/notice?since_id=" + localStorage.getItem("last-notice-id");
fetch(start, { fetch(start, {
method: 'GET' method: "GET"
}).then(function (response) { })
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
console.error(error); console.error(error);
}).then(function (mess) { })
.then(function(mess) {
if (mess.length < 1) { if (mess.length < 1) {
return false; return false;
} else { } else {
var last = localStorage.getItem("last-notice-id") var last = localStorage.getItem("last-notice-id");
localStorage.setItem("last-notice-id", mess[0].ID) localStorage.setItem("last-notice-id", mess[0].ID);
for (i = 0; i < mess.length; i++) { for (i = 0; i < mess.length; i++) {
var obj = mess[i]; var obj = mess[i];
if (obj.ID * 1 <= last) { if (obj.ID * 1 <= last) {
@ -144,7 +162,7 @@ function verck(ver, jp) {
if (~obj.languages.indexOf(lang.language)) { if (~obj.languages.indexOf(lang.language)) {
var show = true; var show = true;
if (obj.toot != "") { if (obj.toot != "") {
var toot = '<button class="btn-flat toast-action" onclick="detEx(\'' + obj.toot + '\',\'main\')">Show</button>'; var toot = '<button class="btn-flat toast-action" onclick="detEx(\'' + obj.toot + "','main')\">Show</button>";
} else { } else {
var toot = ""; var toot = "";
} }
@ -169,12 +187,11 @@ function verck(ver, jp) {
} }
} }
if (show) { if (show) {
M.toast({ html: escapeHTML(obj.text) + toot + '<span class="sml grey-text">(スライドして消去)</span>', displayLength: 86400 }) M.toast({ html: escapeHTML(obj.text) + toot + '<span class="sml grey-text">(スライドして消去)</span>', displayLength: 86400 });
} }
} }
} }
} }
} }
} }
}); });
@ -185,17 +202,17 @@ function infowebsocket() {
infows.onopen = function(mess) { infows.onopen = function(mess) {
console.log([tlid, ":Connect Streaming Info:", mess]); console.log([tlid, ":Connect Streaming Info:", mess]);
infostreaming = true; infostreaming = true;
} };
infows.onmessage = function(mess) { infows.onmessage = function(mess) {
console.log([tlid, ":Receive Streaming:", JSON.parse(mess.data)]); console.log([tlid, ":Receive Streaming:", JSON.parse(mess.data)]);
var obj = JSON.parse(mess.data); var obj = JSON.parse(mess.data);
if (obj.type != "counter") { if (obj.type != "counter") {
if (obj.type == "textv2") { if (obj.type == "textv2") {
if (~obj.languages.indexOf(lang.language)) { if (~obj.languages.indexOf(lang.language)) {
localStorage.setItem("last-notice-id", obj.id) localStorage.setItem("last-notice-id", obj.id);
var show = true; var show = true;
if (obj.toot != "") { if (obj.toot != "") {
var toot = '<button class="btn-flat toast-action" onclick="detEx(\'' + obj.toot + '\',\'main\')">Show</button>'; var toot = '<button class="btn-flat toast-action" onclick="detEx(\'' + obj.toot + "','main')\">Show</button>";
} else { } else {
var toot = ""; var toot = "";
} }
@ -220,16 +237,16 @@ function infowebsocket() {
} }
} }
if (show) { if (show) {
console.log(obj.text) console.log(obj.text);
console.log(escapeHTML(obj.text)) console.log(escapeHTML(obj.text));
M.toast({ html: escapeHTML(obj.text) + toot + '<span class="sml grey-text">(スライドして消去)</span>', displayLength: 86400 }) M.toast({ html: escapeHTML(obj.text) + toot + '<span class="sml grey-text">(スライドして消去)</span>', displayLength: 86400 });
} }
} }
} }
} else { } else {
$("#persons").text(obj.text); $("#persons").text(obj.text);
} }
} };
infows.onerror = function(error) { infows.onerror = function(error) {
infostreaming = false; infostreaming = false;
console.error("Error closing:info"); console.error("Error closing:info");
@ -243,34 +260,37 @@ function infowebsocket() {
} }
setInterval(function() { setInterval(function() {
if (!infostreaming) { if (!infostreaming) {
console.log("try to connect to base-streaming") console.log("try to connect to base-streaming");
infowebsocket(); infowebsocket();
} }
}, 10000); }, 10000);
function openRN() { function openRN() {
$('#releasenote').modal('open'); $("#releasenote").modal("open");
if (lang.language == "ja") { if (lang.language == "ja") {
verp = ver.replace('(', ''); verp = ver.replace("(", "");
verp = verp.replace('.', '-'); verp = verp.replace(".", "-");
verp = verp.replace('.', '-'); verp = verp.replace(".", "-");
verp = verp.replace('[', '-'); verp = verp.replace("[", "-");
verp = verp.replace(']', ''); verp = verp.replace("]", "");
verp = verp.replace(')', ''); verp = verp.replace(")", "");
verp = verp.replace(' ', '_'); verp = verp.replace(" ", "_");
$("#release-" + verp).show(); $("#release-" + verp).show();
} else { } else {
$("#release-en").show(); $("#release-en").show();
} }
} }
function closeSupport() { function closeSupport() {
$("#support-btm").animate({ $("#support-btm").animate(
'bottom': '-300px' {
}, { bottom: "-300px"
'duration': 300, },
'complete': function () { {
$("#support-btm").addClass("hide") duration: 300,
complete: function() {
$("#support-btm").addClass("hide");
} }
}); }
);
} }
function storeDialog(platform, ver) { function storeDialog(platform, ver) {
if (platform == "win32") { if (platform == "win32") {
@ -283,31 +303,31 @@ function storeDialog(platform, ver) {
Swal.fire({ Swal.fire({
title: "Select your platform", title: "Select your platform",
text: mes, text: mes,
type: 'info', type: "info",
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: "#3085d6",
cancelButtonColor: '#3085d6', cancelButtonColor: "#3085d6",
confirmButtonText: lang.lang_no, confirmButtonText: lang.lang_no,
cancelButtonText: lang.lang_yesno cancelButtonText: lang.lang_yesno
}).then((result) => { }).then(result => {
//逆にしてる //逆にしてる
if (!result.value) { if (!result.value) {
localStorage.setItem("winstore", "winstore") localStorage.setItem("winstore", "winstore");
} else { } else {
localStorage.setItem("winstore", "localinstall") localStorage.setItem("winstore", "localinstall");
} }
localStorage.setItem("ver", ver); localStorage.setItem("ver", ver);
show = true show = true;
console.log("%c Thank you for your update🎉", "color: red;font-size:200%;"); console.log("%c Thank you for your update🎉", "color: red;font-size:200%;");
$(document).ready(function() { $(document).ready(function() {
$('#releasenote').modal('open'); $("#releasenote").modal("open");
verp = ver.replace('(', ''); verp = ver.replace("(", "");
verp = verp.replace('.', '-'); verp = verp.replace(".", "-");
verp = verp.replace('.', '-'); verp = verp.replace(".", "-");
verp = verp.replace('[', '-'); verp = verp.replace("[", "-");
verp = verp.replace(']', ''); verp = verp.replace("]", "");
verp = verp.replace(')', ''); verp = verp.replace(")", "");
verp = verp.replace(' ', '_'); verp = verp.replace(" ", "_");
console.log("%c " + verp, "color: red;font-size:200%;"); console.log("%c " + verp, "color: red;font-size:200%;");
if (lang.language == "ja") { if (lang.language == "ja") {
$("#release-" + verp).show(); $("#release-" + verp).show();
@ -315,11 +335,11 @@ function storeDialog(platform, ver) {
$("#release-en").show(); $("#release-en").show();
} }
}); });
}) });
} }
function closeStart() { function closeStart() {
$("#start").css('display', 'none'); $("#start").css("display", "none");
var platform = localStorage.getItem("platform"); var platform = localStorage.getItem("platform");
var ver = localStorage.getItem("ver"); var ver = localStorage.getItem("ver");
storeDialog(platform, ver) storeDialog(platform, ver);
} }

View File

@ -76,6 +76,7 @@ function login(url) {
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); }
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[ var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
"client_id"] + "&client_secret=" + json["client_secret"] + "client_id"] + "&client_secret=" + json["client_secret"] +
"&response_type=code&redirect_uri=" + red + "&scope=read+write+follow"; "&response_type=code&redirect_uri=" + red + "&scope=read+write+follow";
@ -129,6 +130,11 @@ function code(code, mode) {
code: code code: code
}) })
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -160,6 +166,11 @@ function getdata() {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -207,6 +218,11 @@ function getdataAdv(domain, at) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -265,6 +281,11 @@ function refresh(target, loadskip) {
'Authorization': 'Bearer ' + obj[target].at 'Authorization': 'Bearer ' + obj[target].at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -531,6 +552,11 @@ function ticker() {
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
console.error(error); console.error(error);

View File

@ -85,6 +85,11 @@ function data(domain) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -114,6 +119,11 @@ function data(domain) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -320,6 +330,7 @@ function login(url) {
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); }
localStorage.setItem("msky", "false"); localStorage.setItem("msky", "false");
var auth = "https://" + url + "/oauth/authorize?client_id=" + json["client_id"] + "&client_secret=" + json["client_secret"] + "&response_type=code&scope=read+write+follow&redirect_uri=" + encodeURIComponent(red); var auth = "https://" + url + "/oauth/authorize?client_id=" + json["client_id"] + "&client_secret=" + json["client_secret"] + "&response_type=code&scope=read+write+follow&redirect_uri=" + encodeURIComponent(red);
localStorage.setItem("domain_tmp", url); localStorage.setItem("domain_tmp", url);
@ -345,6 +356,11 @@ function versionChecker(url) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -378,6 +394,11 @@ function versionCompat(prefix, ver, title, real) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -437,6 +458,7 @@ function misskeyLogin(url) {
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); }
misskeyAuth(url, json.secret); misskeyAuth(url, json.secret);
} }
}; };
@ -458,6 +480,7 @@ function misskeyAuth(url, mkc) {
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); }
var token = json.token; var token = json.token;
$("#auth").show(); $("#auth").show();
$("#code").val(token); $("#code").val(token);
@ -488,7 +511,7 @@ function code(code) {
} }
if (!code || code == "") { if (!code || code == "") {
M.toast({ html: lang.lang_fatalerroroccured + "Error: no code", displayLength: 5000 }); M.toast({ html: lang.lang_fatalerroroccured + "Error: no code", displayLength: 5000 });
return false return false;
} }
var url = localStorage.getItem("domain_tmp"); var url = localStorage.getItem("domain_tmp");
localStorage.removeItem("domain_tmp"); localStorage.removeItem("domain_tmp");
@ -507,6 +530,7 @@ function code(code) {
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); }
var i = sha256(json.accessToken + localStorage.getItem("mkc")); var i = sha256(json.accessToken + localStorage.getItem("mkc"));
var avatar = json["user"]["avatarUrl"]; var avatar = json["user"]["avatarUrl"];
var priv = "public"; var priv = "public";
@ -563,6 +587,7 @@ function code(code) {
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 (json["access_token"]) { if (json["access_token"]) {
$("#auth").hide(); $("#auth").hide();
$("#add").show(); $("#add").show();
@ -583,6 +608,11 @@ function getdata(domain, at) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -666,7 +696,7 @@ function atSetup(type) {
} }
if (!i || i == "") { if (!i || i == "") {
M.toast({ html: lang.lang_fatalerroroccured + "Error: access token", displayLength: 5000 }); M.toast({ html: lang.lang_fatalerroroccured + "Error: access token", displayLength: 5000 });
return false return false;
} }
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
var target = obj.length; var target = obj.length;
@ -684,7 +714,7 @@ function atSetup(type) {
function refresh(target) { function refresh(target) {
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem("multi");
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
console.log(obj) console.log(obj);
if (obj[target].mode == "misskey") { if (obj[target].mode == "misskey") {
misskeyRefresh(obj, target, obj[target].domain); misskeyRefresh(obj, target, obj[target].domain);
return; return;
@ -698,6 +728,16 @@ function refresh(target) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -755,6 +795,7 @@ function misskeyRefresh(obj, target, url) {
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); }
var avatar = json["user"]["avatarUrl"]; var avatar = json["user"]["avatarUrl"];
var priv = "public"; var priv = "public";
var add = { var add = {
@ -879,6 +920,11 @@ input.addEventListener(
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {

View File

@ -196,4 +196,19 @@ function object_array_sort(data, key, order, fn) {
} }
fn(data); fn(data);
} }
localStorage.removeItem("errors"); function setLog(txt1, txt2,txt3){
//url,statuscode,responsetext
var text = new Date().toUTCString()
text=text+","+txt1+","+txt2+","+escapeCsv(txt3)
console.error(text)
postMessage(["log", text], "*")
}
function escapeCsv(str) {
if(!str){return str;}
var result;
result = str.replace(/\"/g, "\"\"");
if (result.indexOf(",") >= 0) {
result = "\"" + result + "\""
}
return result;
}

View File

@ -25,6 +25,11 @@ function tl(data) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
console.error(error); console.error(error);
@ -199,6 +204,7 @@ function post() {
httpreq.send(JSON.stringify(toot)); httpreq.send(JSON.stringify(toot));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
$("#textarea").val(""); $("#textarea").val("");
} }
}; };

View File

@ -63,6 +63,8 @@ onmessage = function(e) {
ipc.send("sendMarkersComplete", null); ipc.send("sendMarkersComplete", null);
} else if (e.data[0] == "copy") { } else if (e.data[0] == "copy") {
ipc.send("copy", e.data[1]); ipc.send("copy", e.data[1]);
} else if (e.data[0] == "log") {
ipc.send("log", e.data[1]);
} }
}; };
//version.js //version.js

View File

@ -62,6 +62,11 @@ function emojiGet(parse, started) {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -133,6 +138,11 @@ function emojiGet(parse, started) {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -118,6 +118,7 @@ function media(b64, type, no) {
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 (!json.id) { if (!json.id) {
todc(); todc();
$("#imgup").text(""); $("#imgup").text("");
@ -267,6 +268,11 @@ function altImage(acct_id, id) {
}) })
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {

View File

@ -17,6 +17,7 @@ function renote(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); }
console.log(["Success: renote", json]); console.log(["Success: renote", json]);
$("[toot-id=" + id + "]").addClass("rted"); $("[toot-id=" + id + "]").addClass("rted");
$(".rt_" + id).toggleClass("teal-text"); $(".rt_" + id).toggleClass("teal-text");
@ -63,6 +64,7 @@ function reactiontoggle(id, acct_id, tlid) {
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); }
console.log(["Success: reaction", json]); console.log(["Success: reaction", json]);
if (json.reactions) { if (json.reactions) {
var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"]; var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"];
@ -123,6 +125,11 @@ function reactRefresh(acct_id, id) {
} }
fetch(start, i, fetch(start, i,
).then(function (response) { ).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -186,6 +193,7 @@ function reaction(mode, id, acct_id, tlid) {
httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode })); httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode }));
httpreq.onreadystatechange = function () { httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
$(".fav_" + id).toggleClass("yellow-text"); $(".fav_" + id).toggleClass("yellow-text");
} }
} }
@ -219,6 +227,7 @@ function voterefresh(acct_id, id) {
httpreqd.onreadystatechange = function () { httpreqd.onreadystatechange = function () {
if (httpreqd.readyState == 4) { if (httpreqd.readyState == 4) {
var json = httpreqd.response; var json = httpreqd.response;
if(this.status!==200){ setLog(start, this.status, json); }
if (!json) { if (!json) {
return false; return false;
} }

View File

@ -153,6 +153,7 @@ function post(mode, postvis) {
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); }
var box = localStorage.getItem("box"); var box = localStorage.getItem("box");
if (box == "yes" || !box) { if (box == "yes" || !box) {
$("#textarea").blur(); $("#textarea").blur();
@ -224,6 +225,7 @@ function misskeyPost() {
localStorage.removeItem("stable") localStorage.removeItem("stable")
} }
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); }
console.log(["Success: toot", json]); console.log(["Success: toot", json]);
var box = localStorage.getItem("box"); var box = localStorage.getItem("box");
if (box == "yes") { if (box == "yes") {

View File

@ -18,6 +18,7 @@ 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 (json.reblog) { if (json.reblog) {
json = json.reblog; json = json.reblog;
} }
@ -75,6 +76,7 @@ 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 (json.reblog) { if (json.reblog) {
json = json.reblog; json = json.reblog;
} }
@ -147,6 +149,7 @@ 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); }
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");
@ -194,6 +197,7 @@ 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 ($("#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);
@ -251,6 +255,7 @@ 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 ($("#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);
@ -288,6 +293,7 @@ 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); }
} }
}; };
} }
@ -362,6 +368,7 @@ 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); }
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");
@ -389,6 +396,7 @@ 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); }
console.log(["Success: request", "type:" + flag, json]); console.log(["Success: request", "type:" + flag, json]);
showReq(); showReq();
} }
@ -412,6 +420,7 @@ 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); }
console.log(["Success: domain block", json]); console.log(["Success: domain block", json]);
showDom(); showDom();
} }
@ -468,6 +477,7 @@ 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 ($("#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);
@ -499,6 +509,11 @@ function staEx(mode) {
} }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {

View File

@ -113,6 +113,11 @@ input.addEventListener("focus", function () {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -258,6 +263,11 @@ function cgNPs(q) {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -60,6 +60,11 @@ function additional(acct_id, tlid) {
}, },
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -88,6 +93,7 @@ function additional(acct_id, tlid) {
if (this.readyState === 4 && this.status === 200) { if (this.readyState === 4 && this.status === 200) {
if (this.response) { if (this.response) {
var json = this.response; var json = this.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
var emojis = json.emojis; var emojis = json.emojis;
for (i = 0; i < emojis.length; i++) { for (i = 0; i < emojis.length; i++) {
var emojie = emojis[i]; var emojie = emojis[i];
@ -144,6 +150,11 @@ function additionalIndv(tlid, acct_id, id) {
}, },
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -168,6 +179,11 @@ function additionalIndv(tlid, acct_id, id) {
}, },
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -35,6 +35,11 @@ function details(id, acct_id, tlid, mode) {
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -131,6 +136,11 @@ function replyTL(id, acct_id) {
return false return false
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -183,6 +193,11 @@ function getContext(id, acct_id) {
} }
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -241,6 +256,11 @@ function beforeToot(id, acct_id, domain) {
untilID: id untilID: id
}) })
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -259,6 +279,11 @@ function beforeToot(id, acct_id, domain) {
'content-type': 'application/json', 'content-type': 'application/json',
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -291,6 +316,11 @@ function userToot(id, acct_id, user) {
userId: user userId: user
}) })
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -309,6 +339,11 @@ function userToot(id, acct_id, user) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -336,6 +371,11 @@ function afterToot(id, acct_id, domain) {
'content-type': 'application/json', 'content-type': 'application/json',
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -361,6 +401,11 @@ function afterUserToot(id, acct_id, user) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -386,6 +431,11 @@ function afterFTLToot(id, acct_id, domain) {
'content-type': 'application/json', 'content-type': 'application/json',
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -413,6 +463,11 @@ function faved(id, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -440,6 +495,11 @@ function rted(id, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -500,6 +560,11 @@ function trans(tar, to) {
fetch(exec, { fetch(exec, {
method: 'GET', method: 'GET',
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -528,6 +593,11 @@ function detEx(url, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
} }
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -51,6 +51,11 @@ function directory(isMore) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
//todo(error); //todo(error);

View File

@ -11,6 +11,11 @@ function dm(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -43,6 +48,11 @@ function dmmore(tlid) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -121,6 +121,11 @@ function filter() {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -199,6 +204,7 @@ function makeNewFilter() {
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); }
filter(); filter();
filterUpdate(acct_id) filterUpdate(acct_id)
$("#filter-add-word").val(""); $("#filter-add-word").val("");
@ -239,6 +245,11 @@ function filterEdit(id, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -282,6 +293,7 @@ function filterDel(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); }
filter(); filter();
filterUpdate(acct_id) filterUpdate(acct_id)
} }
@ -299,6 +311,11 @@ function getFilter(acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -342,6 +359,11 @@ function filterUpdate(acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -21,6 +21,11 @@ function list() {
i: at i: at
}), }),
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -47,6 +52,11 @@ function list() {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -85,6 +95,7 @@ function makeNewList() {
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); }
list(); list();
$("#list-add").val("") $("#list-add").val("")
} }
@ -102,6 +113,7 @@ function makeNewList() {
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); }
list(); list();
$("#list-add").val("") $("#list-add").val("")
} }
@ -123,6 +135,11 @@ function listUser(id, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -153,6 +170,11 @@ function hisList(user, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -178,6 +200,11 @@ function hisList(user, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -203,6 +230,11 @@ function hisList(user, acct_id) {
i: at i: at
}), }),
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -249,6 +281,7 @@ function listAdd(id, user, 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); }
hisList(user, acct_id) hisList(user, acct_id)
} }
} }
@ -280,6 +313,7 @@ function listRemove(id, user, 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); }
hisList(user, acct_id) hisList(user, acct_id)
} }
} }

View File

@ -14,6 +14,11 @@ function mixtl(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -27,6 +32,11 @@ function mixtl(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -267,6 +277,11 @@ function mixmore(tlid, type) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -280,6 +295,11 @@ function mixmore(tlid, type) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -43,6 +43,7 @@ function notfColumn(acct_id, tlid, sys) {
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); }
var max_id = httpreq.getResponseHeader("link"); var max_id = httpreq.getResponseHeader("link");
if (max_id) { if (max_id) {
max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1] max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1]
@ -152,6 +153,11 @@ function notfCommon(acct_id, tlid, sys) {
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
console.log("header to get param:" + response.headers.get('link')); console.log("header to get param:" + response.headers.get('link'));
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -317,6 +323,7 @@ function notfmore(tlid) {
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); }
console.log(["More notifications on " + tlid, json]); console.log(["More notifications on " + tlid, json]);
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1]; var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1];
if (json[0]) { if (json[0]) {

View File

@ -15,6 +15,11 @@ function mixtl(acct_id, tlid) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function(response) { }).then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function(error) { }).catch(function(error) {
todo(error); todo(error);
@ -38,6 +43,11 @@ function mixtl(acct_id, tlid) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function(response) { }).then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function(error) { }).catch(function(error) {
todo(error); todo(error);
@ -193,6 +203,11 @@ function mixmore(tlid) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function(response) { }).then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function(error) { }).catch(function(error) {
todo(error); todo(error);
@ -211,6 +226,11 @@ function mixmore(tlid) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function(response) { }).then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function(error) { }).catch(function(error) {
todo(error); todo(error);

View File

@ -114,6 +114,7 @@ function voteMastodonrefresh(acct_id, id) {
httpreqd.send(); httpreqd.send();
httpreqd.onreadystatechange = function () { httpreqd.onreadystatechange = function () {
if (httpreqd.readyState == 4) { if (httpreqd.readyState == 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
var json = httpreqd.response; var json = httpreqd.response;
console.log(["Refresh vote", json]); console.log(["Refresh vote", json]);
if (!json) { if (!json) {

View File

@ -46,6 +46,11 @@ function src(mode, offset) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
src("v1") src("v1")
@ -110,6 +115,11 @@ function tootsearch(tlid, q) {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -149,6 +159,11 @@ function moreTs(tlid, q) {
'content-type': 'application/json' 'content-type': 'application/json'
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -223,6 +238,11 @@ function trend() {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
//todo(error); //todo(error);

View File

@ -87,6 +87,11 @@ function trendTag() {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -143,6 +148,11 @@ function tagFeature(name, acct_id){
name: name name: name
}) })
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
return false; return false;

View File

@ -128,6 +128,11 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
console.log(["Try to get timeline of " + tlid, start]) console.log(["Try to get timeline of " + tlid, start])
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -438,6 +443,11 @@ function moreload(type, tlid) {
}; };
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -551,6 +561,11 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -897,6 +912,11 @@ function getMarker(tlid, type, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
$("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing) $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing)
@ -940,6 +960,11 @@ function showUnread(tlid, type, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -991,6 +1016,11 @@ function ueload(tlid) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -1062,6 +1092,7 @@ function asRead(callback) {
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); }
console.log(json) console.log(json)
ct++ ct++
if (ct == obl && callback) { if (ct == obl && callback) {

View File

@ -727,6 +727,11 @@ function checkupd(){
fetch(start, { fetch(start, {
method: 'GET' method: 'GET'
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -66,6 +66,11 @@ function nowplaying(mode) {
'content-type': 'application/json' 'content-type': 'application/json'
} }
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -66,6 +66,11 @@ function trendTagonTip() {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -96,6 +101,11 @@ function spotifytips() {
'content-type': 'application/json' 'content-type': 'application/json'
} }
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -42,6 +42,11 @@ function utl(user, more, acct_id) {
} }
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -87,6 +92,11 @@ function pinutl(before, user, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -144,6 +154,11 @@ function flw(user, more, acct_id) {
} }
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -210,6 +225,11 @@ function fer(user, more, acct_id) {
} }
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -272,6 +292,11 @@ function showFav(more, acct_id) {
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -333,6 +358,11 @@ function showMut(more, acct_id) {
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -376,6 +406,11 @@ function showBlo(more, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -433,6 +468,11 @@ function showReq(more, acct_id) {
} }
} }
fetch(start, i).then(function (response) { fetch(start, i).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -483,6 +523,11 @@ function showDom(more, acct_id) {
}, },
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -533,6 +578,11 @@ function showFrl(more, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(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>");
@ -566,6 +616,11 @@ function udAdd(acct_id, id, start) {
}, },
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -583,6 +638,11 @@ function udAdd(acct_id, id, start) {
'Accept': 'application/json' 'Accept': 'application/json'
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -612,6 +672,11 @@ function showMat() {
}, },
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -52,6 +52,7 @@ function imgChange(imgfile, target) {
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); }
$('#his-data').modal('close'); $('#his-data').modal('close');
todc(); todc();
localStorage.removeItem("image"); localStorage.removeItem("image");

View File

@ -31,6 +31,11 @@ function udgEx(user, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
} }
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -65,6 +70,11 @@ function udg(user, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -235,6 +245,11 @@ function misskeyUdg(user, acct_id) {
userId: user userId: user
}) })
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);
@ -357,6 +372,11 @@ function relations(user, acct_id) {
'Authorization': 'Bearer ' + at 'Authorization': 'Bearer ' + at
}, },
}).then(function (response) { }).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}).catch(function (error) { }).catch(function (error) {
todo(error); todo(error);

View File

@ -194,7 +194,9 @@ function createWindow() {
// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) thedesk/18.11.3 Chrome/76.0.3809.146 Electron/6.0.12 Safari/537.36 // Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) thedesk/18.11.3 Chrome/76.0.3809.146 Electron/6.0.12 Safari/537.36
const crypto = require("crypto"); const crypto = require("crypto");
const N = 100; const N = 100;
var ua = "Mastodon client: "+crypto var ua =
"Mastodon client: " +
crypto
.randomBytes(N) .randomBytes(N)
.toString("base64") .toString("base64")
.substring(0, N); .substring(0, N);

View File

@ -1,116 +1,126 @@
function system(mainWindow, dir, lang, dirname) { function system(mainWindow, dir, lang, dirname) {
const electron = require("electron"); const electron = require("electron");
const app = electron.app; const app = electron.app;
const join = require('path').join; const join = require("path").join;
var Jimp = require("jimp"); var Jimp = require("jimp");
const fs = require("fs"); const fs = require("fs");
var JSON5 = require('json5'); var JSON5 = require("json5");
var ipc = electron.ipcMain; var ipc = electron.ipcMain;
const clipboard = electron.clipboard; const clipboard = electron.clipboard;
var tmp_img = join(app.getPath("userData"), "tmp.png"); var tmp_img = join(app.getPath("userData"), "tmp.png");
var ha_path = join(app.getPath("userData"), "hardwareAcceleration"); var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
var ua_path = join(app.getPath("userData"), "useragent"); var ua_path = join(app.getPath("userData"), "useragent");
var lang_path = join(app.getPath("userData"), "language"); var lang_path = join(app.getPath("userData"), "language");
var log_dir_path = join(app.getPath("userData"), "logs");
const BrowserWindow = electron.BrowserWindow; const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog; const dialog = electron.dialog;
const os = require('os') const os = require("os");
const language = require("../main/language.js"); const language = require("../main/language.js");
//プラットフォーム //プラットフォーム
ipc.on('getPlatform', function (e, arg) { ipc.on("getPlatform", function(e, arg) {
try { try {
var gitHash = fs.readFileSync("git", 'utf8') var gitHash = fs.readFileSync("git", "utf8");
} catch { } catch {
var gitHash = null var gitHash = null;
} }
e.sender.webContents.send('platform', [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]); e.sender.webContents.send("platform", [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]);
}) });
//言語 //言語
ipc.on('lang', function (e, arg) { ipc.on("lang", function(e, arg) {
console.log("set:" + arg); console.log("set:" + arg);
fs.writeFileSync(lang_path, arg); fs.writeFileSync(lang_path, arg);
e.sender.webContents.send('langres', arg); e.sender.webContents.send("langres", arg);
}) });
//エクスポートのダイアログ //エクスポートのダイアログ
ipc.on('exportSettings', function (e, args) { ipc.on("exportSettings", function(e, args) {
dialog.showSaveDialog(null, { dialog.showSaveDialog(
title: 'Export', null,
properties: ['openFile', 'createDirectory'], {
title: "Export",
properties: ["openFile", "createDirectory"],
defaultPath: "export.thedeskconfig.json5" defaultPath: "export.thedeskconfig.json5"
}, (savedFiles) => { },
savedFiles => {
if (!savedFiles) { if (!savedFiles) {
return false; return false;
} }
e.sender.webContents.send('exportSettingsFile', savedFiles); e.sender.webContents.send("exportSettingsFile", savedFiles);
}) }
}) );
});
//インポートのダイアログ //インポートのダイアログ
ipc.on('importSettings', function (e, args) { ipc.on("importSettings", function(e, args) {
dialog.showOpenDialog(null, { dialog.showOpenDialog(
title: 'Import', null,
properties: ['openFile'], {
filters: [ title: "Import",
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] }, properties: ["openFile"],
] filters: [{ name: "TheDesk Config", extensions: ["thedeskconfig", "thedeskconfigv2", "json5"] }]
}, (fileNames) => { },
fileNames => {
if (!fileNames) { if (!fileNames) {
return false; return false;
} }
e.sender.webContents.send('config', JSON5.parse(fs.readFileSync(fileNames[0], 'utf8'))); e.sender.webContents.send("config", JSON5.parse(fs.readFileSync(fileNames[0], "utf8")));
}) }
}) );
});
//保存フォルダのダイアログ //保存フォルダのダイアログ
ipc.on('savefolder', function (e, args) { ipc.on("savefolder", function(e, args) {
dialog.showOpenDialog(null, { dialog.showOpenDialog(
title: 'Save folder', null,
properties: ['openDirectory'], {
}, (fileNames) => { title: "Save folder",
e.sender.webContents.send('savefolder', fileNames[0]); properties: ["openDirectory"]
},
fileNames => {
e.sender.webContents.send("savefolder", fileNames[0]);
}
);
}); });
})
//カスタムサウンドのダイアログ //カスタムサウンドのダイアログ
ipc.on('customSound', function (e, arg) { ipc.on("customSound", function(e, arg) {
dialog.showOpenDialog(null, { dialog.showOpenDialog(
title: 'Custom sound', null,
properties: ['openFile'], {
filters: [ title: "Custom sound",
{ name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] }, properties: ["openFile"],
{ name: 'All', extensions: ['*'] }, filters: [{ name: "Audio", extensions: ["mp3", "aac", "wav", "flac", "m4a"] }, { name: "All", extensions: ["*"] }]
] },
}, (fileNames) => { fileNames => {
e.sender.webContents.send('customSoundRender', [arg, fileNames[0]]); e.sender.webContents.send("customSoundRender", [arg, fileNames[0]]);
}
);
}); });
})
//ハードウェアアクセラレーションの無効化 //ハードウェアアクセラレーションの無効化
ipc.on('ha', function (e, arg) { ipc.on("ha", function(e, arg) {
if (arg == "true") { if (arg == "true") {
fs.writeFileSync(ha_path, arg); fs.writeFileSync(ha_path, arg);
} else { } else {
fs.unlink(ha_path, function(err) {}); fs.unlink(ha_path, function(err) {});
} }
app.relaunch() app.relaunch();
app.exit() app.exit();
}) });
ipc.on('ua', function (e, arg) { ipc.on("ua", function(e, arg) {
if (arg == "") { if (arg == "") {
fs.unlink(ua_path, function(err) {}); fs.unlink(ua_path, function(err) {});
} else { } else {
fs.writeFileSync(ua_path, arg); fs.writeFileSync(ua_path, arg);
} }
app.relaunch() app.relaunch();
app.exit() app.exit();
}) });
ipc.on('quit', (e, args) => { ipc.on("quit", (e, args) => {
app.quit(); app.quit();
}); });
ipc.on('about', (e, args) => { ipc.on("about", (e, args) => {
about(); about();
}); });
function about() { function about() {
var ver = app.getVersion() var ver = app.getVersion();
var window = new BrowserWindow({ var window = new BrowserWindow({
webPreferences: { webPreferences: {
webviewTag: false, webviewTag: false,
@ -120,20 +130,18 @@ function system(mainWindow, dir, lang, dirname) {
}, },
width: 300, width: 300,
height: 500, height: 500,
"transparent": false, // ウィンドウの背景を透過 transparent: false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ frame: false, // 枠の無いウィンドウ
"resizable": false resizable: false
}); });
window.loadURL(dir + '/about.html?ver=' + ver); window.loadURL(dir + "/about.html?ver=" + ver);
return "true" return "true";
} }
ipc.on('nano', function (e, x, y) { ipc.on("nano", function(e, x, y) {
var nano_info_path = join(app.getPath("userData"), "nano-window-position.json");
var nano_info_path = join(app.getPath("userData"),
"nano-window-position.json");
var window_pos; var window_pos;
try { try {
window_pos = JSON.parse(fs.readFileSync(nano_info_path, 'utf8')); window_pos = JSON.parse(fs.readFileSync(nano_info_path, "utf8"));
} catch (e) { } catch (e) {
window_pos = [0, 0]; // デフォルトバリュー window_pos = [0, 0]; // デフォルトバリュー
} }
@ -146,40 +154,39 @@ function system(mainWindow, dir, lang, dirname) {
}, },
width: 350, width: 350,
height: 140, height: 140,
"transparent": false, // ウィンドウの背景を透過 transparent: false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ frame: false, // 枠の無いウィンドウ
"resizable": false resizable: false
}); });
nanowindow.loadURL(dir + '/nano.html'); nanowindow.loadURL(dir + "/nano.html");
nanowindow.setAlwaysOnTop(true); nanowindow.setAlwaysOnTop(true);
//nanowindow.toggleDevTools() //nanowindow.toggleDevTools()
nanowindow.setPosition(window_pos[0], window_pos[1]); nanowindow.setPosition(window_pos[0], window_pos[1]);
nanowindow.on('close', function () { nanowindow.on("close", function() {
fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition())); fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition()));
}); });
return true; return true;
}) });
var cbTimer1; var cbTimer1;
ipc.on('startmem', (e, arg) => { ipc.on("startmem", (e, arg) => {
event = e.sender event = e.sender;
cbTimer1 = setInterval(mems, 1000); cbTimer1 = setInterval(mems, 1000);
}); });
function mems() { function mems() {
var mem = os.totalmem() - os.freemem(); var mem = os.totalmem() - os.freemem();
if (mainWindow) { if (mainWindow) {
event.webContents.send('memory', [mem, os.cpus()[0].model, os.totalmem()]); event.webContents.send("memory", [mem, os.cpus()[0].model, os.totalmem()]);
} }
} }
ipc.on('endmem', (e, arg) => { ipc.on("endmem", (e, arg) => {
if (cbTimer1) { if (cbTimer1) {
clearInterval(cbTimer1); clearInterval(cbTimer1);
} }
}); });
ipc.on("export", (e, args) => {
ipc.on('export', (e, args) => {
fs.writeFileSync(args[0], JSON5.stringify(args[1])); fs.writeFileSync(args[0], JSON5.stringify(args[1]));
e.sender.webContents.send('exportAllComplete', ""); e.sender.webContents.send("exportAllComplete", "");
}); });
//フォント //フォント
function object_array_sort(data, key, order, fn) { function object_array_sort(data, key, order, fn) {
@ -187,7 +194,8 @@ function system(mainWindow, dir, lang, dirname) {
var num_a = -1; var num_a = -1;
var num_b = 1; var num_b = 1;
if (order === 'asc') { //指定があれば昇順(ASC) if (order === "asc") {
//指定があれば昇順(ASC)
num_a = 1; num_a = 1;
num_b = -1; num_b = -1;
} }
@ -203,7 +211,7 @@ function system(mainWindow, dir, lang, dirname) {
//重複排除 //重複排除
var arrObj = {}; var arrObj = {};
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
arrObj[data[i]['family']] = data[i]; arrObj[data[i]["family"]] = data[i];
} }
data = []; data = [];
@ -213,16 +221,56 @@ function system(mainWindow, dir, lang, dirname) {
fn(data); // ソート後の配列を返す fn(data); // ソート後の配列を返す
} }
ipc.on('fonts', (e, arg) => { ipc.on("fonts", (e, arg) => {
const fm = require('font-manager'); const fm = require("font-manager");
var fonts = fm.getAvailableFontsSync(); var fonts = fm.getAvailableFontsSync();
object_array_sort(fonts, 'family', 'asc', function (fonts_sorted) { object_array_sort(fonts, "family", "asc", function(fonts_sorted) {
e.sender.webContents.send('font-list', fonts_sorted); e.sender.webContents.send("font-list", fonts_sorted);
}); });
}); });
//コピー //コピー
ipc.on('copy', (e, arg) => { ipc.on("copy", (e, arg) => {
clipboard.writeText(arg) clipboard.writeText(arg);
});
//ログ
ipc.on("log", (e, arg) => {
var today = new Date();
var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate();
var log_path = join(log_dir_path, todayStr + ".log");
fs.appendFile(log_path, "\n" + arg, function(err) {
if (err) {
throw err;
}
});
});
//起動時ログディレクトリ存在確認と作成、古ログ削除
fs.access(log_dir_path, fs.constants.R_OK | fs.constants.W_OK, error => {
var today = new Date();
//今日のやつ
var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
//昨日のやつ
today.setDate(today.getDate() - 1);
var yestStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
//一昨日のやつ
today.setDate(today.getDate() - 1);
var yest2Str = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
if (error) {
if (error.code === "ENOENT") {
fs.mkdirSync(log_dir_path);
} else {
return;
}
} else {
fs.readdir(log_dir_path, function(err, files) {
if (err) throw err;
files.filter(function(file) {
if (file != todayStr && file != yestStr && file != yest2Str) {
console.log(file, todayStr, yest2Str, yest2Str);
fs.unlinkSync(join(log_dir_path, file));
}
});
});
}
}); });
} }
exports.system = system; exports.system = system;

View File

@ -148,6 +148,11 @@
headers: { "content-type": "application/json" } headers: { "content-type": "application/json" }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
@ -215,6 +220,11 @@
headers: { "content-type": "application/json" } headers: { "content-type": "application/json" }
}) })
.then(function(response) { .then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {