add Pleroma refreshable token
This commit is contained in:
parent
eaec63adb8
commit
cc5ba8af0f
|
@ -88,4 +88,7 @@ i.left {
|
|||
|
||||
#domain-list .title {
|
||||
font-size: 1.3rem;
|
||||
}
|
||||
.text-line-icon {
|
||||
font-size: 1rem;
|
||||
}
|
|
@ -32,7 +32,7 @@ function ck() {
|
|||
} else {
|
||||
var obj = JSON.parse(multi)
|
||||
var jp = false
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var acct = obj[key]
|
||||
if (acct.domain) {
|
||||
refresh(key, true)
|
||||
|
@ -50,7 +50,7 @@ function ck() {
|
|||
let tipsName = localStorage.getItem('tips')
|
||||
const matchCID = /custom:([abcdef0-9]{8}-[abcdef0-9]{4}-4[abcdef0-9]{3}-[abcdef0-9]{4}-[abcdef0-9]{12})/
|
||||
if (tipsName) {
|
||||
if(tipsName.match(matchCID)) {
|
||||
if (tipsName.match(matchCID)) {
|
||||
const id = tipsName.match(matchCID)[1]
|
||||
tips('custom', id)
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ function login(url) {
|
|||
website: 'https://thedesk.top'
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -149,20 +149,20 @@ function code(code, mode) {
|
|||
code: code
|
||||
})
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
todo(json)
|
||||
if (json['access_token']) {
|
||||
localStorage.setItem(url + '_at', json['access_token'])
|
||||
|
@ -188,20 +188,20 @@ function getdata() {
|
|||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json.error) {
|
||||
console.error('Error:' + json.error)
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
||||
|
@ -246,20 +246,20 @@ function getdataAdv(domain, at) {
|
|||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json.error) {
|
||||
console.error('Error:' + json.error)
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
||||
|
@ -298,34 +298,40 @@ function getdataAdv(domain, at) {
|
|||
})
|
||||
}
|
||||
//ユーザーデータ更新
|
||||
function refresh(target, loadskip) {
|
||||
async function refresh(target, loadskip) {
|
||||
var multi = localStorage.getItem('multi')
|
||||
var obj = JSON.parse(multi)
|
||||
if (obj[target].mode == 'misskey') {
|
||||
return
|
||||
}
|
||||
let at = obj[target].at
|
||||
if (obj[target].rt) {
|
||||
console.log('refresh access token')
|
||||
at = await refreshPleromaAt(obj[target])
|
||||
localStorage.setItem(`acct_${target}_at`, at)
|
||||
}
|
||||
var start = 'https://' + obj[target].domain + '/api/v1/accounts/verify_credentials'
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
Authorization: 'Bearer ' + obj[target].at
|
||||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json.error) {
|
||||
console.error('Error:' + json.error)
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
||||
|
@ -369,6 +375,29 @@ function refresh(target, loadskip) {
|
|||
}
|
||||
})
|
||||
}
|
||||
async function refreshPleromaAt(obj) {
|
||||
const start = 'https://' + obj.domain + '/oauth/token'
|
||||
const rt = obj.rt.split(' ')
|
||||
let promise = await fetch(start, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
grant_type : 'refresh_token',
|
||||
refresh_token: rt[0],
|
||||
client_id: rt[1],
|
||||
client_secret: rt[2]
|
||||
})
|
||||
})
|
||||
|
||||
const json = await promise.json()
|
||||
if (json.access_token) {
|
||||
return json.access_token
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
//MarkdownやBBCodeの対応、文字数制限をチェック
|
||||
//絶対ストリーミングを閉じさせないマン
|
||||
function ckdb(acct_id) {
|
||||
|
@ -454,13 +483,13 @@ function ckdb(acct_id) {
|
|||
'content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json.error) {
|
||||
console.error(json.error)
|
||||
return
|
||||
|
@ -507,7 +536,7 @@ function multiSelector(parseC) {
|
|||
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>')
|
||||
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>')
|
||||
} else {
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var acct = obj[key]
|
||||
var list = key * 1 + 1
|
||||
if (key + '' === last) {
|
||||
|
@ -575,8 +604,8 @@ function multiSelector(parseC) {
|
|||
$('#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>'
|
||||
lang.lang_login_noauth +
|
||||
'</option><option value="webview">Twitter</option>'
|
||||
)
|
||||
$('#dir-acct-sel').append('<option value="noauth">' + lang.lang_login_noauth + '</option>')
|
||||
}
|
||||
|
@ -605,18 +634,18 @@ function ticker() {
|
|||
'content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json) {
|
||||
localStorage.removeItem('ticker')
|
||||
localStorage.setItem('sticker', JSON.stringify(json))
|
||||
|
|
|
@ -36,7 +36,7 @@ function load() {
|
|||
var domains = []
|
||||
var templete
|
||||
$('#acct-list').html('')
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var acct = obj[key]
|
||||
var list = key * 1 + 1
|
||||
if (acct.background != 'def' && acct.text != 'def') {
|
||||
|
@ -55,6 +55,9 @@ function load() {
|
|||
<div class="card-content ">
|
||||
<span class="lts">${list}.</span><img src="${acct.prof}" width="40" height="40" />
|
||||
<span class="card-title">${name}</span>${escapeHTML(acct.user)}@${acct.domain}
|
||||
<a onclick="login('${acct.domain}')" class="pointer white-text waves-effect" title="${lang.lang_manager_refreshAt}">
|
||||
<i class="material-icons text-line-icon">login</i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-action">
|
||||
<button class="btn-flat waves-effect disTar pointer white-text" onclick="refresh('${key}')">
|
||||
|
@ -72,7 +75,7 @@ function load() {
|
|||
})
|
||||
domains = _.uniq(domains)
|
||||
$('#domain-list').html('')
|
||||
Object.keys(domains).forEach(function(key2) {
|
||||
Object.keys(domains).forEach(function (key2) {
|
||||
var domain = domains[key2]
|
||||
if (localStorage.getItem('letters_' + key2)) {
|
||||
var maxChars = localStorage.getItem('letters_' + key2)
|
||||
|
@ -108,7 +111,7 @@ load()
|
|||
support()
|
||||
function maxChars(domain, uid) {
|
||||
var value = $('#maxChars' + uid).val()
|
||||
if(value*1 < 1 || !Number.isInteger(value*1)) {
|
||||
if (value * 1 < 1 || !Number.isInteger(value * 1)) {
|
||||
Swal.fire({
|
||||
type: 'error',
|
||||
title: 'Error'
|
||||
|
@ -127,8 +130,8 @@ function maxChars(domain, uid) {
|
|||
localStorage.removeItem('multi')
|
||||
}
|
||||
}
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
if(obj[key].domain == domain) localStorage.setItem('letters_' + key, value)
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
if (obj[key].domain == domain) localStorage.setItem('letters_' + key, value)
|
||||
})
|
||||
console.log('#maxChars' + uid, value)
|
||||
load()
|
||||
|
@ -208,7 +211,7 @@ function multiDel(target) {
|
|||
cancelButtonText: lang.lang_no
|
||||
}).then(result => {
|
||||
if (result.value) {
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var nk = key - 1
|
||||
//公開範囲(差分のみ)
|
||||
if (key >= target) {
|
||||
|
@ -227,7 +230,9 @@ function multiDel(target) {
|
|||
var olddom = localStorage.getItem('domain_' + key)
|
||||
localStorage.setItem('domain_' + nk, olddom)
|
||||
var oldat = localStorage.getItem('acct_' + key + '_at')
|
||||
var oldrt = localStorage.getItem('acct_' + key + '_rt')
|
||||
localStorage.setItem('acct_' + nk + '_at', oldat)
|
||||
localStorage.setItem('acct_' + nk + '_rt', oldrt)
|
||||
localStorage.setItem('name_' + nk, localStorage.getItem('name_' + key))
|
||||
localStorage.setItem('user_' + target, localStorage.getItem('user_' + key))
|
||||
localStorage.setItem('user-id_' + target, localStorage.getItem('user-id_' + key))
|
||||
|
@ -243,7 +248,7 @@ function multiDel(target) {
|
|||
var col = localStorage.getItem('column')
|
||||
var oldcols = JSON.parse(col)
|
||||
var newcols = []
|
||||
Object.keys(oldcols).forEach(function(key) {
|
||||
Object.keys(oldcols).forEach(function (key) {
|
||||
var nk = key - 1
|
||||
var oldcol = oldcols[key]
|
||||
if (target < oldcol.domain) {
|
||||
|
@ -253,19 +258,19 @@ function multiDel(target) {
|
|||
}
|
||||
var type = oldcol.type
|
||||
var data = null
|
||||
if(oldcol.data) {
|
||||
if (oldcol.data) {
|
||||
data = oldcol.data
|
||||
}
|
||||
var background = null
|
||||
if(oldcol.background) {
|
||||
if (oldcol.background) {
|
||||
background = oldcol.background
|
||||
}
|
||||
var text = null
|
||||
if(oldcol.text) {
|
||||
if (oldcol.text) {
|
||||
text = oldcol.text
|
||||
}
|
||||
var left_fold = false
|
||||
if(oldcol.left_fold) {
|
||||
if (oldcol.left_fold) {
|
||||
left_fold = true
|
||||
}
|
||||
//消した垢のコラムじゃないときコピー
|
||||
|
@ -303,7 +308,7 @@ function multiDel2(target) {
|
|||
obj.splice(target, 1)
|
||||
var json = JSON.stringify(obj)
|
||||
localStorage.setItem('multi', json)
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
if (key >= target) {
|
||||
var oldvis = localStorage.getItem('vis-memory-' + key)
|
||||
if (oldvis) {
|
||||
|
@ -331,7 +336,7 @@ function multiDel2(target) {
|
|||
} else {
|
||||
var cobj = JSON.parse(col)
|
||||
}
|
||||
Object.keys(cobj).forEach(function(key) {
|
||||
Object.keys(cobj).forEach(function (key) {
|
||||
var column = cobj[key]
|
||||
if (column.domain > target) {
|
||||
var nk = key - 1
|
||||
|
@ -351,7 +356,7 @@ function multiDel2(target) {
|
|||
|
||||
//サポートインスタンス
|
||||
function support() {
|
||||
Object.keys(idata).forEach(function(key) {
|
||||
Object.keys(idata).forEach(function (key) {
|
||||
var instance = idata[key]
|
||||
if (instance == 'instance') {
|
||||
templete =
|
||||
|
@ -399,7 +404,7 @@ function login(url) {
|
|||
website: 'https://thedesk.top'
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -437,20 +442,20 @@ function versionChecker(url) {
|
|||
'content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
var version = json.version
|
||||
if (version) {
|
||||
var reg = version.match(/^([0-9])\.[0-9]\.[0-9]/u)
|
||||
|
@ -476,25 +481,25 @@ function versionCompat(prefix, ver, title, real) {
|
|||
'content-type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
var complete = false
|
||||
var ct = 0
|
||||
var jl = 0
|
||||
var jl2 = 0
|
||||
Object.keys(json).forEach(function(key) {
|
||||
Object.keys(json).forEach(function (key) {
|
||||
var data = json[key]
|
||||
if (data) {
|
||||
jl++
|
||||
|
@ -581,7 +586,7 @@ function misskeyLogin(url) {
|
|||
]
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -605,7 +610,7 @@ function misskeyAuth(url, mkc) {
|
|||
appSecret: mkc
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -629,9 +634,8 @@ function instance() {
|
|||
alert('入力形式が違います。(Cutls@mstdn.jpにログインする場合、入力するのは"mstdn.jp"です。)')
|
||||
return false
|
||||
}
|
||||
login(url)
|
||||
login(url)
|
||||
}
|
||||
|
||||
//コード入れてAccessTokenゲット
|
||||
function code(code) {
|
||||
localStorage.removeItem('redirect')
|
||||
|
@ -657,7 +661,7 @@ function code(code) {
|
|||
appSecret: localStorage.getItem('mkc')
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -716,7 +720,7 @@ function code(code) {
|
|||
code: code
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -725,14 +729,16 @@ function code(code) {
|
|||
if (json['access_token']) {
|
||||
$('#auth').hide()
|
||||
$('#add').show()
|
||||
getdata(url, json['access_token'])
|
||||
getdata(url, json)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//ユーザーデータ取得
|
||||
function getdata(domain, at) {
|
||||
function getdata(domain, json) {
|
||||
var at = json['access_token']
|
||||
var rt = `${json['refresh_token']} ${localStorage.getItem('client_id')} ${localStorage.getItem('client_secret')}`
|
||||
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
|
@ -741,20 +747,20 @@ function getdata(domain, at) {
|
|||
Authorization: 'Bearer ' + at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json.error) {
|
||||
console.error('Error:' + json.error)
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
||||
|
@ -772,6 +778,7 @@ function getdata(domain, at) {
|
|||
}
|
||||
var add = {
|
||||
at: at,
|
||||
rt: rt ? rt : null,
|
||||
name: json['display_name'],
|
||||
domain: domain,
|
||||
user: json['acct'],
|
||||
|
@ -782,8 +789,24 @@ function getdata(domain, at) {
|
|||
}
|
||||
var multi = localStorage.getItem('multi')
|
||||
var obj = JSON.parse(multi)
|
||||
var target = obj.length
|
||||
obj.push(add)
|
||||
let addTarget = -1
|
||||
let ct = 0
|
||||
for (let acct of obj) {
|
||||
if (acct.domain === domain && acct.user === json['acct']) {
|
||||
console.log('detected dupl addct')
|
||||
addTarget = ct
|
||||
break
|
||||
}
|
||||
ct++
|
||||
}
|
||||
if (addTarget == -1) {
|
||||
var target = obj.length
|
||||
obj.push(add)
|
||||
} else {
|
||||
console.log('dupl acct_' + addTarget)
|
||||
obj[addTarget] = add
|
||||
var target = addTarget
|
||||
}
|
||||
localStorage.setItem('name_' + target, json['display_name'])
|
||||
localStorage.setItem('user_' + target, json['acct'])
|
||||
localStorage.setItem('user-id_' + target, json['id'])
|
||||
|
@ -807,6 +830,7 @@ function atSetup(type) {
|
|||
var i = $('#misskey-key').val()
|
||||
var add = {
|
||||
at: i,
|
||||
rt: null,
|
||||
name: 'Pseudo Account',
|
||||
domain: url,
|
||||
user: 'user+pseudo',
|
||||
|
@ -820,6 +844,7 @@ function atSetup(type) {
|
|||
var i = $('#code').val()
|
||||
var add = {
|
||||
at: i,
|
||||
rt: null,
|
||||
name: 'Pseudo Account',
|
||||
domain: url,
|
||||
user: 'user+pseudo',
|
||||
|
@ -862,25 +887,25 @@ function refresh(target) {
|
|||
Authorization: 'Bearer ' + obj[target].at
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (json.error) {
|
||||
console.error('Error:' + json.error)
|
||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
||||
|
@ -893,6 +918,7 @@ function refresh(target) {
|
|||
}
|
||||
var ref = {
|
||||
at: obj[target].at,
|
||||
rt: obj[target].rt ? obj[target].rt : null,
|
||||
name: json['display_name'],
|
||||
domain: obj[target].domain,
|
||||
user: json['acct'],
|
||||
|
@ -934,7 +960,7 @@ function misskeyRefresh(obj, target, url) {
|
|||
i: obj[target].at
|
||||
})
|
||||
)
|
||||
httpreq.onreadystatechange = function() {
|
||||
httpreq.onreadystatechange = function () {
|
||||
if (httpreq.readyState === 4) {
|
||||
var json = httpreq.response
|
||||
if (this.status !== 200) {
|
||||
|
@ -944,6 +970,7 @@ function misskeyRefresh(obj, target, url) {
|
|||
var priv = 'public'
|
||||
var add = {
|
||||
at: json.accessToken,
|
||||
rt: null,
|
||||
name: json['user']['name'],
|
||||
domain: url,
|
||||
user: json['user']['username'],
|
||||
|
@ -983,7 +1010,7 @@ function multisel() {
|
|||
$('#src-acct-sel').html('<option value="tootsearch">Tootsearch</option>')
|
||||
$('#add-acct-sel').html('<option value="noauth">' + lang.lang_login_noauth + '</option>')
|
||||
} else {
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
var acct = obj[key]
|
||||
var list = key * 1 + 1
|
||||
if (key == last) {
|
||||
|
@ -1073,10 +1100,10 @@ var oldSuggest
|
|||
var suggest
|
||||
input.addEventListener(
|
||||
'focus',
|
||||
function() {
|
||||
function () {
|
||||
$('#ins-suggest').html('')
|
||||
window.clearInterval(timer)
|
||||
timer = window.setInterval(function() {
|
||||
timer = window.setInterval(function () {
|
||||
var new_val = input.value
|
||||
if (prev_val != new_val) {
|
||||
if (new_val.length > 3) {
|
||||
|
@ -1089,23 +1116,23 @@ input.addEventListener(
|
|||
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
|
||||
}
|
||||
})
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
response.text().then(function (text) {
|
||||
setLog(response.url, response.status, text)
|
||||
})
|
||||
}
|
||||
return response.json()
|
||||
})
|
||||
.catch(function(error) {
|
||||
.catch(function (error) {
|
||||
todo(error)
|
||||
setLog(start, 'JSON', error)
|
||||
console.error(error)
|
||||
})
|
||||
.then(function(json) {
|
||||
.then(function (json) {
|
||||
if (!json.error) {
|
||||
var urls = 'Suggest:'
|
||||
Object.keys(json.instances).forEach(function(key) {
|
||||
Object.keys(json.instances).forEach(function (key) {
|
||||
var url = json.instances[key]
|
||||
urls =
|
||||
urls +
|
||||
|
@ -1127,7 +1154,7 @@ input.addEventListener(
|
|||
|
||||
input.addEventListener(
|
||||
'blur',
|
||||
function() {
|
||||
function () {
|
||||
window.clearInterval(timer)
|
||||
},
|
||||
false
|
||||
|
|
|
@ -51,6 +51,7 @@ function parseColumn(target, dontclose) {
|
|||
localStorage.setItem('prof_' + key, acct.prof)
|
||||
localStorage.setItem('domain_' + key, acct.domain)
|
||||
localStorage.setItem('acct_' + key + '_at', acct.at)
|
||||
localStorage.setItem('acct_' + key + '_rt', acct.rt ? acct.rt : null)
|
||||
if(!target) mastodonBaseStreaming(key)
|
||||
ckdb(key)
|
||||
//フィルターデータ読もう
|
||||
|
|
|
@ -405,6 +405,7 @@ function importSettingsCore(obj) {
|
|||
localStorage.setItem('prof_' + key, acct.prof)
|
||||
localStorage.setItem('domain_' + key, acct.domain)
|
||||
localStorage.setItem('acct_' + key + '_at', acct.at)
|
||||
localStorage.setItem('acct_' + key + '_rt', acct.rt ? acct.rt : null)
|
||||
}
|
||||
localStorage.setItem('column', JSON.stringify(obj.columns))
|
||||
if (obj.config) {
|
||||
|
|
|
@ -1,154 +1,133 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="@@lang@@">
|
||||
<head>
|
||||
<title>Account Manager - TheDesk</title>
|
||||
<meta content="width=device-width,initial-scale=1.0" name="viewport" />
|
||||
<link href="../../css/themes.css" type="text/css" rel="stylesheet">
|
||||
<link
|
||||
href="../../@@node_base@@/materialize-css/dist/css/materialize.css"
|
||||
type="text/css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link href="../../css/master.css" type="text/css" rel="stylesheet" />
|
||||
<link href="../../css/tl.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../css/userdata.css" rel="stylesheet" type="text/css" />
|
||||
<link
|
||||
href="../../@@node_base@@/@fortawesome/fontawesome-free/css/all.min.css"
|
||||
type="text/css"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link href="../../css/acct.css" rel="stylesheet" type="text/css" />
|
||||
<meta charset="utf-8" />
|
||||
@@comment-start@@
|
||||
<script type="text/javascript">
|
||||
var _jipt = []
|
||||
_jipt.push(['project', 'thedesk'])
|
||||
</script>
|
||||
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
|
||||
@@comment-end@@
|
||||
@@pwa@@ @@store@@
|
||||
</head>
|
||||
|
||||
<body id="mainView" class="@@pwaClass@@">
|
||||
<script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../js/platform/first.js"></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../../@@node_base@@/materialize-css/dist/js/materialize.js"
|
||||
></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="../../@@node_base@@/sweetalert2/dist/sweetalert2.all.min.js"
|
||||
></script>
|
||||
<script>
|
||||
var misskeytoken = false
|
||||
</script>
|
||||
<script type="text/javascript" src="../../js/common/time.js"></script>
|
||||
<div class="hide-first">
|
||||
<a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;"
|
||||
>@@back@@</a
|
||||
><br />
|
||||
<h5>@@list@@</h5>
|
||||
<div id="acct-list"></div>
|
||||
<div class="divider"></div>
|
||||
</div>
|
||||
<div class="hide-second">
|
||||
<a href="setting.html">@@haveExported@@</a>
|
||||
</div>
|
||||
<div>
|
||||
<h5>@@add@@</h5>
|
||||
<br />
|
||||
<div id="add">
|
||||
<div class="row">
|
||||
<div class="col s8">
|
||||
@@addAcct@@<br />
|
||||
<input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp" />
|
||||
<div id="ins-suggest"></div>
|
||||
<button class="btn waves-effect" onclick="instance()">Login</button><br />
|
||||
<div class="pwa">
|
||||
@@codesetupwarn@@<br />
|
||||
<label>
|
||||
<input type="checkbox" class="filled-in" id="linux" />
|
||||
<span>@@codesetup@@</span>
|
||||
</label>
|
||||
<br />
|
||||
</div>
|
||||
<head>
|
||||
<title>Account Manager - TheDesk</title>
|
||||
<meta content="width=device-width,initial-scale=1.0" name="viewport" />
|
||||
<link href="../../css/themes.css" type="text/css" rel="stylesheet">
|
||||
<link href="../../@@node_base@@/materialize-css/dist/css/materialize.css" type="text/css" rel="stylesheet" />
|
||||
<link href="../../css/master.css" type="text/css" rel="stylesheet" />
|
||||
<link href="../../css/tl.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../css/userdata.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../@@node_base@@/@fortawesome/fontawesome-free/css/all.min.css" type="text/css" rel="stylesheet" />
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link href="../../css/acct.css" rel="stylesheet" type="text/css" />
|
||||
<meta charset="utf-8" />
|
||||
@@comment-start@@
|
||||
<script type="text/javascript">
|
||||
var _jipt = []
|
||||
_jipt.push(['project', 'thedesk'])
|
||||
</script>
|
||||
<script type="text/javascript" src="https://cdn.crowdin.com/jipt/jipt.js"></script>
|
||||
@@comment-end@@
|
||||
@@pwa@@ @@store@@
|
||||
</head>
|
||||
|
||||
<body id="mainView" class="@@pwaClass@@">
|
||||
<script type="text/javascript" src="../../@@node_base@@/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript" src="../../js/platform/first.js"></script>
|
||||
<script type="text/javascript" src="../../@@node_base@@/materialize-css/dist/js/materialize.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
<script type="text/javascript" src="../../@@node_base@@/sweetalert2/dist/sweetalert2.all.min.js"></script>
|
||||
<script>
|
||||
var misskeytoken = false
|
||||
</script>
|
||||
<script type="text/javascript" src="../../js/common/time.js"></script>
|
||||
<div class="hide-first">
|
||||
<a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;">@@back@@</a><br />
|
||||
<h5>@@list@@</h5>
|
||||
<div id="acct-list"></div>
|
||||
<div class="divider"></div>
|
||||
</div>
|
||||
<div class="hide-second">
|
||||
<a href="setting.html">@@haveExported@@</a>
|
||||
</div>
|
||||
<div>
|
||||
<h5>@@add@@</h5>
|
||||
<br />
|
||||
<div id="add">
|
||||
<div class="row">
|
||||
<div class="col s8">
|
||||
@@addAcct@@<br />
|
||||
<input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp" />
|
||||
<div id="ins-suggest"></div>
|
||||
<button class="btn waves-effect" onclick="instance()">Login</button><br />
|
||||
<div class="pwa">
|
||||
@@codesetupwarn@@<br />
|
||||
<label>
|
||||
<input type="checkbox" class="filled-in" id="misskey" />
|
||||
<span>@@thisismisskey@@</span> </label
|
||||
><br />
|
||||
</div>
|
||||
<div class="col s4 scr" aria-hidden="true">
|
||||
<span style="font-family:Open Sans;">Supports</span>
|
||||
<div id="support" class="collection transparent"></div>
|
||||
<input type="checkbox" class="filled-in" id="linux" />
|
||||
<span>@@codesetup@@</span>
|
||||
</label>
|
||||
<br />
|
||||
</div>
|
||||
<label>
|
||||
<input type="checkbox" class="filled-in" id="misskey" />
|
||||
<span>@@thisismisskey@@</span> </label><br />
|
||||
</div>
|
||||
<div class="col s4 scr" aria-hidden="true">
|
||||
<span style="font-family:Open Sans;">Supports</span>
|
||||
<div id="support" class="collection transparent"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="auth" style="display:none">
|
||||
@@codepastewarn@@<br />
|
||||
<input type="text" id="code" placeholder="@@codepaste@@" required />
|
||||
<button class="btn waves-effect" onclick="code()">Auth</button><br />
|
||||
<br />
|
||||
<a onclick="atSetup()" class="pointer">@@accessTokenSetup@@</a>
|
||||
<div id="compt" style="display:none" class="scr">
|
||||
<h5>ログイン前に必ずご確認ください</h5>
|
||||
<span id="compt-instance"></span>はバージョンが<span id="compt-ver"></span
|
||||
>のため以下の機能がご利用いただけません。
|
||||
<span id="compt-warn" style="display:none"
|
||||
>また、このインスタンスはMastodonではなくそのAPI上の互換実装であり、TheDeskでは利用を想定していないため非保証となります。</span
|
||||
>
|
||||
<ul id="compt-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="misskeylogin" style="display:none">
|
||||
<h5>AppSecret</h5>
|
||||
@@misskeylogin@@<br />
|
||||
<input type="hidden" id="misskey-url" />
|
||||
<input type="text" id="misskey-key" placeholder="@@codepaste@@" required />
|
||||
<button class="btn waves-effect" onclick="misskeyLogin()">Auth</button><br />
|
||||
<br />
|
||||
<a onclick="atSetup('misskey')" class="pointer">@@accessTokenSetup@@</a>
|
||||
</div>
|
||||
<div id="auth" style="display:none">
|
||||
@@codepastewarn@@<br />
|
||||
<input type="text" id="code" placeholder="@@codepaste@@" required />
|
||||
<button class="btn waves-effect" onclick="code()">Auth</button><br />
|
||||
<br />
|
||||
<a onclick="atSetup()" class="pointer">@@accessTokenSetup@@</a>
|
||||
<div id="compt" style="display:none" class="scr">
|
||||
<h5>ログイン前に必ずご確認ください</h5>
|
||||
<span id="compt-instance"></span>はバージョンが<span id="compt-ver"></span>のため以下の機能がご利用いただけません。
|
||||
<span id="compt-warn"
|
||||
style="display:none">また、このインスタンスはMastodonではなくそのAPI上の互換実装であり、TheDeskでは利用を想定していないため非保証となります。</span>
|
||||
<ul id="compt-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hide-first">
|
||||
<h5>@@mainacct@@</h5>
|
||||
<div class="input-field" style="width:300px">
|
||||
<span data-trans="your_acct">@@selacct@@</span>
|
||||
<br />
|
||||
<select
|
||||
id="main-acct-sel"
|
||||
class="acct-sel"
|
||||
style="color:black"
|
||||
onchange="mainacct()"
|
||||
></select>
|
||||
<label></label>
|
||||
</div>
|
||||
<ul id="domain-list" class="collection transparent"></ul>
|
||||
<div id="instance-data">
|
||||
Some instance data by
|
||||
<a href="https://instances.social" target="_blank">instances.social API</a><br />
|
||||
<h5 id="ins-title"></h5>
|
||||
Administered by:<a id="ins-admin"></a><br />
|
||||
<span id="ins-desc"></span><br />
|
||||
<img src="../../img/loading.svg" id="ins-prof" width="200" /><br />
|
||||
<br />
|
||||
@@domain@@:<span id="ins-name"></span><br />
|
||||
@@connect@@:<span id="ins-connect"></span>@@ko@@<br />
|
||||
@@toots@@:<span id="ins-toot"></span>@@ko@@<br />
|
||||
@@users@@:<span id="ins-user"></span>@@users@@<br />
|
||||
@@safety@@:<span id="ins-per"></span>%<br />
|
||||
@@ver@@:<span id="ins-ver"></span>@<span id="ins-upd"></span><br />
|
||||
</div>
|
||||
<div id="misskeylogin" style="display:none">
|
||||
<h5>AppSecret</h5>
|
||||
@@misskeylogin@@<br />
|
||||
<input type="hidden" id="misskey-url" />
|
||||
<input type="text" id="misskey-key" placeholder="@@codepaste@@" required />
|
||||
<button class="btn waves-effect" onclick="misskeyLogin()">Auth</button><br />
|
||||
<br />
|
||||
<a onclick="atSetup('misskey')" class="pointer">@@accessTokenSetup@@</a>
|
||||
</div>
|
||||
<script type="text/javascript" src="../../js/ui/theme.js"></script>
|
||||
<script type="text/javascript" src="../../js/ui/tips.js"></script>
|
||||
<script type="text/javascript" src="../../js/platform/end.js"></script>
|
||||
<script type="text/javascript" src="../../js/common/sha256.js"></script>
|
||||
<script type="text/javascript" src="../../@@node_base@@/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../js/login/instance.js"></script>
|
||||
<script type="text/javascript" src="../../js/login/manager.js"></script>
|
||||
<script type="text/javascript" src="../../js/tl/date.js"></script>
|
||||
<script>$('body').addClass(localStorage.getItem('platform'))</script>
|
||||
</body>
|
||||
</html>
|
||||
</div>
|
||||
<div class="hide-first">
|
||||
<h5>@@mainacct@@</h5>
|
||||
<div class="input-field" style="width:300px">
|
||||
<span data-trans="your_acct">@@selacct@@</span>
|
||||
<br />
|
||||
<select id="main-acct-sel" class="acct-sel" style="color:black" onchange="mainacct()"></select>
|
||||
<label></label>
|
||||
</div>
|
||||
<ul id="domain-list" class="collection transparent"></ul>
|
||||
<div id="instance-data">
|
||||
Some instance data by
|
||||
<a href="https://instances.social" target="_blank">instances.social API</a><br />
|
||||
<h5 id="ins-title"></h5>
|
||||
Administered by:<a id="ins-admin"></a><br />
|
||||
<span id="ins-desc"></span><br />
|
||||
<img src="../../img/loading.svg" id="ins-prof" width="200" /><br />
|
||||
<br />
|
||||
@@domain@@:<span id="ins-name"></span><br />
|
||||
@@connect@@:<span id="ins-connect"></span>@@ko@@<br />
|
||||
@@toots@@:<span id="ins-toot"></span>@@ko@@<br />
|
||||
@@users@@:<span id="ins-user"></span>@@users@@<br />
|
||||
@@safety@@:<span id="ins-per"></span>%<br />
|
||||
@@ver@@:<span id="ins-ver"></span>@<span id="ins-upd"></span><br />
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="../../js/ui/theme.js"></script>
|
||||
<script type="text/javascript" src="../../js/ui/tips.js"></script>
|
||||
<script type="text/javascript" src="../../js/platform/end.js"></script>
|
||||
<script type="text/javascript" src="../../js/common/sha256.js"></script>
|
||||
<script type="text/javascript" src="../../@@node_base@@/lodash/lodash.min.js"></script>
|
||||
<script type="text/javascript" src="../../js/login/instance.js"></script>
|
||||
<script type="text/javascript" src="../../js/login/manager.js"></script>
|
||||
<script type="text/javascript" src="../../js/tl/date.js"></script>
|
||||
<script>$('body').addClass(localStorage.getItem('platform'))</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user