2018-01-28 23:22:43 +11:00
|
|
|
|
//アカウントマネージャ
|
|
|
|
|
//最初に読むやつ
|
|
|
|
|
function load() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#acct-list').html('')
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (location.search) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
|
|
|
|
|
var mode = m[1]
|
|
|
|
|
var codex = m[2]
|
|
|
|
|
if (mode == 'first' && codex == 'true') {
|
|
|
|
|
$('body').addClass('first')
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2019-04-11 02:52:01 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var prof = localStorage.getItem('prof')
|
|
|
|
|
$('.my-prof').attr('src', prof)
|
|
|
|
|
var name = localStorage.getItem('name')
|
|
|
|
|
$('#now-name').text(name)
|
|
|
|
|
var user = localStorage.getItem('user')
|
|
|
|
|
$('#now-user').text(user)
|
|
|
|
|
var domain = localStorage.getItem('domain')
|
|
|
|
|
$('.now-domain').text(domain)
|
|
|
|
|
var multi = localStorage.getItem('multi')
|
2018-01-28 23:22:43 +11:00
|
|
|
|
if (!multi) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var obj = []
|
2018-01-28 23:22:43 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var obj = JSON.parse(multi)
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (obj[0]) {
|
|
|
|
|
if (!obj[0].at) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
obj = []
|
|
|
|
|
localStorage.removeItem('multi')
|
2018-08-17 03:21:40 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
|
console.table(obj)
|
2019-12-19 03:00:17 +11:00
|
|
|
|
var domains = []
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var templete
|
2019-12-19 03:00:17 +11:00
|
|
|
|
$('#acct-list').html('')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var acct = obj[key]
|
|
|
|
|
var list = key * 1 + 1
|
|
|
|
|
if (acct.background != 'def' && acct.text != 'def') {
|
|
|
|
|
var style = 'style="background-color:#' + acct.background + '; color:' + acct.text + ';"'
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var style = ''
|
2018-06-18 00:26:45 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (acct.name) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var name = acct.name
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var name = acct.user
|
2018-08-23 03:29:39 +10:00
|
|
|
|
}
|
2019-12-19 03:00:17 +11:00
|
|
|
|
domains.push(acct.domain)
|
2019-11-09 00:52:54 +11:00
|
|
|
|
templete = `
|
|
|
|
|
<div id="acct_${key}" class="card" ${style}>
|
|
|
|
|
<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}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-action">
|
2019-12-19 03:00:17 +11:00
|
|
|
|
<button class="btn-flat waves-effect disTar pointer white-text" onclick="refresh('${key}')">
|
|
|
|
|
<i class="material-icons left">refresh</i>${lang.lang_manager_refresh}
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn-flat waves-effect disTar pointer red-text" onclick="multiDel('${key}')">
|
|
|
|
|
<i class="material-icons left">delete</i>${lang.lang_manager_delete}
|
|
|
|
|
</button><br />${lang.lang_manager_color}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
<div id="colorsel_${key}" class="colorsel"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
$('#acct-list').append(templete)
|
|
|
|
|
colorpicker(key)
|
|
|
|
|
})
|
2019-12-19 03:00:17 +11:00
|
|
|
|
domains = _.uniq(domains)
|
|
|
|
|
$('#domain-list').html('')
|
|
|
|
|
Object.keys(domains).forEach(function(key2) {
|
|
|
|
|
var domain = domains[key2]
|
|
|
|
|
if (localStorage.getItem('letters_' + key2)) {
|
|
|
|
|
var maxChars = localStorage.getItem('letters_' + key2)
|
|
|
|
|
} else {
|
|
|
|
|
var maxChars = 500
|
|
|
|
|
}
|
|
|
|
|
var templete = `
|
|
|
|
|
<li class="collection-item transparent">
|
|
|
|
|
<div>
|
|
|
|
|
<p class="title">${domain}</p>
|
|
|
|
|
${lang.lang_manager_maxChars} <input style="width: 100px" value="${maxChars}" id="maxChars${key2}">
|
|
|
|
|
<button class="btn-flat waves-effect" onclick="maxChars('${domain}', '${key2}')">
|
|
|
|
|
<i class="material-icons">send</i>
|
|
|
|
|
</button>
|
|
|
|
|
<button class="btn-flat waves-effect secondary-content" onclick="data('${domain}', '${key2}')">
|
|
|
|
|
<i class="material-icons left">info</i>${lang.lang_manager_info}
|
|
|
|
|
</button>
|
|
|
|
|
</div></li>
|
|
|
|
|
`
|
|
|
|
|
$('#domain-list').append(templete)
|
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
multisel()
|
|
|
|
|
var acctN = localStorage.getItem('acct')
|
2018-01-28 23:22:43 +11:00
|
|
|
|
if (!acctN) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.setItem('acct', 0)
|
|
|
|
|
var acctN = 0
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
2019-04-08 01:14:06 +10:00
|
|
|
|
//全部チェックアリでいいと思うの
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#linux').prop('checked', true)
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
//最初に読む
|
2019-11-09 00:52:54 +11:00
|
|
|
|
load()
|
|
|
|
|
support()
|
2019-12-19 03:00:17 +11:00
|
|
|
|
function maxChars(domain, uid) {
|
|
|
|
|
var value = $('#maxChars' + uid).val()
|
|
|
|
|
if(value*1 < 1 || !Number.isInteger(value*1)) {
|
|
|
|
|
Swal.fire({
|
|
|
|
|
type: 'error',
|
|
|
|
|
title: 'Error'
|
|
|
|
|
})
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
if (!multi) {
|
|
|
|
|
var obj = []
|
|
|
|
|
} else {
|
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
}
|
|
|
|
|
if (obj[0]) {
|
|
|
|
|
if (!obj[0].at) {
|
|
|
|
|
obj = []
|
|
|
|
|
localStorage.removeItem('multi')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
|
if(obj[key].domain == domain) localStorage.setItem('letters_' + key, value)
|
|
|
|
|
})
|
|
|
|
|
console.log('#maxChars' + uid, value)
|
|
|
|
|
load()
|
|
|
|
|
}
|
2018-09-01 23:02:15 +10:00
|
|
|
|
//instances.social/instances API
|
2019-12-19 03:00:17 +11:00
|
|
|
|
async function data(domain, acct_id) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#ins-upd').text('Loading...')
|
|
|
|
|
$('#ins-add').text('Loading...')
|
|
|
|
|
$('#ins-connect').text('Loading...')
|
|
|
|
|
$('#ins-toot').text('Loading...')
|
|
|
|
|
$('#ins-sys').text('Loading...')
|
|
|
|
|
$('#ins-per').text('Loading...')
|
|
|
|
|
$('#ins-user').text('Loading...')
|
|
|
|
|
$('#ins-ver').text('Loading...')
|
|
|
|
|
$('#ins-name').text('Loading...')
|
|
|
|
|
$('#ins-prof').attr('src', '../../img/loading.svg')
|
|
|
|
|
var start = 'https://instances.social/api/1.0/instances/show?name=' + domain
|
2019-12-19 03:00:17 +11:00
|
|
|
|
let promise = await fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2018-01-28 23:22:43 +11:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
Authorization:
|
|
|
|
|
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
2019-12-19 03:00:17 +11:00
|
|
|
|
var json = await promise.json()
|
|
|
|
|
$('#ins-name').text(json.name)
|
|
|
|
|
$('#ins-upd').text(date(json.checked_at, 'full'))
|
|
|
|
|
$('#ins-add').text(date(json.added_at, 'full'))
|
|
|
|
|
$('#ins-connect').text(json.connections)
|
|
|
|
|
$('#ins-toot').text(json.statuses)
|
|
|
|
|
$('#ins-sys').text(date(json.updated_at, 'full'))
|
|
|
|
|
$('#ins-per').text(json.uptime * 100)
|
|
|
|
|
$('#ins-user').text(json.users)
|
|
|
|
|
$('#ins-ver').text(json.version)
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + domain + '/api/v1/instance'
|
2019-12-19 03:00:17 +11:00
|
|
|
|
let promise2 = await fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2018-09-01 23:02:15 +10:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json'
|
2018-09-01 23:02:15 +10:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
2019-12-19 03:00:17 +11:00
|
|
|
|
var json = await promise2.json()
|
|
|
|
|
$('#ins-title').text(json.title)
|
|
|
|
|
$('#ins-desc').html(json.description)
|
|
|
|
|
$('#ins-email').text(json.email)
|
|
|
|
|
$('#ins-toot').text(json.stats.status_count)
|
|
|
|
|
$('#ins-user').text(json.stats.user_count)
|
|
|
|
|
$('#ins-ver').text(json.version)
|
|
|
|
|
$('#ins-prof').attr('src', json.thumbnail)
|
|
|
|
|
$('#ins-admin').text(
|
|
|
|
|
escapeHTML(json.contact_account.display_name) + '(' + json.contact_account.acct + ')'
|
|
|
|
|
)
|
|
|
|
|
$('#ins-admin').attr(
|
|
|
|
|
'href',
|
|
|
|
|
'index.html?mode=user&code=' + json.contact_account.username + '@' + domain
|
|
|
|
|
)
|
|
|
|
|
if (json['max_toot_chars']) {
|
|
|
|
|
localStorage.setItem('letters_' + acct_id, json['max_toot_chars'])
|
|
|
|
|
load()
|
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//アカウントデータ 消す
|
|
|
|
|
function multiDel(target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
2018-07-07 03:51:48 +10:00
|
|
|
|
//削除確認ダイアログ
|
2019-06-22 02:06:32 +10:00
|
|
|
|
Swal.fire({
|
|
|
|
|
title: lang.lang_manager_logout,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
text: obj[target]['user'] + '@' + obj[target]['domain'] + lang.lang_manager_confirm,
|
|
|
|
|
type: 'warning',
|
2019-06-22 02:06:32 +10:00
|
|
|
|
showCancelButton: true,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
confirmButtonColor: '#3085d6',
|
|
|
|
|
cancelButtonColor: '#d33',
|
2019-06-22 02:06:32 +10:00
|
|
|
|
confirmButtonText: lang.lang_yesno,
|
|
|
|
|
cancelButtonText: lang.lang_no
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}).then(result => {
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (result.value) {
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var nk = key - 1
|
2019-06-22 02:06:32 +10:00
|
|
|
|
//公開範囲(差分のみ)
|
|
|
|
|
if (key >= target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var oldvis = localStorage.getItem('vis-memory-' + key)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (oldvis) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.setItem('vis-memory-' + nk, oldvis)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//独自ロケール
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.removeItem('home_' + key)
|
|
|
|
|
localStorage.removeItem('local_' + key)
|
|
|
|
|
localStorage.removeItem('public_' + key)
|
|
|
|
|
localStorage.removeItem('notification_' + key)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
//アクセストークンとドメイン、プロフ(差分)
|
|
|
|
|
if (key > target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var olddom = localStorage.getItem('domain_' + key)
|
|
|
|
|
localStorage.setItem('domain_' + nk, olddom)
|
|
|
|
|
var oldat = localStorage.getItem('acct_' + key + '_at')
|
|
|
|
|
localStorage.setItem('acct_' + nk + '_at', oldat)
|
|
|
|
|
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))
|
|
|
|
|
localStorage.setItem('prof_' + target, localStorage.getItem('prof_' + key))
|
2018-07-07 03:51:48 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2019-06-22 02:06:32 +10:00
|
|
|
|
//とりあえず消す
|
2019-11-09 00:52:54 +11:00
|
|
|
|
obj.splice(target, 1)
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
|
|
|
|
load()
|
2019-06-22 02:06:32 +10:00
|
|
|
|
//カラムデータコンフリクト
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var col = localStorage.getItem('column')
|
|
|
|
|
var oldcols = JSON.parse(col)
|
|
|
|
|
var newcols = []
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(oldcols).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var nk = key - 1
|
|
|
|
|
var oldcol = oldcols[key]
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (target < oldcol.domain) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var newdom = oldcol.domain - 1
|
2019-06-22 02:06:32 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var newdom = oldcol.domain
|
2019-06-22 02:06:32 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var type = oldcol.type
|
2019-06-22 02:06:32 +10:00
|
|
|
|
//消した垢のコラムじゃないときコピー
|
|
|
|
|
if (target != oldcol.domain) {
|
|
|
|
|
var add = {
|
|
|
|
|
domain: newdom,
|
|
|
|
|
type: type
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
|
|
|
|
newcols.push(add)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
|
|
|
|
var json = JSON.stringify(newcols)
|
|
|
|
|
localStorage.setItem('column', json)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2018-07-07 03:51:48 +10:00
|
|
|
|
}
|
|
|
|
|
function multiDel2(target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
Swal.fire({
|
|
|
|
|
title: lang.lang_manager_logout,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
text: obj[target]['user'] + '@' + obj[target]['domain'] + lang.lang_manager_confirm,
|
|
|
|
|
type: 'warning',
|
2019-06-22 02:06:32 +10:00
|
|
|
|
showCancelButton: true,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
confirmButtonColor: '#3085d6',
|
|
|
|
|
cancelButtonColor: '#d33',
|
2019-06-22 02:06:32 +10:00
|
|
|
|
confirmButtonText: lang.lang_yesno,
|
|
|
|
|
cancelButtonText: lang.lang_no
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}).then(result => {
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (result.value) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
obj.splice(target, 1)
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (key >= target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var oldvis = localStorage.getItem('vis-memory-' + key)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (oldvis) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var nk = key - 1
|
|
|
|
|
localStorage.setItem('vis-memory-' + nk, oldvis)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.removeItem('home_' + key)
|
|
|
|
|
localStorage.removeItem('local_' + key)
|
|
|
|
|
localStorage.removeItem('public_' + key)
|
|
|
|
|
localStorage.removeItem('notification_' + key)
|
|
|
|
|
refresh(key)
|
|
|
|
|
})
|
|
|
|
|
var col = localStorage.getItem('column')
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (!col) {
|
2019-10-22 16:34:23 +11:00
|
|
|
|
var obj = [
|
|
|
|
|
{
|
|
|
|
|
domain: 0,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
type: 'local'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
]
|
|
|
|
|
localStorage.setItem('card_0', 'true')
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('column', json)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var cobj = JSON.parse(col)
|
2018-07-07 03:51:48 +10:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(cobj).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var column = cobj[key]
|
2019-06-22 02:06:32 +10:00
|
|
|
|
if (column.domain > target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var nk = key - 1
|
|
|
|
|
column.domain = nk
|
|
|
|
|
cobj[key] = column
|
2019-06-22 02:06:32 +10:00
|
|
|
|
} else if (column.domain == target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.removeItem('card_' + tlid)
|
|
|
|
|
cobj.splice(key, 1)
|
2019-06-22 02:06:32 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
|
|
|
|
var json = JSON.stringify(column)
|
|
|
|
|
localStorage.setItem('column', json)
|
|
|
|
|
load()
|
2018-07-07 03:51:48 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//サポートインスタンス
|
|
|
|
|
function support() {
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(idata).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var instance = idata[key]
|
|
|
|
|
if (instance == 'instance') {
|
|
|
|
|
templete =
|
|
|
|
|
'<a onclick="login(\'' +
|
|
|
|
|
key +
|
|
|
|
|
'\')" class="collection-item pointer transparent">' +
|
|
|
|
|
idata[key + '_name'] +
|
|
|
|
|
'(' +
|
|
|
|
|
key +
|
|
|
|
|
')</a>'
|
|
|
|
|
$('#support').append(templete)
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//URL指定してポップアップ
|
|
|
|
|
function login(url) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
if ($('#misskey:checked').val() == 'on') {
|
|
|
|
|
$('#misskey').prop('checked', true)
|
|
|
|
|
misskeyLogin(url)
|
|
|
|
|
return
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#compt').hide()
|
|
|
|
|
if ($('#linux:checked').val() == 'on') {
|
|
|
|
|
var red = 'urn:ietf:wg:oauth:2.0:oob'
|
|
|
|
|
if (~url.indexOf('pixelfed')) {
|
|
|
|
|
red = 'https://thedesk.top/hello.html'
|
2019-10-14 02:28:44 +11:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var red = 'thedesk://manager'
|
2018-02-26 02:32:10 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +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-10-22 16:34:23 +11:00
|
|
|
|
httpreq.send(
|
|
|
|
|
JSON.stringify({
|
2019-11-09 00:52:54 +11:00
|
|
|
|
scopes: 'read write follow',
|
|
|
|
|
client_name: 'TheDesk(PC)',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
redirect_uris: red,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
website: 'https://thedesk.top'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 05:19:26 +11:00
|
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
|
if (this.status !== 200) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
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)
|
|
|
|
|
localStorage.setItem('client_id', json['client_id'])
|
|
|
|
|
localStorage.setItem('client_secret', json['client_secret'])
|
|
|
|
|
$('#auth').show()
|
|
|
|
|
versionChecker(url)
|
|
|
|
|
$('#add').hide()
|
|
|
|
|
postMessage(['openUrl', auth], '*')
|
|
|
|
|
if ($('#linux:checked').val() == 'on') {
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
postMessage(['sendSinmpleIpc', 'quit'], '*')
|
2018-02-26 02:32:10 +11:00
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
2019-09-30 03:22:44 +10:00
|
|
|
|
}
|
|
|
|
|
function versionChecker(url) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + url + '/api/v1/instance'
|
2019-09-30 03:22:44 +10:00
|
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2019-09-30 03:22:44 +10:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json'
|
2019-09-30 03:22:44 +10:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(response) {
|
2019-10-31 02:30:26 +11:00
|
|
|
|
if (!response.ok) {
|
2019-11-04 03:10:06 +11:00
|
|
|
|
response.text().then(function(text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
return response.json()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.catch(function(error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
todo(error)
|
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
|
console.error(error)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var version = json.version
|
2019-10-22 16:34:23 +11:00
|
|
|
|
if (version) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var reg = version.match(/^([0-9])\.[0-9]\.[0-9]/u)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
if (reg) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
versionCompat(reg[1], reg, json.title, reg[0])
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2019-09-30 03:22:44 +10:00
|
|
|
|
}
|
2019-10-14 02:28:44 +11:00
|
|
|
|
function versionCompat(prefix, ver, title, real) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#compt-instance').text(title)
|
|
|
|
|
$('#compt-ver').text(real)
|
|
|
|
|
if (~real.indexOf('compatible')) {
|
|
|
|
|
$('#compt-warn').show()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#compt-warn').hide()
|
2019-09-30 03:29:26 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#compt-list').html('')
|
|
|
|
|
var start = '../../source/version.json'
|
2019-09-30 03:22:44 +10:00
|
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2019-09-30 03:22:44 +10:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(function(response) {
|
2019-10-31 02:30:26 +11:00
|
|
|
|
if (!response.ok) {
|
2019-11-04 03:10:06 +11:00
|
|
|
|
response.text().then(function(text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
return response.json()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.catch(function(error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
todo(error)
|
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
|
console.error(error)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(json) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var complete = false
|
|
|
|
|
var ct = 0
|
|
|
|
|
var jl = 0
|
|
|
|
|
var jl2 = 0
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(json).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var data = json[key]
|
2019-10-22 16:34:23 +11:00
|
|
|
|
if (data) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
jl++
|
2019-10-22 16:34:23 +11:00
|
|
|
|
if (key != real && !complete) {
|
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var e = ''
|
2019-10-22 16:34:23 +11:00
|
|
|
|
if (i == 0) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
e = '(' + key + ')'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#compt-list').append('<li>' + data[i] + e + '</li>')
|
|
|
|
|
ct++
|
|
|
|
|
e = ''
|
2019-09-30 03:22:44 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
jl2++
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else if (!complete) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
complete = true
|
2019-09-30 03:22:44 +10:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
|
|
|
|
if (lang.language == 'ja' && ct > 0) {
|
|
|
|
|
if (jl2 != jl && prefix != '1') {
|
|
|
|
|
$('#compt').show()
|
2019-09-30 03:22:44 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
|
|
|
|
//これが後のMisskeyである。
|
2018-08-21 04:26:14 +10:00
|
|
|
|
function misskeyLogin(url) {
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (!url) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var url = $('#misskey-url').val()
|
2018-08-21 04:26:14 +10:00
|
|
|
|
}
|
2020-04-08 16:27:47 +10:00
|
|
|
|
var start = 'https://' + url + '/api/app/create'
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var httpreq = new XMLHttpRequest()
|
|
|
|
|
httpreq.open('POST', start, true)
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
|
|
|
|
httpreq.responseType = 'json'
|
|
|
|
|
localStorage.setItem('msky', 'true')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.send(
|
|
|
|
|
JSON.stringify({
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: 'TheDesk(PC)',
|
|
|
|
|
description: 'Mastodon and Misskey client for PC',
|
|
|
|
|
permission: [
|
|
|
|
|
'account-read',
|
|
|
|
|
'account-write',
|
|
|
|
|
'account/read',
|
|
|
|
|
'account/write',
|
|
|
|
|
'drive-read',
|
|
|
|
|
'drive-write',
|
|
|
|
|
'favorite-read',
|
|
|
|
|
'favorite-write',
|
|
|
|
|
'favorites-read',
|
|
|
|
|
'following-read',
|
|
|
|
|
'following-write',
|
|
|
|
|
'messaging-read',
|
|
|
|
|
'messaging-write',
|
|
|
|
|
'note-read',
|
|
|
|
|
'note-write',
|
|
|
|
|
'notification-read',
|
|
|
|
|
'notification-write',
|
|
|
|
|
'reaction-read',
|
|
|
|
|
'reaction-write',
|
|
|
|
|
'vote-read',
|
|
|
|
|
'vote-write',
|
|
|
|
|
'read:account',
|
|
|
|
|
'write:account',
|
|
|
|
|
'read:drive',
|
|
|
|
|
'write:drive',
|
|
|
|
|
'read:blocks',
|
|
|
|
|
'write:blocks',
|
|
|
|
|
'read:favorites',
|
|
|
|
|
'write:favorites',
|
|
|
|
|
'read:following',
|
|
|
|
|
'write:following',
|
|
|
|
|
'read:messaging',
|
|
|
|
|
'write:messaging',
|
|
|
|
|
'read:mutes',
|
|
|
|
|
'write:mutes',
|
|
|
|
|
'write:notes',
|
|
|
|
|
'read:notifications',
|
|
|
|
|
'write:notifications',
|
|
|
|
|
'read:reactions',
|
|
|
|
|
'write:reactions',
|
|
|
|
|
'write:votes'
|
|
|
|
|
]
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 19:14:47 +11:00
|
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
|
if (this.status !== 200) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
misskeyAuth(url, json.secret)
|
2018-08-21 04:26:14 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
2019-03-08 19:14:47 +11:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function misskeyAuth(url, mkc) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + url + '/api/auth/session/generate'
|
|
|
|
|
var httpreq = new XMLHttpRequest()
|
|
|
|
|
httpreq.open('POST', start, true)
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
|
|
|
|
httpreq.responseType = 'json'
|
2019-03-08 19:14:47 +11:00
|
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.setItem('mkc', mkc)
|
|
|
|
|
localStorage.setItem('msky', 'true')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.send(
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
appSecret: mkc
|
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 05:19:26 +11:00
|
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
|
if (this.status !== 200) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var token = json.token
|
|
|
|
|
$('#auth').show()
|
|
|
|
|
$('#code').val(token)
|
|
|
|
|
$('#add').hide()
|
|
|
|
|
$('#misskey').prop('checked', false)
|
|
|
|
|
localStorage.setItem('domain_tmp', url)
|
|
|
|
|
postMessage(['openUrl', json.url], '*')
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//テキストボックスにURL入れた
|
|
|
|
|
function instance() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var url = $('#url').val()
|
|
|
|
|
if (url.indexOf('@') != -1 || url.indexOf('https') != -1) {
|
|
|
|
|
alert('入力形式が違います。(Cutls@mstdn.jpにログインする場合、入力するのは"mstdn.jp"です。)')
|
|
|
|
|
return false
|
2018-08-21 04:26:14 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
login(url)
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//コード入れてAccessTokenゲット
|
2018-02-18 16:43:11 +11:00
|
|
|
|
function code(code) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.removeItem('redirect')
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (!code) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var code = $('#code').val()
|
|
|
|
|
$('#code').val('')
|
2018-02-18 16:43:11 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
if (!code || code == '') {
|
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error: no code', displayLength: 5000 })
|
|
|
|
|
return false
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var url = localStorage.getItem('domain_tmp')
|
|
|
|
|
localStorage.removeItem('domain_tmp')
|
|
|
|
|
if (localStorage.getItem('msky') == 'true') {
|
|
|
|
|
var start = 'https://' + url + '/api/auth/session/userkey'
|
|
|
|
|
var httpreq = new XMLHttpRequest()
|
|
|
|
|
httpreq.open('POST', start, true)
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
|
|
|
|
httpreq.responseType = 'json'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.send(
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
token: code,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
appSecret: localStorage.getItem('mkc')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 05:19:26 +11:00
|
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
|
if (this.status !== 200) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var i = sha256(json.accessToken + localStorage.getItem('mkc'))
|
|
|
|
|
var avatar = json['user']['avatarUrl']
|
|
|
|
|
var priv = 'public'
|
2018-07-30 21:03:49 +10:00
|
|
|
|
var add = {
|
|
|
|
|
at: i,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: json['user']['name'],
|
2018-08-21 04:26:14 +10:00
|
|
|
|
domain: url,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
user: json['user']['username'],
|
2018-07-30 21:03:49 +10:00
|
|
|
|
prof: avatar,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
id: json['user']['id'],
|
2018-08-21 04:26:14 +10:00
|
|
|
|
vis: priv,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
mode: 'misskey'
|
2019-04-11 02:52:01 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.setItem('mode_' + url, 'misskey')
|
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
var target = obj.length
|
|
|
|
|
obj.push(add)
|
|
|
|
|
localStorage.setItem('name_' + target, json['user']['name'])
|
|
|
|
|
localStorage.setItem('user_' + target, json['user']['username'])
|
|
|
|
|
localStorage.setItem('user-id_' + target, json['user']['id'])
|
|
|
|
|
localStorage.setItem('prof_' + target, avatar)
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
|
|
|
|
if ($('body').hasClass('first')) {
|
|
|
|
|
location.href = 'index.html'
|
|
|
|
|
}
|
|
|
|
|
load()
|
|
|
|
|
return
|
2018-07-30 21:03:49 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
|
|
|
|
return
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var red = 'urn:ietf:wg:oauth:2.0:oob'
|
|
|
|
|
if (~url.indexOf('pixelfed')) {
|
|
|
|
|
red = 'https://thedesk.top/hello.html'
|
2019-10-14 02:28:44 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + url + '/oauth/token'
|
|
|
|
|
var id = localStorage.getItem('client_id')
|
|
|
|
|
var secret = localStorage.getItem('client_secret')
|
|
|
|
|
var httpreq = new XMLHttpRequest()
|
|
|
|
|
httpreq.open('POST', start, true)
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
|
|
|
|
httpreq.responseType = 'json'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.send(
|
|
|
|
|
JSON.stringify({
|
2019-11-09 00:52:54 +11:00
|
|
|
|
grant_type: 'authorization_code',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
redirect_uri: red,
|
|
|
|
|
client_id: id,
|
|
|
|
|
client_secret: secret,
|
|
|
|
|
code: code
|
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-03-08 05:19:26 +11:00
|
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
|
if (this.status !== 200) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
if (json['access_token']) {
|
|
|
|
|
$('#auth').hide()
|
|
|
|
|
$('#add').show()
|
|
|
|
|
getdata(url, json['access_token'])
|
2018-08-17 03:21:40 +10:00
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
//ユーザーデータ取得
|
|
|
|
|
function getdata(domain, at) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + domain + '/api/v1/accounts/verify_credentials'
|
2018-01-28 23:22:43 +11:00
|
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2018-01-28 23:22:43 +11:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
Authorization: 'Bearer ' + at
|
2018-07-07 03:51:48 +10:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(response) {
|
2019-10-31 02:30:26 +11:00
|
|
|
|
if (!response.ok) {
|
2019-11-04 03:10:06 +11:00
|
|
|
|
response.text().then(function(text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
return response.json()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.catch(function(error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
todo(error)
|
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
|
console.error(error)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(json) {
|
|
|
|
|
if (json.error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
console.error('Error:' + json.error)
|
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
|
|
|
|
return
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var avatar = json['avatar']
|
2019-10-22 16:34:23 +11:00
|
|
|
|
//missingがmissingなやつ
|
2019-11-09 00:52:54 +11:00
|
|
|
|
if (avatar == '/avatars/original/missing.png') {
|
|
|
|
|
avatar = '../../img/missing.svg'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
if (json['source']) {
|
|
|
|
|
var priv = json['source']['privacy']
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var priv = 'public'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
|
|
|
|
var add = {
|
|
|
|
|
at: at,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: json['display_name'],
|
2019-10-22 16:34:23 +11:00
|
|
|
|
domain: domain,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
user: json['acct'],
|
2019-10-22 16:34:23 +11:00
|
|
|
|
prof: avatar,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
id: json['id'],
|
2019-10-22 16:34:23 +11:00
|
|
|
|
vis: priv,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
mode: 'mastodon'
|
|
|
|
|
}
|
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
var target = obj.length
|
|
|
|
|
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)
|
|
|
|
|
if ($('body').hasClass('first')) {
|
|
|
|
|
location.href = 'index.html'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
load()
|
|
|
|
|
})
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
|
|
|
|
//アクセストークン直接入力
|
|
|
|
|
function atSetup(type) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var url = localStorage.getItem('domain_tmp')
|
|
|
|
|
localStorage.removeItem('domain_tmp')
|
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var avatar = '../../img/missing.svg'
|
|
|
|
|
var priv = 'public'
|
|
|
|
|
if (type == 'misskey') {
|
|
|
|
|
var i = $('#misskey-key').val()
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var add = {
|
2019-10-22 16:34:23 +11:00
|
|
|
|
at: i,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: 'Pseudo Account',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
domain: url,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
user: 'user+pseudo',
|
2018-03-31 13:39:06 +11:00
|
|
|
|
prof: avatar,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
id: 'id+pseudo',
|
2018-08-21 04:26:14 +10:00
|
|
|
|
vis: priv,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
mode: 'misskey'
|
|
|
|
|
}
|
|
|
|
|
localStorage.setItem('mode_' + url, 'misskey')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var i = $('#code').val()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
var add = {
|
|
|
|
|
at: i,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: 'Pseudo Account',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
domain: url,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
user: 'user+pseudo',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
prof: avatar,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
id: 'id+pseudo',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
vis: priv,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
mode: ''
|
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
if (!i || i == '') {
|
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error: access token', displayLength: 5000 })
|
|
|
|
|
return false
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
var target = obj.length
|
|
|
|
|
obj.push(add)
|
|
|
|
|
localStorage.setItem('name_' + target, add['name'])
|
|
|
|
|
localStorage.setItem('user_' + target, add['username'])
|
|
|
|
|
localStorage.setItem('user-id_' + target, add['id'])
|
|
|
|
|
localStorage.setItem('prof_' + target, avatar)
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
|
|
|
|
refresh(target)
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ユーザーデータ更新
|
|
|
|
|
function refresh(target) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
console.log(obj)
|
|
|
|
|
if (obj[target].mode == 'misskey') {
|
|
|
|
|
misskeyRefresh(obj, target, obj[target].domain)
|
|
|
|
|
return
|
2018-07-30 21:03:49 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + obj[target].domain + '/api/v1/accounts/verify_credentials'
|
2018-01-28 23:22:43 +11:00
|
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2018-01-28 23:22:43 +11:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
Authorization: 'Bearer ' + obj[target].at
|
2019-10-05 04:51:05 +10:00
|
|
|
|
}
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(response) {
|
2019-10-31 02:30:26 +11:00
|
|
|
|
if (!response.ok) {
|
|
|
|
|
response.text().then(function(text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
|
})
|
2019-10-31 02:30:26 +11:00
|
|
|
|
}
|
|
|
|
|
if (!response.ok) {
|
2019-11-04 03:10:06 +11:00
|
|
|
|
response.text().then(function(text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
return response.json()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.catch(function(error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
todo(error)
|
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
|
console.error(error)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(json) {
|
|
|
|
|
if (json.error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
console.error('Error:' + json.error)
|
|
|
|
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
|
|
|
|
return
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var avatar = json['avatar']
|
2019-10-22 16:34:23 +11:00
|
|
|
|
//missingがmissingなやつ
|
2019-11-09 00:52:54 +11:00
|
|
|
|
if (avatar == '/avatars/original/missing.png' || !avatar) {
|
|
|
|
|
avatar = './img/missing.svg'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
|
|
|
|
var ref = {
|
|
|
|
|
at: obj[target].at,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: json['display_name'],
|
2019-10-22 16:34:23 +11:00
|
|
|
|
domain: obj[target].domain,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
user: json['acct'],
|
2019-10-22 16:34:23 +11:00
|
|
|
|
prof: avatar,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
id: json['id'],
|
|
|
|
|
vis: json['source']['privacy']
|
|
|
|
|
}
|
2019-11-10 22:37:13 +11:00
|
|
|
|
if (obj[target].background) {
|
|
|
|
|
ref.background = obj[target].background
|
|
|
|
|
}
|
|
|
|
|
if (obj[target].text) {
|
|
|
|
|
ref.text = obj[target].text
|
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
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)
|
|
|
|
|
if (json['source']['sensitive']) {
|
|
|
|
|
localStorage.setItem('nsfw_' + target, 'true')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
localStorage.removeItem('nsfw_' + target)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
obj[target] = ref
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
2018-01-28 23:22:43 +11:00
|
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
|
load()
|
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function misskeyRefresh(obj, target, url) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://' + url + '/api/users/show'
|
|
|
|
|
var httpreq = new XMLHttpRequest()
|
|
|
|
|
httpreq.open('POST', start, true)
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
|
|
|
|
httpreq.responseType = 'json'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.send(
|
|
|
|
|
JSON.stringify({
|
|
|
|
|
username: obj[target].user,
|
|
|
|
|
i: obj[target].at
|
|
|
|
|
})
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
httpreq.onreadystatechange = function() {
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (httpreq.readyState === 4) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var json = httpreq.response
|
2019-11-04 03:10:06 +11:00
|
|
|
|
if (this.status !== 200) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(start, this.status, json)
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var avatar = json['user']['avatarUrl']
|
|
|
|
|
var priv = 'public'
|
2019-05-19 17:39:30 +10:00
|
|
|
|
var add = {
|
|
|
|
|
at: json.accessToken,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
name: json['user']['name'],
|
2019-05-19 17:39:30 +10:00
|
|
|
|
domain: url,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
user: json['user']['username'],
|
2019-05-19 17:39:30 +10:00
|
|
|
|
prof: avatar,
|
2019-11-09 00:52:54 +11:00
|
|
|
|
id: json['user']['id'],
|
2019-05-19 17:39:30 +10:00
|
|
|
|
vis: priv
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
|
var target = obj.length
|
|
|
|
|
obj.push(add)
|
|
|
|
|
localStorage.setItem('name_' + target, json['user']['name'])
|
|
|
|
|
localStorage.setItem('user_' + target, json['user']['username'])
|
|
|
|
|
localStorage.setItem('user-id_' + target, json['user']['id'])
|
|
|
|
|
localStorage.setItem('prof_' + target, avatar)
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
|
|
|
|
load()
|
|
|
|
|
return
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}
|
2018-07-30 21:03:49 +10:00
|
|
|
|
}
|
2018-05-20 16:17:10 +10:00
|
|
|
|
//アカウントを選択…を実装
|
|
|
|
|
function multisel() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var multi = localStorage.getItem('multi')
|
2018-05-20 16:17:10 +10:00
|
|
|
|
if (!multi) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var obj = []
|
|
|
|
|
var json = JSON.stringify(obj)
|
|
|
|
|
localStorage.setItem('multi', json)
|
2018-05-20 16:17:10 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var obj = JSON.parse(multi)
|
2018-05-20 16:17:10 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var templete
|
|
|
|
|
var last = localStorage.getItem('main')
|
|
|
|
|
var sel
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (obj.length < 1) {
|
2019-11-09 00:52:54 +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-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var acct = obj[key]
|
|
|
|
|
var list = key * 1 + 1
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (key == last) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
sel = 'selected'
|
|
|
|
|
mainb = '(' + lang.lang_manager_def + ')'
|
|
|
|
|
var domain = localStorage.getItem('domain_' + key)
|
|
|
|
|
var profimg = localStorage.getItem('prof_' + key)
|
|
|
|
|
var domain = localStorage.getItem('domain_' + key)
|
2019-05-19 17:39:30 +10:00
|
|
|
|
if (!profimg) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
profimg = '../../img/missing.svg'
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
sel = ''
|
|
|
|
|
mainb = ''
|
2018-05-20 16:17:10 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
template = `
|
|
|
|
|
<option value="${key}" data-icon="${acct.prof}" class="left circle" ${sel}>
|
|
|
|
|
${acct.user}@${acct.domain}${mainb}
|
|
|
|
|
</option>
|
|
|
|
|
`
|
2019-11-09 02:15:03 +11:00
|
|
|
|
$('.acct-sel').append(template)
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2018-05-20 16:17:10 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('select').formSelect()
|
2018-05-20 16:17:10 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function mainacct() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var acct_id = $('#main-acct-sel').val()
|
|
|
|
|
localStorage.setItem('main', acct_id)
|
|
|
|
|
M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 })
|
2018-06-18 00:26:45 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function colorpicker(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
temp = `<div onclick="coloradd('${key}','def','def')" class="pointer exc">${lang.lang_manager_none}</div>
|
|
|
|
|
<div onclick="coloradd('${key}','f44336','white')" class="red white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','e91e63','white')" class="pink white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','9c27b0','white')" class="purple white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','673ab7','white')" class="deep-purple white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','3f51b5','white')" class="indigo white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','2196f3','white')" class="blue white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','03a9f4','black')" class="light-blue black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','00bcd4','black')" class="cyan black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','009688','white')" class="teal white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','4caf50','black')" class="green black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','8bc34a','black')" class="light-green black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','cddc39','black')" class="lime black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','ffeb3b','black')" class="yellow black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','ffc107','black')" class="amber black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','ff9800','black')" class="orange black-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','ff5722','white')" class="deep-orange white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','795548','white')" class="brown white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','9e9e9e','white')" class="grey white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','607d8b','white')" class="blue-grey white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','000000','white')" class="black white-text pointer"></div>
|
|
|
|
|
<div onclick="coloradd('${key}','ffffff','black')" class="white black-text pointer"></div>`
|
|
|
|
|
$('#colorsel_' + key).html(temp)
|
2018-06-18 00:26:45 +10:00
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
function coloradd(key, bg, txt) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var col = localStorage.getItem('multi')
|
|
|
|
|
var o = JSON.parse(col)
|
|
|
|
|
var obj = o[key]
|
|
|
|
|
obj.background = bg
|
|
|
|
|
obj.text = txt
|
|
|
|
|
o[key] = obj
|
|
|
|
|
var json = JSON.stringify(o)
|
|
|
|
|
localStorage.setItem('multi', json)
|
|
|
|
|
if (txt == 'def') {
|
|
|
|
|
$('#acct_' + key).attr('style', '')
|
2019-05-19 17:39:30 +10:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#acct_' + key).css('background-color', '#' + bg)
|
|
|
|
|
if (txt == 'black') {
|
|
|
|
|
var bghex = '000000'
|
|
|
|
|
var ichex = '9e9e9e'
|
|
|
|
|
} else if (txt == 'white') {
|
|
|
|
|
var bghex = 'ffffff'
|
|
|
|
|
var ichex = 'eeeeee'
|
2019-05-19 17:39:30 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#acct_' + key + ' .nex').css('color', '#' + ichex)
|
|
|
|
|
$('#acct_' + key).css('color', '#' + bghex)
|
2018-06-18 00:26:45 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//入力時にハッシュタグと@をサジェスト
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var timer = null
|
2018-06-18 00:26:45 +10:00
|
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var input = document.getElementById('url')
|
2018-06-18 00:26:45 +10:00
|
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var prev_val = input.value
|
|
|
|
|
var oldSuggest
|
|
|
|
|
var suggest
|
2019-10-22 16:34:23 +11:00
|
|
|
|
input.addEventListener(
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'focus',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
function() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
$('#ins-suggest').html('')
|
|
|
|
|
window.clearInterval(timer)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
timer = window.setInterval(function() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var new_val = input.value
|
2019-10-22 16:34:23 +11:00
|
|
|
|
if (prev_val != new_val) {
|
|
|
|
|
if (new_val.length > 3) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var start = 'https://instances.social/api/1.0/instances/search?q=' + new_val
|
2019-10-22 16:34:23 +11:00
|
|
|
|
fetch(start, {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
method: 'GET',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
headers: {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
Authorization:
|
|
|
|
|
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(function(response) {
|
2019-10-31 02:30:26 +11:00
|
|
|
|
if (!response.ok) {
|
2019-11-04 03:10:06 +11:00
|
|
|
|
response.text().then(function(text) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
setLog(response.url, response.status, text)
|
|
|
|
|
})
|
2019-11-04 03:10:06 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
return response.json()
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.catch(function(error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
todo(error)
|
|
|
|
|
setLog(start, 'JSON', error)
|
|
|
|
|
console.error(error)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
})
|
|
|
|
|
.then(function(json) {
|
|
|
|
|
if (!json.error) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var urls = 'Suggest:'
|
2019-10-22 16:34:23 +11:00
|
|
|
|
Object.keys(json.instances).forEach(function(key) {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
var url = json.instances[key]
|
|
|
|
|
urls =
|
|
|
|
|
urls +
|
|
|
|
|
` <a onclick="login('${url.name}')" class="pointer">${escapeHTML(url.name)}</a>`
|
|
|
|
|
})
|
|
|
|
|
$('#ins-suggest').html(urls)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
console.error(json.error)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
})
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
oldSuggest = suggest
|
|
|
|
|
prev_value = new_val
|
2018-06-18 00:26:45 +10:00
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
|
}, 1000)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
},
|
|
|
|
|
false
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2018-06-18 00:26:45 +10:00
|
|
|
|
|
2019-10-22 16:34:23 +11:00
|
|
|
|
input.addEventListener(
|
2019-11-09 00:52:54 +11:00
|
|
|
|
'blur',
|
2019-10-22 16:34:23 +11:00
|
|
|
|
function() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
window.clearInterval(timer)
|
2019-10-22 16:34:23 +11:00
|
|
|
|
},
|
|
|
|
|
false
|
2019-11-09 00:52:54 +11:00
|
|
|
|
)
|
2019-10-05 02:57:53 +10:00
|
|
|
|
//acctで未読マーカーは要らない
|
|
|
|
|
function asReadEnd() {
|
2019-11-09 00:52:54 +11:00
|
|
|
|
postMessage(['asReadComp', ''], '*')
|
2019-10-22 16:34:23 +11:00
|
|
|
|
}
|