today shinchoku
This commit is contained in:
parent
47749dde7b
commit
d92a9ae1ae
|
@ -65,7 +65,12 @@ async function verck(ver) {
|
||||||
r += c[Math.floor(Math.random() * cl)]
|
r += c[Math.floor(Math.random() * cl)]
|
||||||
}
|
}
|
||||||
const start = 'https://thedesk.top/ver.json'
|
const start = 'https://thedesk.top/ver.json'
|
||||||
const mess = await getApi(start, null)
|
let mess
|
||||||
|
try {
|
||||||
|
mess = await getApi(start, null)
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
console.table(mess)
|
console.table(mess)
|
||||||
if (mess) {
|
if (mess) {
|
||||||
let newest = null
|
let newest = null
|
||||||
|
@ -98,7 +103,12 @@ async function verck(ver) {
|
||||||
lni = 0
|
lni = 0
|
||||||
}
|
}
|
||||||
const getNotice = 'https://thedesk.top/notice/index.php?since_id=' + lni
|
const getNotice = 'https://thedesk.top/notice/index.php?since_id=' + lni
|
||||||
const notices = await getApi(getNotice, null)
|
let notices
|
||||||
|
try {
|
||||||
|
notices = await getApi(getNotice, null)
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (notices.length < 1) {
|
if (notices.length < 1) {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -8,7 +8,7 @@ localStorage.removeItem('imas')
|
||||||
localStorage.removeItem('stable')
|
localStorage.removeItem('stable')
|
||||||
const acctList = JSON.parse(localStorage.getItem('multi'))
|
const acctList = JSON.parse(localStorage.getItem('multi'))
|
||||||
|
|
||||||
function ck() {
|
async function ck() {
|
||||||
const main = localStorage.getItem('main')
|
const main = localStorage.getItem('main')
|
||||||
if (!main) {
|
if (!main) {
|
||||||
localStorage.setItem('main', '0')
|
localStorage.setItem('main', '0')
|
||||||
|
@ -37,7 +37,8 @@ function ck() {
|
||||||
const key = keymap[i]
|
const key = keymap[i]
|
||||||
const acct = obj[key]
|
const acct = obj[key]
|
||||||
if (acct.domain) {
|
if (acct.domain) {
|
||||||
req = refresh(key, true)
|
let refreshed = await refresh(key, true)
|
||||||
|
if(refreshed) req = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(req) {
|
if(req) {
|
||||||
|
@ -76,27 +77,35 @@ async function refresh(target, loadskip) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const start = `https://${domain}/api/v1/accounts/verify_credentials`
|
const start = `https://${domain}/api/v1/accounts/verify_credentials`
|
||||||
const json = await getApi(start, at)
|
let json
|
||||||
|
try{
|
||||||
|
json = await getApi(start, at)
|
||||||
|
} catch {
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (json.error) {
|
if (json.error) {
|
||||||
console.error('Error:' + json.error)
|
console.error('Error:' + json.error)
|
||||||
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
M.toast({ html: lang.lang_fatalerroroccured + 'Error:' + json.error, displayLength: 5000 })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(!json) return false
|
||||||
let avatar = json['avatar']
|
let avatar = json['avatar']
|
||||||
//missingがmissingなやつ
|
//missingがmissingなやつ
|
||||||
if (avatar == '/avatars/original/missing.png' || !avatar) {
|
if (avatar == '/avatars/original/missing.png' || !avatar) {
|
||||||
avatar = './img/missing.svg'
|
avatar = './img/missing.svg'
|
||||||
}
|
}
|
||||||
const { newName, newProf, newVis } = json
|
const newName = json.display_name
|
||||||
|
const newProf = avatar
|
||||||
|
const newVis = json.source.privacy
|
||||||
if (newName != name || newProf != prof || newVis != vis) {
|
if (newName != name || newProf != prof || newVis != vis) {
|
||||||
let ref = {
|
let ref = {
|
||||||
at: at,
|
at: at,
|
||||||
name: json['display_name'],
|
name: newName,
|
||||||
domain: domain,
|
domain: domain,
|
||||||
user: json['acct'],
|
user: json['acct'],
|
||||||
prof: avatar,
|
prof: avatar,
|
||||||
id: json['id'],
|
id: json['id'],
|
||||||
vis: json['source']['privacy']
|
vis: newVis
|
||||||
}
|
}
|
||||||
if (background) {
|
if (background) {
|
||||||
ref.background = background
|
ref.background = background
|
||||||
|
@ -173,7 +182,7 @@ function multiSelector(parseC) {
|
||||||
lastUsed = localStorage.getItem('main')
|
lastUsed = localStorage.getItem('main')
|
||||||
} else if (localStorage.getItem('last-use')) {
|
} else if (localStorage.getItem('last-use')) {
|
||||||
lastUsed = localStorage.getItem('last-use')
|
lastUsed = localStorage.getItem('last-use')
|
||||||
if (lastUsed == 'webview' || last == 'noauth') {
|
if (lastUsed == 'webview' || lastUsed == 'noauth') {
|
||||||
lastUsed = '0'
|
lastUsed = '0'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -187,7 +196,7 @@ function multiSelector(parseC) {
|
||||||
for (let i = 0; i < obj.length; i++) {
|
for (let i = 0; i < obj.length; i++) {
|
||||||
const acct = obj[i]
|
const acct = obj[i]
|
||||||
const strKey = i?.toString()
|
const strKey = i?.toString()
|
||||||
if (key == lastUsed) {
|
if (strKey == lastUsed) {
|
||||||
sel = 'selected'
|
sel = 'selected'
|
||||||
const domain = acct.domain
|
const domain = acct.domain
|
||||||
const letters = idata[`${domain}_letters`]
|
const letters = idata[`${domain}_letters`]
|
||||||
|
@ -196,7 +205,7 @@ function multiSelector(parseC) {
|
||||||
textarea.setAttribute('data-length', letters)
|
textarea.setAttribute('data-length', letters)
|
||||||
} else {
|
} else {
|
||||||
//手動でアカマネで変えれちゃうから
|
//手動でアカマネで変えれちゃうから
|
||||||
const maxLetters = localStorage.getItem('letters_' + key)
|
const maxLetters = localStorage.getItem('letters_' + strKey)
|
||||||
if (maxLetters > 0) {
|
if (maxLetters > 0) {
|
||||||
textarea.setAttribute('data-length', maxLetters)
|
textarea.setAttribute('data-length', maxLetters)
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,7 +219,7 @@ function multiSelector(parseC) {
|
||||||
if (!profimg) {
|
if (!profimg) {
|
||||||
profimg = '../../img/missing.svg'
|
profimg = '../../img/missing.svg'
|
||||||
}
|
}
|
||||||
document.querySelector('#acct-sel-pro').setAttribute('src', profimg)
|
document.querySelector('#acct-sel-prof').setAttribute('src', profimg)
|
||||||
let cc = ''
|
let cc = ''
|
||||||
if (domain) {
|
if (domain) {
|
||||||
cc = `(${domain})`
|
cc = `(${domain})`
|
||||||
|
@ -225,35 +234,35 @@ function multiSelector(parseC) {
|
||||||
if (domain == 'imastodon.net') {
|
if (domain == 'imastodon.net') {
|
||||||
trendTag()
|
trendTag()
|
||||||
} else {
|
} else {
|
||||||
document.querySelector('#trendtag').innerHTML = ''
|
if(document.querySelector('#trendtag')) this.innerHTML = ''
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sel = ''
|
sel = ''
|
||||||
}
|
}
|
||||||
template = `
|
template = `
|
||||||
<option value="${key}" data-icon="${acct.prof}" class="left circle" ${sel}>
|
<option value="${strKey}" data-icon="${acct.prof}" class="left circle" ${sel}>
|
||||||
@${acct.user} ${acct.domain}
|
@${acct.user} ${acct.domain}
|
||||||
</option>
|
</option>
|
||||||
`
|
`
|
||||||
appendPrepend('.acct-sel', template, 'append')
|
appendPrepend('.acct-sel', template, 'append')
|
||||||
}
|
}
|
||||||
$('#src-acct-sel').append('<option value="tootsearch">Tootsearch</option>')
|
appendPrepend('#src-acct-sel', '<option value="tootsearch">Tootsearch</option>', 'append')
|
||||||
$('#add-acct-sel').append(
|
appendPrepend('#add-acct-sel', `
|
||||||
'<option value="noauth">' +
|
<option value="noauth">${lang.lang_login_noauth}</option>
|
||||||
lang.lang_login_noauth +
|
<option value="webview">Twitter</option>
|
||||||
'</option><option value="webview">Twitter</option>'
|
`, 'append')
|
||||||
)
|
appendPrepend('#dir-acct-sel', `<option value="noauth">${lang.lang_login_noauth}</option>`, 'append')
|
||||||
$('#dir-acct-sel').append('<option value="noauth">' + lang.lang_login_noauth + '</option>')
|
|
||||||
}
|
}
|
||||||
$('select').formSelect()
|
const elems = document.querySelectorAll('select');
|
||||||
|
M.FormSelect.init(elems, null);
|
||||||
if (!parseC) {
|
if (!parseC) {
|
||||||
parseColumn(null, true)
|
parseColumn(null, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//インスタンスティッカー
|
//インスタンスティッカー
|
||||||
function ticker() {
|
async function ticker() {
|
||||||
const start = 'https://toot-app.thedesk.top/toot/index.php'
|
const start = 'https://toot-app.thedesk.top/toot/index.php'
|
||||||
const json = getApi(start, null)
|
const json = await getApi(start, null)
|
||||||
if(json) localStorage.setItem('ticker', JSON.stringify(json))
|
if(json) localStorage.setItem('ticker', JSON.stringify(json))
|
||||||
}
|
}
|
||||||
function isMisskey(domain) {
|
function isMisskey(domain) {
|
||||||
|
|
|
@ -13,12 +13,7 @@ function escapeHTML(str) {
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
return str
|
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''')
|
||||||
.replace(/&/g, '&')
|
|
||||||
.replace(/</g, '<')
|
|
||||||
.replace(/>/g, '>')
|
|
||||||
.replace(/"/g, '"')
|
|
||||||
.replace(/'/g, ''')
|
|
||||||
}
|
}
|
||||||
//PHPのnl2brと同様
|
//PHPのnl2brと同様
|
||||||
function nl2br(str) {
|
function nl2br(str) {
|
||||||
|
@ -88,17 +83,18 @@ function formattimeutc(date) {
|
||||||
}
|
}
|
||||||
postMessage(['sendSinmpleIpc', 'custom-css-request'], '*')
|
postMessage(['sendSinmpleIpc', 'custom-css-request'], '*')
|
||||||
function makeCID() {
|
function makeCID() {
|
||||||
return (
|
let chars = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.split('')
|
||||||
randomStr(8) +
|
for (let i = 0, len = chars.length; i < len; i++) {
|
||||||
'-' +
|
switch (chars[i]) {
|
||||||
randomStr(4) +
|
case 'x':
|
||||||
'-' +
|
chars[i] = Math.floor(Math.random() * 16).toString(16)
|
||||||
randomStr(4) +
|
break
|
||||||
'-' +
|
case 'y':
|
||||||
randomStr(4) +
|
chars[i] = (Math.floor(Math.random() * 4) + 8).toString(16)
|
||||||
'-' +
|
break
|
||||||
randomStr(12)
|
}
|
||||||
)
|
}
|
||||||
|
return chars.join('')
|
||||||
}
|
}
|
||||||
function randomStr(l) {
|
function randomStr(l) {
|
||||||
// 生成する文字列に含める文字セット
|
// 生成する文字列に含める文字セット
|
||||||
|
@ -129,7 +125,7 @@ function rgbToHex(color) {
|
||||||
// RGBからHEXへ変換
|
// RGBからHEXへ変換
|
||||||
parseInt(regex[1]).toString(16),
|
parseInt(regex[1]).toString(16),
|
||||||
parseInt(regex[2]).toString(16),
|
parseInt(regex[2]).toString(16),
|
||||||
parseInt(regex[3]).toString(16)
|
parseInt(regex[3]).toString(16),
|
||||||
]
|
]
|
||||||
|
|
||||||
for (var i = 0; i < rgb.length; ++i) {
|
for (var i = 0; i < rgb.length; ++i) {
|
||||||
|
@ -252,7 +248,7 @@ function statusModel(now) {
|
||||||
reblog: null,
|
reblog: null,
|
||||||
application: {
|
application: {
|
||||||
name: null,
|
name: null,
|
||||||
website: null
|
website: null,
|
||||||
},
|
},
|
||||||
account: {
|
account: {
|
||||||
id: '',
|
id: '',
|
||||||
|
@ -273,13 +269,13 @@ function statusModel(now) {
|
||||||
statuses_count: 0,
|
statuses_count: 0,
|
||||||
last_status_at: now,
|
last_status_at: now,
|
||||||
emojis: [],
|
emojis: [],
|
||||||
fields: []
|
fields: [],
|
||||||
},
|
},
|
||||||
media_attachments: [],
|
media_attachments: [],
|
||||||
mentions: [],
|
mentions: [],
|
||||||
tags: [],
|
tags: [],
|
||||||
card: null,
|
card: null,
|
||||||
poll: null
|
poll: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +314,8 @@ function appendPrepend(query, elm, action) {
|
||||||
const allTarget = document.querySelectorAll(query)
|
const allTarget = document.querySelectorAll(query)
|
||||||
for (let i = 0; i < allTarget.length; i++) {
|
for (let i = 0; i < allTarget.length; i++) {
|
||||||
const target = allTarget[i]
|
const target = allTarget[i]
|
||||||
if(action == 'prepend') target.prependChild(elm)
|
if (action == 'prepend') target.prependChild(document.createTextNode(elm))
|
||||||
if(action == 'append') target.appendChild(elm)
|
if (action == 'append') target.appendChild(document.createTextNode(elm))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
|
const sleep = (msec) => new Promise((resolve) => setTimeout(resolve, msec))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user