2018-01-28 23:22:43 +11:00
|
|
|
/*ログイン処理・認証までのJS*/
|
|
|
|
//最初に読むやつ
|
2018-02-09 03:43:11 +11:00
|
|
|
//アスタルテ判定初期化
|
2018-03-31 13:39:06 +11:00
|
|
|
|
2018-02-09 03:43:11 +11:00
|
|
|
localStorage.removeItem("kirishima")
|
2018-04-16 23:58:14 +10:00
|
|
|
localStorage.removeItem("imas")
|
2018-02-19 04:41:25 +11:00
|
|
|
localStorage.removeItem("image");
|
2019-03-13 02:51:07 +11:00
|
|
|
localStorage.removeItem("stable")
|
2018-08-24 01:15:57 +10:00
|
|
|
localStorage.setItem("mode_misskey.xyz","misskey")
|
2018-01-28 23:22:43 +11:00
|
|
|
function ck() {
|
2018-05-20 16:17:10 +10:00
|
|
|
var main = localStorage.getItem("main");
|
|
|
|
if(!main){
|
|
|
|
localStorage.setItem("main",0)
|
|
|
|
}
|
2019-03-08 05:19:26 +11:00
|
|
|
var domainz = localStorage.getItem("domain_0");
|
2018-07-07 03:51:48 +10:00
|
|
|
var at = localStorage.getItem("acct_0_at");
|
2019-03-08 05:19:26 +11:00
|
|
|
var oldat = localStorage.getItem(domainz + "_at");
|
2018-07-07 03:51:48 +10:00
|
|
|
if(oldat){
|
|
|
|
console.log("Move to New Account Management System")
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
if (!multi) {
|
|
|
|
var acctlen=1;
|
|
|
|
} else {
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
var acctlen=obj.length;
|
|
|
|
}
|
|
|
|
for(i=0;acctlen>i;i++){
|
|
|
|
var domain = localStorage.getItem("domain_"+i);
|
|
|
|
var oldat = localStorage.getItem(domain + "_at");
|
|
|
|
var newat = localStorage.setItem("acct_"+ i + "_at",oldat);
|
|
|
|
localStorage.removeItem(domain + "_at");
|
|
|
|
}
|
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
//コード受信
|
|
|
|
if(location.search){
|
2018-02-26 02:32:10 +11:00
|
|
|
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
|
2018-02-18 16:43:11 +11:00
|
|
|
var mode=m[1];
|
|
|
|
var codex=m[2];
|
|
|
|
if(mode=="manager" || mode=="login"){
|
|
|
|
code(codex,mode);
|
2018-07-05 11:26:07 +10:00
|
|
|
}else{
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|
|
|
|
}
|
2019-02-05 13:33:32 +11:00
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
if (!multi) {
|
|
|
|
var obj = [];
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
} else {
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
}
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
var acct=obj[key];
|
|
|
|
if(acct.domain){
|
|
|
|
refresh(key,true)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
console.log(obj);
|
|
|
|
if (obj[0].domain) {
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#tl").show();
|
2018-12-09 05:46:01 +11:00
|
|
|
ticker();
|
2018-07-07 03:51:48 +10:00
|
|
|
multiSelector();
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
2018-03-27 13:39:35 +11:00
|
|
|
$("#tl").show();
|
2019-02-05 13:33:32 +11:00
|
|
|
$("#post-box").hide();
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ck();
|
|
|
|
//ログインポップアップ
|
|
|
|
function login(url) {
|
2018-03-11 01:22:59 +11:00
|
|
|
if($('#linux:checked').val()=="on"){
|
2018-02-26 02:32:10 +11:00
|
|
|
var red = "urn:ietf:wg:oauth:2.0:oob"
|
|
|
|
}else{
|
|
|
|
var red = 'thedesk://login';
|
|
|
|
}
|
|
|
|
localStorage.setItem("redirect", red);
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + url + "/api/v1/apps";
|
2018-04-17 03:10:35 +10:00
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
2019-03-08 05:19:26 +11:00
|
|
|
httpreq.responseType = "json";
|
2018-04-17 03:10:35 +10:00
|
|
|
httpreq.send(JSON.stringify({
|
|
|
|
scopes: 'read write follow',
|
|
|
|
client_name: "TheDesk(PC)",
|
|
|
|
redirect_uris: red,
|
|
|
|
website: "https://thedesk.top"
|
|
|
|
}));
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2018-04-17 03:10:35 +10:00
|
|
|
var json = httpreq.response;
|
|
|
|
console.log(json);
|
|
|
|
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
|
2018-01-28 23:22:43 +11:00
|
|
|
"client_id"] + "&client_secret=" + json["client_secret"] +
|
2018-03-11 01:22:59 +11:00
|
|
|
"&response_type=code&redirect_uri="+red+"&scope=read+write+follow";
|
2018-01-28 23:22:43 +11:00
|
|
|
localStorage.setItem("domain_" + acct_id, url);
|
|
|
|
localStorage.setItem("client_id", json["client_id"]);
|
|
|
|
localStorage.setItem("client_secret", json["client_secret"]);
|
|
|
|
$("#auth").show();
|
|
|
|
$("#masara").hide();
|
2019-03-08 05:19:26 +11:00
|
|
|
const { shell } = require('electron');
|
2018-01-31 03:43:01 +11:00
|
|
|
|
2018-02-18 16:43:11 +11:00
|
|
|
shell.openExternal(auth);
|
2018-03-11 01:22:59 +11:00
|
|
|
|
|
|
|
if($('#linux:checked').val()=="on"){
|
|
|
|
}else{
|
|
|
|
var electron = require("electron");
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('quit', 'go');
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//テキストボックスにURL入れた
|
|
|
|
function instance() {
|
|
|
|
var url = $("#url").val();
|
|
|
|
login(url);
|
|
|
|
}
|
|
|
|
|
2018-02-18 16:43:11 +11:00
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
//コードを入れた後認証
|
2018-02-18 16:43:11 +11:00
|
|
|
function code(code,mode) {
|
2018-02-26 02:32:10 +11:00
|
|
|
var red = localStorage.getItem("redirect");
|
|
|
|
localStorage.removeItem("redirect")
|
2018-02-18 16:43:11 +11:00
|
|
|
if(!code){
|
|
|
|
var code = $("#code").val();
|
|
|
|
}
|
|
|
|
if(localStorage.getItem("domain_tmp")){
|
|
|
|
var url = localStorage.getItem("domain_tmp");
|
|
|
|
}else{
|
|
|
|
var url = localStorage.getItem("domain_" + acct_id);
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + url + "/oauth/token";
|
|
|
|
var id = localStorage.getItem("client_id");
|
|
|
|
var secret = localStorage.getItem("client_secret");
|
|
|
|
fetch(start, {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
|
|
|
grant_type: "authorization_code",
|
2018-02-26 02:32:10 +11:00
|
|
|
redirect_uri: red,
|
2018-01-28 23:22:43 +11:00
|
|
|
client_id: id,
|
|
|
|
client_secret: secret,
|
|
|
|
code: code
|
|
|
|
})
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
2018-02-18 16:43:11 +11:00
|
|
|
todo(json);
|
2018-01-28 23:22:43 +11:00
|
|
|
if (json["access_token"]) {
|
|
|
|
localStorage.setItem(url + "_at", json["access_token"]);
|
2018-02-18 16:43:11 +11:00
|
|
|
if(mode=="manager"){
|
|
|
|
getdataAdv(url, json["access_token"]);
|
|
|
|
}else{
|
|
|
|
getdata();
|
|
|
|
}
|
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-02-18 16:43:11 +11:00
|
|
|
//ユーザーデータ取得(最初)
|
2018-01-28 23:22:43 +11:00
|
|
|
function getdata() {
|
|
|
|
var acct_id = 0;
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2018-07-07 03:51:48 +10:00
|
|
|
var at = localStorage.getItem("acct_"+ acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
if (json.error) {
|
|
|
|
console.error("Error:" + json.error);
|
2019-01-26 14:24:26 +11:00
|
|
|
Materialize.toast(lang.lang_fatalerroroccured+"Error:" + json.error,
|
2018-01-28 23:22:43 +11:00
|
|
|
5000);
|
|
|
|
return;
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
var avatar=json["avatar"];
|
|
|
|
//missingがmissingなやつ
|
|
|
|
if(avatar=="/avatars/original/missing.png"){
|
|
|
|
avatar="./img/missing.svg";
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var obj = [{
|
|
|
|
at: at,
|
|
|
|
name: json["display_name"],
|
|
|
|
domain: domain,
|
|
|
|
user: json["acct"],
|
2018-06-18 00:26:45 +10:00
|
|
|
prof: avatar,
|
|
|
|
id: json["id"],
|
|
|
|
vis: json["source"]["privacy"]
|
2018-01-28 23:22:43 +11:00
|
|
|
}];
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
console.log(obj);
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
localStorage.setItem("name_" + acct_id, json["display_name"]);
|
|
|
|
localStorage.setItem("user_" + acct_id, json["acct"]);
|
|
|
|
localStorage.setItem("user-id_" + acct_id, json["id"]);
|
2018-03-31 13:39:06 +11:00
|
|
|
localStorage.setItem("prof_" + acct_id, avatar);
|
2018-02-18 16:43:11 +11:00
|
|
|
$("#masara").hide();
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#auth").hide();
|
|
|
|
$("#tl").show();
|
|
|
|
parseColumn()
|
|
|
|
ckdb();
|
|
|
|
});
|
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
//ユーザーデータ取得(追加)
|
|
|
|
function getdataAdv(domain, at) {
|
|
|
|
var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
if (json.error) {
|
|
|
|
console.error("Error:" + json.error);
|
2019-01-26 14:24:26 +11:00
|
|
|
Materialize.toast(lang.lang_fatalerroroccured+"Error:" + json.error,
|
2018-02-18 16:43:11 +11:00
|
|
|
5000);
|
|
|
|
return;
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
var avatar=json["avatar"];
|
|
|
|
//missingがmissingなやつ
|
|
|
|
if(avatar=="/avatars/original/missing.png"){
|
2019-02-05 13:33:32 +11:00
|
|
|
avatar="../../img/missing.svg";
|
2018-03-31 13:39:06 +11:00
|
|
|
}
|
2018-07-07 03:51:48 +10:00
|
|
|
if(json["source"]["privacy"]){
|
|
|
|
var priv=json["source"]["privacy"];
|
|
|
|
}else{
|
|
|
|
var priv="public";
|
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
var add = {
|
|
|
|
at: at,
|
|
|
|
name: json["display_name"],
|
|
|
|
domain: domain,
|
|
|
|
user: json["acct"],
|
2018-03-31 13:39:06 +11:00
|
|
|
prof: avatar,
|
2018-06-18 00:26:45 +10:00
|
|
|
id: json["id"],
|
2018-07-07 03:51:48 +10:00
|
|
|
vis: priv
|
2018-02-18 16:43:11 +11:00
|
|
|
};
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
var target = obj.lengtth;
|
|
|
|
obj.push(add);
|
|
|
|
localStorage.setItem("name_" + target, json["display_name"]);
|
|
|
|
localStorage.setItem("user_" + target, json["acct"]);
|
|
|
|
localStorage.setItem("user-id_" + target, json["id"]);
|
2018-03-31 13:39:06 +11:00
|
|
|
localStorage.setItem("prof_" + target, avatar);
|
2018-02-18 16:43:11 +11:00
|
|
|
console.log(obj);
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
location.href="index.html";
|
|
|
|
});
|
|
|
|
}
|
2018-08-17 03:21:40 +10:00
|
|
|
//ユーザーデータ更新
|
2019-02-05 13:33:32 +11:00
|
|
|
function refresh(target,loadskip) {
|
2018-08-17 03:21:40 +10:00
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
var obj = JSON.parse(multi);
|
2018-08-21 04:26:14 +10:00
|
|
|
if(obj[target].mode=="misskey"){
|
2018-08-17 03:21:40 +10:00
|
|
|
return
|
|
|
|
}
|
|
|
|
var start = "https://" + obj[target].domain +
|
|
|
|
"/api/v1/accounts/verify_credentials";
|
|
|
|
console.log(start);
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + obj[target].at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
if (json.error) {
|
|
|
|
console.error("Error:" + json.error);
|
2019-01-26 14:24:26 +11:00
|
|
|
Materialize.toast(lang.lang_fatalerroroccured+"Error:" + json.error,
|
2018-08-17 03:21:40 +10:00
|
|
|
5000);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var avatar=json["avatar"];
|
|
|
|
//missingがmissingなやつ
|
|
|
|
if(avatar=="/avatars/original/missing.png" || !avatar){
|
|
|
|
avatar="./img/missing.svg";
|
|
|
|
}
|
|
|
|
var ref = {
|
|
|
|
at: obj[target].at,
|
|
|
|
name: json["display_name"],
|
|
|
|
domain: obj[target].domain,
|
|
|
|
user: json["acct"],
|
|
|
|
prof: avatar,
|
|
|
|
id: json["id"],
|
|
|
|
vis: json["source"]["privacy"]
|
|
|
|
};
|
|
|
|
localStorage.setItem("name_" + target, json["display_name"]);
|
|
|
|
localStorage.setItem("user_" + target, json["acct"]);
|
|
|
|
localStorage.setItem("user-id_" + target, json["id"]);
|
|
|
|
console.log("user-id_" + target+":"+json["id"])
|
|
|
|
console.log(localStorage.getItem("user-id_"+target));
|
|
|
|
localStorage.setItem("prof_" + target, avatar);
|
|
|
|
localStorage.setItem("follow_" + target, json["following_count"]);
|
|
|
|
obj[target] = ref;
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("multi", json);
|
2019-02-05 13:33:32 +11:00
|
|
|
if(!loadskip){
|
|
|
|
load();
|
|
|
|
}
|
2018-08-17 03:21:40 +10:00
|
|
|
});
|
|
|
|
}
|
2018-03-27 13:39:35 +11:00
|
|
|
//MarkdownやBBCodeの対応、文字数制限をチェック
|
2018-08-17 03:21:40 +10:00
|
|
|
//絶対ストリーミングを閉じさせないマン
|
2018-02-09 03:43:11 +11:00
|
|
|
function ckdb(acct_id) {
|
2018-01-28 23:22:43 +11:00
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2018-09-19 02:41:48 +10:00
|
|
|
localStorage.removeItem("home_" + acct_id);
|
|
|
|
localStorage.removeItem("bb_" + acct_id);
|
|
|
|
localStorage.removeItem("md_" + acct_id);
|
|
|
|
localStorage.removeItem("local_" + acct_id);
|
|
|
|
localStorage.removeItem("public_" + acct_id);
|
|
|
|
localStorage.removeItem("notification_" + acct_id);
|
|
|
|
localStorage.removeItem("post_" + acct_id);
|
|
|
|
localStorage.removeItem("fav_" + acct_id);
|
|
|
|
localStorage.removeItem("bt_" + acct_id);
|
2019-03-06 19:08:48 +11:00
|
|
|
localStorage.removeItem("followlocale_" + acct_id);
|
2018-02-09 03:43:11 +11:00
|
|
|
if(domain=="kirishima.cloud"){
|
|
|
|
localStorage.setItem("kirishima", "true");
|
|
|
|
$("#ranking-btn").show();
|
2018-07-07 03:51:48 +10:00
|
|
|
}else if(domain=="imastodon.net"){
|
2018-04-16 23:58:14 +10:00
|
|
|
localStorage.setItem("imas", "true");
|
2018-07-28 07:25:12 +10:00
|
|
|
$(".imasonly").show();
|
2018-02-09 03:43:11 +11:00
|
|
|
}
|
2018-07-07 03:51:48 +10:00
|
|
|
var at = localStorage.getItem("acct_"+ acct_id + "_at");
|
2018-01-28 23:22:43 +11:00
|
|
|
var bbcode = domain + "_bbcode";
|
|
|
|
var letters = domain + "_letters";
|
2018-02-25 19:41:34 +11:00
|
|
|
if(localStorage.getItem("instance")){
|
|
|
|
var json=JSON.parse(localStorage.getItem("instance"));
|
|
|
|
if (json[bbcode]) {
|
|
|
|
if (json[bbcode] == "enabled") {
|
|
|
|
localStorage.setItem("bb_" + acct_id, "true");
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem("bb_" + acct_id);
|
|
|
|
$("[data-activates='bbcode']").addClass("disabled");
|
|
|
|
$("[data-activates='bbcode']").prop("disabled", true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
localStorage.removeItem("bb_" + acct_id);
|
|
|
|
$("[data-activates='bbcode']").addClass("disabled");
|
|
|
|
$("[data-activates='bbcode']").addClass("disabled", true);
|
|
|
|
}
|
2018-04-16 23:58:14 +10:00
|
|
|
|
2018-02-25 19:41:34 +11:00
|
|
|
if (json[domain + "_markdown"] == "enabled") {
|
|
|
|
localStorage.setItem("md_" + acct_id, "true");
|
|
|
|
$(".markdown").show();
|
|
|
|
}else{
|
2018-07-05 11:26:07 +10:00
|
|
|
$(".anti-markdown").hide();
|
|
|
|
$(".markdown").hide();
|
2018-02-25 19:41:34 +11:00
|
|
|
localStorage.removeItem("bb_" + acct_id);
|
|
|
|
}
|
2018-03-20 15:55:25 +11:00
|
|
|
if(json[domain + "_home"]){
|
|
|
|
console.log("unique name:"+json[domain + "_home"]);
|
|
|
|
localStorage.setItem("home_" + acct_id, json[domain + "_home"]);
|
|
|
|
}
|
|
|
|
if(json[domain + "_local"]){
|
|
|
|
localStorage.setItem("local_" + acct_id, json[domain + "_local"]);
|
|
|
|
}
|
|
|
|
if(json[domain + "_public"]){
|
|
|
|
localStorage.setItem("public_" + acct_id, json[domain + "_public"]);
|
|
|
|
}
|
|
|
|
if(json[domain + "_notification"]){
|
|
|
|
localStorage.setItem("notification_" + acct_id, json[domain + "_notification"]);
|
|
|
|
}
|
2018-08-07 01:14:55 +10:00
|
|
|
if(json[domain + "_post"]){
|
|
|
|
localStorage.setItem("post_" + acct_id, json[domain + "_post"]);
|
|
|
|
}
|
|
|
|
if(json[domain + "_fav"]){
|
|
|
|
localStorage.setItem("fav_" + acct_id, json[domain + "_fav"]);
|
|
|
|
}
|
|
|
|
if(json[domain + "_bt"]){
|
|
|
|
localStorage.setItem("bt_" + acct_id, json[domain + "_bt"]);
|
|
|
|
}
|
|
|
|
if(json[domain + "_follow"]){
|
2019-03-06 19:08:48 +11:00
|
|
|
localStorage.setItem("followlocale_" + acct_id, json[domain + "_follow"]);
|
2018-08-07 01:14:55 +10:00
|
|
|
}
|
2018-02-25 19:41:34 +11:00
|
|
|
}
|
2018-08-29 20:17:34 +10:00
|
|
|
if(localStorage.getItem("mode_" + domain)!="misskey"){
|
2018-09-01 23:02:15 +10:00
|
|
|
var start = "https://" + domain + "/api/v1/instance";
|
2018-08-17 03:21:40 +10:00
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
if (json.error) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(json){
|
2018-09-17 21:55:00 +10:00
|
|
|
if(json["max_toot_chars"]){
|
|
|
|
localStorage.setItem("letters_" + acct_id, json["max_toot_chars"]);
|
|
|
|
}
|
|
|
|
if(json["urls"]["streaming_api"]){
|
|
|
|
localStorage.setItem("streaming_" + acct_id, json["urls"]["streaming_api"]);
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
});
|
2018-08-17 03:21:40 +10:00
|
|
|
|
2018-08-21 04:26:14 +10:00
|
|
|
}else{
|
2018-08-17 03:21:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//アカウントを選択…を実装
|
2018-07-07 03:51:48 +10:00
|
|
|
function multiSelector() {
|
2018-01-28 23:22:43 +11:00
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
if (!multi) {
|
2018-03-27 13:39:35 +11:00
|
|
|
var obj = [];
|
2018-01-28 23:22:43 +11:00
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
} else {
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
}
|
|
|
|
var templete;
|
2018-05-20 16:17:10 +10:00
|
|
|
if(localStorage.getItem("mainuse")=="main"){
|
|
|
|
var last = localStorage.getItem("main");
|
2018-08-21 04:26:14 +10:00
|
|
|
}else if(localStorage.getItem("last-use")){
|
2018-05-20 16:17:10 +10:00
|
|
|
var last = localStorage.getItem("last-use");
|
2018-08-21 04:26:14 +10:00
|
|
|
}else{
|
|
|
|
var last=0;
|
2018-05-20 16:17:10 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
var sel;
|
2018-03-27 13:39:35 +11:00
|
|
|
if(obj.length<1){
|
|
|
|
$("#src-acct-sel").html('<option value="tootsearch">Tootsearch</option>');
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#add-acct-sel").html('<option value="noauth">'+lang.lang_login_noauth+'</option>');
|
2018-03-27 13:39:35 +11:00
|
|
|
}else{
|
2018-01-28 23:22:43 +11:00
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
var acct = obj[key];
|
|
|
|
var list = key * 1 + 1;
|
|
|
|
if (key == last) {
|
|
|
|
sel = "selected";
|
2019-02-05 13:33:32 +11:00
|
|
|
var domain = acct.domain;
|
|
|
|
localStorage.setItem("domain_" + key, domain);
|
2018-04-16 23:58:14 +10:00
|
|
|
if(idata[domain+"_letters"]){
|
|
|
|
$("#textarea").attr("data-length", idata[domain+"_letters"])
|
|
|
|
}else{
|
2018-09-01 23:02:15 +10:00
|
|
|
var maxletters = localStorage.getItem("letters_" + key);
|
2018-09-12 02:49:41 +10:00
|
|
|
if(maxletters>0){
|
2018-09-01 23:02:15 +10:00
|
|
|
$("#textarea").attr("data-length", maxletters)
|
|
|
|
}else{
|
|
|
|
$("#textarea").attr("data-length", 500)
|
|
|
|
}
|
2018-04-16 23:58:14 +10:00
|
|
|
}
|
2018-09-06 02:47:27 +10:00
|
|
|
if(idata[domain+"_glitch"]){
|
|
|
|
$("#local-button").removeClass("hide")
|
|
|
|
}
|
2019-02-05 13:33:32 +11:00
|
|
|
var profimg = acct.prof;
|
|
|
|
localStorage.setItem("prof_" + key, profimg);
|
2018-08-21 04:26:14 +10:00
|
|
|
console.log(profimg);
|
2018-04-07 14:31:09 +10:00
|
|
|
if(!profimg){
|
2019-02-05 13:33:32 +11:00
|
|
|
profimg="../../img/missing.svg";
|
2018-04-07 14:31:09 +10:00
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
$("#acct-sel-prof").attr("src",profimg);
|
2019-02-05 13:33:32 +11:00
|
|
|
console.log(domain);
|
|
|
|
if(domain){
|
|
|
|
var cc="("+domain+")";
|
|
|
|
}else{
|
|
|
|
var cc="";
|
|
|
|
}
|
|
|
|
$("#toot-post-btn").text(lang.lang_toot+cc);
|
2018-06-18 00:26:45 +10:00
|
|
|
if(acct.background && acct.background!="def" && acct.text && acct.text!="def"){
|
|
|
|
$("#toot-post-btn").removeClass("indigo");
|
|
|
|
$("#toot-post-btn").css("background-color","#"+acct.background);
|
|
|
|
$("#toot-post-btn").css("color",acct.text);
|
|
|
|
}else{
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
if(domain=="kirishima.cloud"){
|
|
|
|
$("#faicon-btn").show();
|
|
|
|
}else{
|
|
|
|
$("#faicon-btn").hide();
|
|
|
|
}
|
2018-05-20 16:17:10 +10:00
|
|
|
if(domain=="imastodon.net"){
|
|
|
|
trendTag();
|
|
|
|
}else{
|
|
|
|
$("#trendtag").html("");
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
sel = "";
|
|
|
|
}
|
|
|
|
templete = '<option value="' + key + '" data-icon="' + acct.prof +
|
|
|
|
'" class="left circle" ' + sel + '>' + acct.user + '@' + acct.domain +
|
|
|
|
'</option>';
|
|
|
|
$(".acct-sel").append(templete);
|
2018-03-21 16:36:02 +11:00
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
});
|
2018-03-27 13:39:35 +11:00
|
|
|
$("#src-acct-sel").append('<option value="tootsearch">Tootsearch</option>');
|
2019-01-26 14:24:26 +11:00
|
|
|
$("#add-acct-sel").append('<option value="noauth">'+lang.lang_login_noauth+'</option><option value="webview">Twitter</option>');
|
2018-03-27 13:39:35 +11:00
|
|
|
}
|
2018-03-21 16:36:02 +11:00
|
|
|
$('select').material_select('update');
|
2019-02-05 13:33:32 +11:00
|
|
|
parseColumn();
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
|
2018-03-14 05:31:31 +11:00
|
|
|
//バージョンエンコ
|
|
|
|
function enc(ver){
|
|
|
|
var ver = ver.replace( /\s/g , "" );
|
|
|
|
var ver = ver.replace( /\(/g , "-" );
|
|
|
|
var ver = ver.replace( /\)/g , "" );
|
|
|
|
var ver = ver.replace( /\[/g , "_" );
|
|
|
|
var ver = ver.replace( /\]/g , "" );
|
|
|
|
return ver;
|
2018-03-31 13:39:06 +11:00
|
|
|
}
|
2018-12-09 05:46:01 +11:00
|
|
|
//インスタンスティッカー
|
|
|
|
function ticker() {
|
|
|
|
var start = "https://toot.app/toot/";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
if (json.error) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(json){
|
|
|
|
localStorage.setItem("ticker", JSON.stringify(json));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|