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
|
|
|
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.removeItem('kirishima')
|
|
|
|
localStorage.removeItem('quoters')
|
|
|
|
localStorage.removeItem('imas')
|
|
|
|
localStorage.removeItem('image')
|
|
|
|
localStorage.removeItem('stable')
|
|
|
|
localStorage.setItem('mode_misskey.xyz', 'misskey')
|
2018-01-28 23:22:43 +11:00
|
|
|
function ck() {
|
2019-11-10 22:37:13 +11:00
|
|
|
var main = localStorage.getItem('main')
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!main) {
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.setItem('main', 0)
|
2018-05-20 16:17:10 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
|
2018-02-18 16:43:11 +11:00
|
|
|
//コード受信
|
2019-05-19 17:39:30 +10:00
|
|
|
if (location.search) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
|
|
|
|
var mode = m[1]
|
|
|
|
var codex = m[2]
|
|
|
|
if (mode == 'manager' || mode == 'login') {
|
|
|
|
code(codex, mode)
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
if (!multi || multi == '[]') {
|
|
|
|
var date = new Date()
|
|
|
|
localStorage.setItem('showSupportMe', date.getMonth() + 2)
|
|
|
|
location.href = 'acct.html?mode=first&code=true'
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
var jp = false
|
2019-11-04 03:10:06 +11:00
|
|
|
Object.keys(obj).forEach(function(key) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var acct = obj[key]
|
2019-05-19 17:39:30 +10:00
|
|
|
if (acct.domain) {
|
2019-11-10 22:37:13 +11:00
|
|
|
refresh(key, true)
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (acct.domain == 'mstdn.jp') {
|
|
|
|
jp = true
|
2019-10-26 04:13:37 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
})
|
2019-05-19 17:39:30 +10:00
|
|
|
if (obj[0].domain) {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#tl').show()
|
|
|
|
ticker()
|
|
|
|
multiSelector(false)
|
|
|
|
verck(ver, jp)
|
|
|
|
$('.stw').show()
|
|
|
|
$('#something-wrong img').attr('src', '../../img/thinking.svg')
|
2019-02-05 13:33:32 +11:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
ck()
|
2019-05-11 02:31:15 +10:00
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
//ログインポップアップ
|
|
|
|
function login(url) {
|
2019-11-10 22:37:13 +11:00
|
|
|
if ($('#linux:checked').val() == 'on') {
|
|
|
|
var red = 'urn:ietf:wg:oauth:2.0:oob'
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var red = 'thedesk://login'
|
2018-02-26 02:32:10 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.setItem('redirect', red)
|
|
|
|
var start = 'https://' + url + '/api/v1/apps'
|
|
|
|
var httpreq = new XMLHttpRequest()
|
|
|
|
httpreq.open('POST', start, true)
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
|
|
|
httpreq.responseType = 'json'
|
2019-11-04 03:10:06 +11:00
|
|
|
httpreq.send(
|
|
|
|
JSON.stringify({
|
2019-11-10 22:37:13 +11:00
|
|
|
scopes: 'read write follow',
|
|
|
|
client_name: 'TheDesk(PC)',
|
2019-11-04 03:10:06 +11:00
|
|
|
redirect_uris: red,
|
2019-11-10 22:37:13 +11:00
|
|
|
website: 'https://thedesk.top'
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
2019-11-10 22:37:13 +11:00
|
|
|
)
|
2019-11-04 03:10:06 +11:00
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 05:19:26 +11:00
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
if (this.status !== 200) {
|
2019-11-10 22:37:13 +11:00
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
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'
|
|
|
|
localStorage.setItem('domain_' + acct_id, url)
|
|
|
|
localStorage.setItem('client_id', json['client_id'])
|
|
|
|
localStorage.setItem('client_secret', json['client_secret'])
|
|
|
|
$('#auth').show()
|
|
|
|
$('#masara').hide()
|
|
|
|
postMessage(['openUrl', auth], '*')
|
2019-05-19 17:39:30 +10:00
|
|
|
|
2019-11-10 22:37:13 +11:00
|
|
|
if ($('#linux:checked').val() == 'on') {
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
postMessage(['sendSinmpleIpc', 'quit'], '*')
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//テキストボックスにURL入れた
|
|
|
|
function instance() {
|
2019-11-10 22:37:13 +11:00
|
|
|
var url = $('#url').val()
|
|
|
|
login(url)
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//コードを入れた後認証
|
2019-05-19 17:39:30 +10:00
|
|
|
function code(code, mode) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var red = localStorage.getItem('redirect')
|
|
|
|
localStorage.removeItem('redirect')
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!code) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var code = $('#code').val()
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (localStorage.getItem('domain_tmp')) {
|
|
|
|
var url = localStorage.getItem('domain_tmp')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var url = localStorage.getItem('domain_' + acct_id)
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var start = 'https://' + url + '/oauth/token'
|
|
|
|
var id = localStorage.getItem('client_id')
|
|
|
|
var secret = localStorage.getItem('client_secret')
|
2018-01-28 23:22:43 +11:00
|
|
|
fetch(start, {
|
2019-11-10 22:37:13 +11:00
|
|
|
method: 'POST',
|
2018-01-28 23:22:43 +11:00
|
|
|
headers: {
|
2019-11-10 22:37:13 +11:00
|
|
|
'content-type': 'application/json'
|
2018-01-28 23:22:43 +11:00
|
|
|
},
|
|
|
|
body: JSON.stringify({
|
2019-11-10 22:37:13 +11:00
|
|
|
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
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
response.text().then(function(text) {
|
2019-11-10 22:37:13 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.catch(function(error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(json) {
|
2019-11-10 22:37:13 +11:00
|
|
|
todo(json)
|
|
|
|
if (json['access_token']) {
|
|
|
|
localStorage.setItem(url + '_at', json['access_token'])
|
|
|
|
if (mode == 'manager') {
|
|
|
|
getdataAdv(url, json['access_token'])
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
getdata()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
})
|
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() {
|
2019-11-10 22:37:13 +11:00
|
|
|
var acct_id = 0
|
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
|
2018-01-28 23:22:43 +11:00
|
|
|
fetch(start, {
|
2019-11-10 22:37:13 +11:00
|
|
|
method: 'GET',
|
2018-01-28 23:22:43 +11:00
|
|
|
headers: {
|
2019-11-10 22:37:13 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2019-10-31 02:30:26 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
response.text().then(function(text) {
|
2019-11-10 22:37:13 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.catch(function(error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(json) {
|
|
|
|
if (json.error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
console.error('Error:' + json.error)
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
|
|
|
return
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var avatar = json['avatar']
|
2019-11-04 03:10:06 +11:00
|
|
|
//missingがmissingなやつ
|
2019-11-10 22:37:13 +11:00
|
|
|
if (avatar == '/avatars/original/missing.png') {
|
|
|
|
avatar = './img/missing.svg'
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
var obj = [
|
|
|
|
{
|
|
|
|
at: at,
|
2019-11-10 22:37:13 +11:00
|
|
|
name: json['display_name'],
|
2019-11-04 03:10:06 +11:00
|
|
|
domain: domain,
|
2019-11-10 22:37:13 +11:00
|
|
|
user: json['acct'],
|
2019-11-04 03:10:06 +11:00
|
|
|
prof: avatar,
|
2019-11-10 22:37:13 +11:00
|
|
|
id: json['id'],
|
|
|
|
vis: json['source']['privacy']
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
]
|
|
|
|
var json = JSON.stringify(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'])
|
|
|
|
localStorage.setItem('prof_' + acct_id, avatar)
|
|
|
|
$('#masara').hide()
|
|
|
|
$('#auth').hide()
|
|
|
|
$('#tl').show()
|
|
|
|
parseColumn()
|
|
|
|
ckdb()
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
//ユーザーデータ取得(追加)
|
|
|
|
function getdataAdv(domain, at) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
|
2018-02-18 16:43:11 +11:00
|
|
|
fetch(start, {
|
2019-11-10 22:37:13 +11:00
|
|
|
method: 'GET',
|
2018-02-18 16:43:11 +11:00
|
|
|
headers: {
|
2019-11-10 22:37:13 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + at
|
2018-03-31 13:39:06 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
response.text().then(function(text) {
|
2019-11-10 22:37:13 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.catch(function(error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(json) {
|
|
|
|
if (json.error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
console.error('Error:' + json.error)
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
|
|
|
return
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var avatar = json['avatar']
|
2019-11-04 03:10:06 +11:00
|
|
|
//missingがmissingなやつ
|
2019-11-10 22:37:13 +11:00
|
|
|
if (avatar == '/avatars/original/missing.png') {
|
|
|
|
avatar = '../../img/missing.svg'
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json['source']['privacy']) {
|
|
|
|
var priv = json['source']['privacy']
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var priv = 'public'
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
var add = {
|
|
|
|
at: at,
|
2019-11-10 22:37:13 +11:00
|
|
|
name: json['display_name'],
|
2019-11-04 03:10:06 +11:00
|
|
|
domain: domain,
|
2019-11-10 22:37:13 +11:00
|
|
|
user: json['acct'],
|
2019-11-04 03:10:06 +11:00
|
|
|
prof: avatar,
|
2019-11-10 22:37:13 +11:00
|
|
|
id: json['id'],
|
2019-11-04 03:10:06 +11:00
|
|
|
vis: priv
|
2019-11-10 22:37:13 +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'])
|
|
|
|
localStorage.setItem('prof_' + target, avatar)
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
localStorage.setItem('multi', json)
|
|
|
|
location.href = 'index.html'
|
|
|
|
})
|
2018-02-18 16:43:11 +11:00
|
|
|
}
|
2018-08-17 03:21:40 +10:00
|
|
|
//ユーザーデータ更新
|
2019-05-19 17:39:30 +10:00
|
|
|
function refresh(target, loadskip) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
if (obj[target].mode == 'misskey') {
|
|
|
|
return
|
2018-08-17 03:21:40 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var start = 'https://' + obj[target].domain + '/api/v1/accounts/verify_credentials'
|
2018-08-17 03:21:40 +10:00
|
|
|
fetch(start, {
|
2019-11-10 22:37:13 +11:00
|
|
|
method: 'GET',
|
2018-08-17 03:21:40 +10:00
|
|
|
headers: {
|
2019-11-10 22:37:13 +11:00
|
|
|
'content-type': 'application/json',
|
|
|
|
Authorization: 'Bearer ' + obj[target].at
|
2018-08-17 03:21:40 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
response.text().then(function(text) {
|
2019-11-10 22:37:13 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.catch(function(error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
todo(error)
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(json) {
|
|
|
|
if (json.error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
console.error('Error:' + json.error)
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
|
|
|
return
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var avatar = json['avatar']
|
2019-11-04 03:10:06 +11:00
|
|
|
//missingがmissingなやつ
|
2019-11-10 22:37:13 +11:00
|
|
|
if (avatar == '/avatars/original/missing.png' || !avatar) {
|
|
|
|
avatar = './img/missing.svg'
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
|
|
|
var ref = {
|
|
|
|
at: obj[target].at,
|
2019-11-10 22:37:13 +11:00
|
|
|
name: json['display_name'],
|
2019-11-04 03:10:06 +11:00
|
|
|
domain: obj[target].domain,
|
2019-11-10 22:37:13 +11:00
|
|
|
user: json['acct'],
|
2019-11-04 03:10:06 +11:00
|
|
|
prof: avatar,
|
2019-11-10 22:37:13 +11:00
|
|
|
id: json['id'],
|
|
|
|
vis: json['source']['privacy']
|
|
|
|
}
|
|
|
|
if (obj[target].background) {
|
|
|
|
ref.background = obj[target].background
|
|
|
|
}
|
|
|
|
if (obj[target].text) {
|
|
|
|
ref.text = obj[target].text
|
|
|
|
}
|
|
|
|
localStorage.setItem('name_' + target, json['display_name'])
|
|
|
|
localStorage.setItem('user_' + target, json['acct'])
|
|
|
|
localStorage.setItem('user-id_' + target, json['id'])
|
|
|
|
localStorage.setItem('prof_' + target, avatar)
|
|
|
|
localStorage.setItem('follow_' + target, json['following_count'])
|
|
|
|
if (json['source']['sensitive']) {
|
|
|
|
localStorage.setItem('nsfw_' + target, 'true')
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.removeItem('nsfw_' + target)
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
obj[target] = ref
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
localStorage.setItem('multi', json)
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!loadskip) {
|
2019-11-10 22:37:13 +11:00
|
|
|
load()
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
})
|
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) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
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)
|
|
|
|
localStorage.removeItem('followlocale_' + acct_id)
|
|
|
|
if (domain == 'kirishima.cloud') {
|
|
|
|
localStorage.setItem('kirishima', 'true')
|
|
|
|
} else if (domain == 'imastodon.net') {
|
|
|
|
localStorage.setItem('imas', 'true')
|
|
|
|
$('.imasonly').show()
|
2018-02-09 03:43:11 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
|
|
|
var bbcode = domain + '_bbcode'
|
|
|
|
var letters = domain + '_letters'
|
|
|
|
var quoteMarker = domain + '_quote'
|
|
|
|
if (localStorage.getItem('instance')) {
|
|
|
|
var json = JSON.parse(localStorage.getItem('instance'))
|
|
|
|
if (json[quoteMarker] == 'enabled') {
|
|
|
|
localStorage.setItem('quoters', 'true')
|
|
|
|
localStorage.setItem('quote_' + acct_id, 'true')
|
2019-09-08 02:33:01 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (json[bbcode]) {
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[bbcode] == 'enabled') {
|
|
|
|
localStorage.setItem('bb_' + acct_id, 'true')
|
2018-02-25 19:41:34 +11:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.removeItem('bb_' + acct_id)
|
|
|
|
$("[data-activates='bbcode']").addClass('disabled')
|
|
|
|
$("[data-activates='bbcode']").prop('disabled', true)
|
2018-08-07 01:14:55 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.removeItem('bb_' + acct_id)
|
|
|
|
$("[data-activates='bbcode']").addClass('disabled')
|
|
|
|
$("[data-activates='bbcode']").addClass('disabled', true)
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
|
|
|
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_markdown'] == 'enabled') {
|
|
|
|
localStorage.setItem('md_' + acct_id, 'true')
|
|
|
|
$('.markdown').show()
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('.anti-markdown').hide()
|
|
|
|
$('.markdown').hide()
|
|
|
|
localStorage.removeItem('bb_' + acct_id)
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_home']) {
|
|
|
|
localStorage.setItem('home_' + acct_id, json[domain + '_home'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_local']) {
|
|
|
|
localStorage.setItem('local_' + acct_id, json[domain + '_local'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_public']) {
|
|
|
|
localStorage.setItem('public_' + acct_id, json[domain + '_public'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_notification']) {
|
|
|
|
localStorage.setItem('notification_' + acct_id, json[domain + '_notification'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_post']) {
|
|
|
|
localStorage.setItem('post_' + acct_id, json[domain + '_post'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_fav']) {
|
|
|
|
localStorage.setItem('fav_' + acct_id, json[domain + '_fav'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_bt']) {
|
|
|
|
localStorage.setItem('bt_' + acct_id, json[domain + '_bt'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json[domain + '_follow']) {
|
|
|
|
localStorage.setItem('followlocale_' + acct_id, json[domain + '_follow'])
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2018-02-25 19:41:34 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (localStorage.getItem('mode_' + domain) != 'misskey') {
|
|
|
|
var start = 'https://' + domain + '/api/v1/instance'
|
2018-08-17 03:21:40 +10:00
|
|
|
fetch(start, {
|
2019-11-10 22:37:13 +11:00
|
|
|
method: 'GET',
|
2018-08-17 03:21:40 +10:00
|
|
|
headers: {
|
2019-11-10 22:37:13 +11:00
|
|
|
'content-type': 'application/json'
|
2018-08-17 03:21:40 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(response) {
|
2019-11-10 22:37:13 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.catch(function(error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(json) {
|
|
|
|
if (json.error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
console.error(json.error)
|
|
|
|
return
|
2018-09-17 21:55:00 +10:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
if (json) {
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json['max_toot_chars']) {
|
|
|
|
localStorage.setItem('letters_' + acct_id, json['max_toot_chars'])
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (json['urls']['streaming_api']) {
|
|
|
|
localStorage.setItem('streaming_' + acct_id, json['urls']['streaming_api'])
|
2019-11-04 03:10:06 +11:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.removeItem('streaming_' + acct_id)
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2018-09-17 21:55:00 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
})
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2018-08-17 03:21:40 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
//アカウントを選択…を実装
|
2019-07-07 00:16:41 +10:00
|
|
|
function multiSelector(parseC) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var multi = localStorage.getItem('multi')
|
2018-01-28 23:22:43 +11:00
|
|
|
if (!multi) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var obj = []
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
localStorage.setItem('multi', json)
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var obj = JSON.parse(multi)
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var templete
|
|
|
|
if (localStorage.getItem('mainuse') == 'main') {
|
|
|
|
var last = localStorage.getItem('main')
|
|
|
|
} else if (localStorage.getItem('last-use')) {
|
|
|
|
var last = localStorage.getItem('last-use')
|
|
|
|
if (last == 'webview' || last == 'noauth') {
|
|
|
|
last = '0'
|
2019-05-20 23:34:58 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var last = '0'
|
2018-05-20 16:17:10 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
last = last + ''
|
|
|
|
var sel
|
2019-05-19 17:39:30 +10:00
|
|
|
if (obj.length < 1) {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>')
|
|
|
|
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-04 03:10:06 +11:00
|
|
|
Object.keys(obj).forEach(function(key) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var acct = obj[key]
|
|
|
|
var list = key * 1 + 1
|
|
|
|
if (key + '' === last) {
|
|
|
|
sel = 'selected'
|
|
|
|
var domain = acct.domain
|
|
|
|
localStorage.setItem('domain_' + key, domain)
|
|
|
|
if (idata[domain + '_letters']) {
|
|
|
|
$('#textarea').attr('data-length', idata[domain + '_letters'])
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var maxletters = localStorage.getItem('letters_' + key)
|
2019-05-19 17:39:30 +10:00
|
|
|
if (maxletters > 0) {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#textarea').attr('data-length', maxletters)
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#textarea').attr('data-length', 500)
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2018-09-01 23:02:15 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (idata[domain + '_glitch']) {
|
|
|
|
$('#local-button').removeClass('hide')
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
var profimg = acct.prof
|
2019-08-11 03:52:32 +10:00
|
|
|
//localStorage.setItem("prof_" + key, profimg);
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!profimg) {
|
2019-11-10 22:37:13 +11:00
|
|
|
profimg = '../../img/missing.svg'
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#acct-sel-prof').attr('src', profimg)
|
2019-05-19 17:39:30 +10:00
|
|
|
if (domain) {
|
2019-11-10 22:37:13 +11:00
|
|
|
var cc = '(' + domain + ')'
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
var cc = ''
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#toot-post-btn').text(lang.lang_toot + cc)
|
|
|
|
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)
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (domain == 'kirishima.cloud') {
|
|
|
|
$('#faicon-btn').show()
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#faicon-btn').hide()
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
if (domain == 'imastodon.net') {
|
|
|
|
trendTag()
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
$('#trendtag').html('')
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
|
|
|
} else {
|
2019-11-10 22:37:13 +11:00
|
|
|
sel = ''
|
2018-04-16 23:58:14 +10:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
templete =
|
|
|
|
'<option value="' +
|
|
|
|
key +
|
|
|
|
'" data-icon="' +
|
|
|
|
acct.prof +
|
|
|
|
'" class="left circle" ' +
|
|
|
|
sel +
|
|
|
|
'>' +
|
|
|
|
acct.user +
|
|
|
|
'@' +
|
|
|
|
acct.domain +
|
|
|
|
'</option>'
|
|
|
|
$('.acct-sel').append(templete)
|
|
|
|
})
|
|
|
|
$('#src-acct-sel').append('<option value="tootsearch">Tootsearch</option>')
|
|
|
|
$('#add-acct-sel').append(
|
|
|
|
'<option value="noauth">' +
|
|
|
|
lang.lang_login_noauth +
|
|
|
|
'</option><option value="webview">Twitter</option>'
|
|
|
|
)
|
|
|
|
$('#dir-acct-sel').append('<option value="noauth">' + lang.lang_login_noauth + '</option>')
|
2018-03-27 13:39:35 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
$('select').formSelect()
|
2019-11-04 03:10:06 +11:00
|
|
|
if (!parseC) {
|
2019-11-10 22:37:13 +11:00
|
|
|
parseColumn(null, true)
|
2019-07-07 00:16:41 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2018-02-18 16:43:11 +11:00
|
|
|
|
2018-03-14 05:31:31 +11:00
|
|
|
//バージョンエンコ
|
2019-05-19 17:39:30 +10:00
|
|
|
function enc(ver) {
|
2019-11-10 22:37:13 +11:00
|
|
|
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() {
|
2019-11-10 22:37:13 +11:00
|
|
|
var start = 'https://toot.app/toot/'
|
2018-12-09 05:46:01 +11:00
|
|
|
fetch(start, {
|
2019-11-10 22:37:13 +11:00
|
|
|
method: 'GET',
|
2018-12-09 05:46:01 +11:00
|
|
|
headers: {
|
2019-11-10 22:37:13 +11:00
|
|
|
'content-type': 'application/json'
|
2018-12-09 05:46:01 +11:00
|
|
|
}
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(response) {
|
|
|
|
if (!response.ok) {
|
|
|
|
response.text().then(function(text) {
|
2019-11-10 22:37:13 +11:00
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
return response.json()
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.catch(function(error) {
|
2019-11-10 22:37:13 +11:00
|
|
|
console.error(error)
|
2019-11-04 03:10:06 +11:00
|
|
|
})
|
|
|
|
.then(function(json) {
|
|
|
|
if (json) {
|
2019-11-10 22:37:13 +11:00
|
|
|
localStorage.setItem('ticker', JSON.stringify(json))
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
}
|