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

View File

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

View File

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

View File

@ -196,4 +196,19 @@ function object_array_sort(data, key, order, fn) {
}
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
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
console.error(error);
@ -199,6 +204,7 @@ function post() {
httpreq.send(JSON.stringify(toot));
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
$("#textarea").val("");
}
};

View File

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

View File

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

View File

@ -118,6 +118,7 @@ function media(b64, type, no) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); }
if (!json.id) {
todc();
$("#imgup").text("");
@ -267,6 +268,11 @@ function altImage(acct_id, id) {
})
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
})
.catch(function(error) {

View File

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

View File

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

View File

@ -18,6 +18,7 @@ function fav(id, acct_id, remote) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); }
if (json.reblog) {
json = json.reblog;
}
@ -75,6 +76,7 @@ function rt(id, acct_id, remote, vis) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); }
if (json.reblog) {
json = json.reblog;
}
@ -147,6 +149,7 @@ function follow(acct_id, remote) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); }
console.log(["Success: folllow", json]);
if ($("#his-data").hasClass("following")) {
$("#his-data").removeClass("following");
@ -194,6 +197,7 @@ function block(acct_id) {
httpreq.send();
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
if ($("#his-data").hasClass("blocking")) {
$("#his-data").removeClass("blocking");
$("#his-block-btn-text").text(lang.lang_status_block);
@ -251,6 +255,7 @@ function muteDo(acct_id) {
httpreq.send(rq);
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); }
if ($("#his-data").hasClass("muting")) {
$("#his-data").removeClass("muting");
$("#his-mute-btn-text").text(lang.lang_status_mute);
@ -288,6 +293,7 @@ function del(id, acct_id) {
}
httpreq.onreadystatechange = function() {
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() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["Success: pinned", json]);
if ($("[toot-id=" + id + "]").hasClass("pined")) {
$("[toot-id=" + id + "]").removeClass("pined");
@ -389,6 +396,7 @@ function request(id, flag, acct_id) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["Success: request", "type:" + flag, json]);
showReq();
}
@ -412,6 +420,7 @@ function domainblock(add, flag, acct_id) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["Success: domain block", json]);
showDom();
}
@ -468,6 +477,7 @@ function pinUser() {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
if ($("#his-end-btn").hasClass("endorsed")) {
$("#his-end-btn").removeClass("endorsed");
$("#his-end-btn").text(lang.lang_status_endorse);
@ -499,6 +509,11 @@ function staEx(mode) {
}
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
})
.catch(function(error) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -121,6 +121,11 @@ function filter() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@ -199,6 +204,7 @@ function makeNewFilter() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
filter();
filterUpdate(acct_id)
$("#filter-add-word").val("");
@ -239,6 +245,11 @@ function filterEdit(id, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@ -282,6 +293,7 @@ function filterDel(id, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
filter();
filterUpdate(acct_id)
}
@ -299,6 +311,11 @@ function getFilter(acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@ -342,6 +359,11 @@ function filterUpdate(acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);

View File

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

View File

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

View File

@ -43,6 +43,7 @@ function notfColumn(acct_id, tlid, sys) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
var max_id = httpreq.getResponseHeader("link");
if (max_id) {
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) {
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();
}).catch(function (error) {
todo(error);
@ -317,6 +323,7 @@ function notfmore(tlid) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["More notifications on " + tlid, json]);
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1];
if (json[0]) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,6 +52,7 @@ function imgChange(imgfile, target) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); }
$('#his-data').modal('close');
todc();
localStorage.removeItem("image");

View File

@ -31,6 +31,11 @@ function udgEx(user, acct_id) {
'Authorization': 'Bearer ' + at
}
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@ -65,6 +70,11 @@ function udg(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@ -235,6 +245,11 @@ function misskeyUdg(user, acct_id) {
userId: user
})
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
todo(error);
@ -357,6 +372,11 @@ function relations(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (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
const crypto = require("crypto");
const N = 100;
var ua = "Mastodon client: "+crypto
var ua =
"Mastodon client: " +
crypto
.randomBytes(N)
.toString("base64")
.substring(0, N);

View File

@ -1,116 +1,126 @@
function system(mainWindow, dir, lang, dirname) {
const electron = require("electron");
const app = electron.app;
const join = require('path').join;
const join = require("path").join;
var Jimp = require("jimp");
const fs = require("fs");
var JSON5 = require('json5');
var JSON5 = require("json5");
var ipc = electron.ipcMain;
const clipboard = electron.clipboard;
var tmp_img = join(app.getPath("userData"), "tmp.png");
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
var ua_path = join(app.getPath("userData"), "useragent");
var lang_path = join(app.getPath("userData"), "language");
var log_dir_path = join(app.getPath("userData"), "logs");
const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog;
const os = require('os')
const os = require("os");
const language = require("../main/language.js");
//プラットフォーム
ipc.on('getPlatform', function (e, arg) {
ipc.on("getPlatform", function(e, arg) {
try {
var gitHash = fs.readFileSync("git", 'utf8')
var gitHash = fs.readFileSync("git", "utf8");
} 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);
fs.writeFileSync(lang_path, arg);
e.sender.webContents.send('langres', arg);
})
e.sender.webContents.send("langres", arg);
});
//エクスポートのダイアログ
ipc.on('exportSettings', function (e, args) {
dialog.showSaveDialog(null, {
title: 'Export',
properties: ['openFile', 'createDirectory'],
ipc.on("exportSettings", function(e, args) {
dialog.showSaveDialog(
null,
{
title: "Export",
properties: ["openFile", "createDirectory"],
defaultPath: "export.thedeskconfig.json5"
}, (savedFiles) => {
},
savedFiles => {
if (!savedFiles) {
return false;
}
e.sender.webContents.send('exportSettingsFile', savedFiles);
})
})
e.sender.webContents.send("exportSettingsFile", savedFiles);
}
);
});
//インポートのダイアログ
ipc.on('importSettings', function (e, args) {
dialog.showOpenDialog(null, {
title: 'Import',
properties: ['openFile'],
filters: [
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] },
]
}, (fileNames) => {
ipc.on("importSettings", function(e, args) {
dialog.showOpenDialog(
null,
{
title: "Import",
properties: ["openFile"],
filters: [{ name: "TheDesk Config", extensions: ["thedeskconfig", "thedeskconfigv2", "json5"] }]
},
fileNames => {
if (!fileNames) {
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) {
dialog.showOpenDialog(null, {
title: 'Save folder',
properties: ['openDirectory'],
}, (fileNames) => {
e.sender.webContents.send('savefolder', fileNames[0]);
ipc.on("savefolder", function(e, args) {
dialog.showOpenDialog(
null,
{
title: "Save folder",
properties: ["openDirectory"]
},
fileNames => {
e.sender.webContents.send("savefolder", fileNames[0]);
}
);
});
})
//カスタムサウンドのダイアログ
ipc.on('customSound', function (e, arg) {
dialog.showOpenDialog(null, {
title: 'Custom sound',
properties: ['openFile'],
filters: [
{ name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] },
{ name: 'All', extensions: ['*'] },
]
}, (fileNames) => {
e.sender.webContents.send('customSoundRender', [arg, fileNames[0]]);
ipc.on("customSound", function(e, arg) {
dialog.showOpenDialog(
null,
{
title: "Custom sound",
properties: ["openFile"],
filters: [{ name: "Audio", extensions: ["mp3", "aac", "wav", "flac", "m4a"] }, { name: "All", extensions: ["*"] }]
},
fileNames => {
e.sender.webContents.send("customSoundRender", [arg, fileNames[0]]);
}
);
});
})
//ハードウェアアクセラレーションの無効化
ipc.on('ha', function (e, arg) {
ipc.on("ha", function(e, arg) {
if (arg == "true") {
fs.writeFileSync(ha_path, arg);
} else {
fs.unlink(ha_path, function(err) {});
}
app.relaunch()
app.exit()
})
ipc.on('ua', function (e, arg) {
app.relaunch();
app.exit();
});
ipc.on("ua", function(e, arg) {
if (arg == "") {
fs.unlink(ua_path, function(err) {});
} else {
fs.writeFileSync(ua_path, arg);
}
app.relaunch()
app.exit()
})
app.relaunch();
app.exit();
});
ipc.on('quit', (e, args) => {
ipc.on("quit", (e, args) => {
app.quit();
});
ipc.on('about', (e, args) => {
ipc.on("about", (e, args) => {
about();
});
function about() {
var ver = app.getVersion()
var ver = app.getVersion();
var window = new BrowserWindow({
webPreferences: {
webviewTag: false,
@ -120,20 +130,18 @@ function system(mainWindow, dir, lang, dirname) {
},
width: 300,
height: 500,
"transparent": false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ
"resizable": false
transparent: false, // ウィンドウの背景を透過
frame: false, // 枠の無いウィンドウ
resizable: false
});
window.loadURL(dir + '/about.html?ver=' + ver);
return "true"
window.loadURL(dir + "/about.html?ver=" + ver);
return "true";
}
ipc.on('nano', function (e, x, y) {
var nano_info_path = join(app.getPath("userData"),
"nano-window-position.json");
ipc.on("nano", function(e, x, y) {
var nano_info_path = join(app.getPath("userData"), "nano-window-position.json");
var window_pos;
try {
window_pos = JSON.parse(fs.readFileSync(nano_info_path, 'utf8'));
window_pos = JSON.parse(fs.readFileSync(nano_info_path, "utf8"));
} catch (e) {
window_pos = [0, 0]; // デフォルトバリュー
}
@ -146,40 +154,39 @@ function system(mainWindow, dir, lang, dirname) {
},
width: 350,
height: 140,
"transparent": false, // ウィンドウの背景を透過
"frame": false, // 枠の無いウィンドウ
"resizable": false
transparent: false, // ウィンドウの背景を透過
frame: false, // 枠の無いウィンドウ
resizable: false
});
nanowindow.loadURL(dir + '/nano.html');
nanowindow.loadURL(dir + "/nano.html");
nanowindow.setAlwaysOnTop(true);
//nanowindow.toggleDevTools()
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()));
});
return true;
})
});
var cbTimer1;
ipc.on('startmem', (e, arg) => {
event = e.sender
ipc.on("startmem", (e, arg) => {
event = e.sender;
cbTimer1 = setInterval(mems, 1000);
});
function mems() {
var mem = os.totalmem() - os.freemem();
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) {
clearInterval(cbTimer1);
}
});
ipc.on('export', (e, args) => {
ipc.on("export", (e, args) => {
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) {
@ -187,7 +194,8 @@ function system(mainWindow, dir, lang, dirname) {
var num_a = -1;
var num_b = 1;
if (order === 'asc') { //指定があれば昇順(ASC)
if (order === "asc") {
//指定があれば昇順(ASC)
num_a = 1;
num_b = -1;
}
@ -203,7 +211,7 @@ function system(mainWindow, dir, lang, dirname) {
//重複排除
var arrObj = {};
for (var i = 0; i < data.length; i++) {
arrObj[data[i]['family']] = data[i];
arrObj[data[i]["family"]] = data[i];
}
data = [];
@ -213,16 +221,56 @@ function system(mainWindow, dir, lang, dirname) {
fn(data); // ソート後の配列を返す
}
ipc.on('fonts', (e, arg) => {
const fm = require('font-manager');
ipc.on("fonts", (e, arg) => {
const fm = require("font-manager");
var fonts = fm.getAvailableFontsSync();
object_array_sort(fonts, 'family', 'asc', function (fonts_sorted) {
e.sender.webContents.send('font-list', fonts_sorted);
object_array_sort(fonts, "family", "asc", function(fonts_sorted) {
e.sender.webContents.send("font-list", fonts_sorted);
});
});
//コピー
ipc.on('copy', (e, arg) => {
clipboard.writeText(arg)
ipc.on("copy", (e, 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;

View File

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