add limited flags of moderated account

This commit is contained in:
cutls 2022-10-10 16:09:17 +09:00
parent c2ccc9a493
commit 48c872909d
4 changed files with 241 additions and 239 deletions

View File

@ -721,9 +721,11 @@
text-rendering: auto; text-rendering: auto;
line-height: 1; line-height: 1;
font-weight: 900; font-weight: 900;
color: #000; color: var(--text);
position: relative; position: relative;
font-size: 1.5em font-size: 1.5em;
top: 1.7rem;
left: 1rem;
} }
.swal2-icon { .swal2-icon {

View File

@ -48,13 +48,13 @@ function initPlugin() {
}) })
}) })
asCommon['TheDesk:confirm'] = asValue.FN_NATIVE(async (z) => { asCommon['TheDesk:confirm'] = asValue.FN_NATIVE(async (z) => {
const alert = await Swal.fire({ const alertSwal = await Swal.fire({
title: z[0].value, title: z[0].value,
text: z[1].value, text: z[1].value,
icon: z[2] ? z[2].value : 'info', icon: z[2] ? z[2].value : 'info',
showCancelButton: true showCancelButton: true
}) })
return asUtil.jsToVal(!!(alert.value && alert.value === true)) return asUtil.jsToVal(!!(alertSwal.value && alertSwal.value === true))
}) })
asCommon['TheDesk:css'] = asValue.FN_NATIVE((z) => { asCommon['TheDesk:css'] = asValue.FN_NATIVE((z) => {
$(escapeHTML(z[0].value)).css(escapeHTML(z[1].value), escapeHTML(z[2].value)) $(escapeHTML(z[0].value)).css(escapeHTML(z[1].value), escapeHTML(z[2].value))
@ -227,13 +227,13 @@ async function testExec(exe) {
}) })
}) })
asCommon['TheDesk:confirm'] = asValue.FN_NATIVE(async (z) => { asCommon['TheDesk:confirm'] = asValue.FN_NATIVE(async (z) => {
const alert = await Swal.fire({ const alertSwal = await Swal.fire({
title: z[0].value, title: z[0].value,
text: z[1].value, text: z[1].value,
icon: z[2] ? z[2].value : 'info', icon: z[2] ? z[2].value : 'info',
showCancelButton: true showCancelButton: true
}) })
return asUtil.jsToVal(!!(alert.value && alert.value === true)) return asUtil.jsToVal(!!(alertSwal.value && alertSwal.value === true))
}) })
asCommon['TheDesk:css'] = asValue.FN_NATIVE((z) => { asCommon['TheDesk:css'] = asValue.FN_NATIVE((z) => {
$(escapeHTML(z[0].value)).css(escapeHTML(z[1].value), escapeHTML(z[2].value)) $(escapeHTML(z[0].value)).css(escapeHTML(z[1].value), escapeHTML(z[2].value))

View File

@ -837,12 +837,12 @@ function testExecTrg() {
testExec(inputPlugin) testExec(inputPlugin)
} }
async function deletePlugin() { async function deletePlugin() {
const alert = await Swal.fire({ const delIsIt = await Swal.fire({
title: 'delete', title: 'delete',
icon: 'warning', icon: 'warning',
showCancelButton: true, showCancelButton: true,
}) })
if (!alert) return false if (!delIsIt.isConfirmed) return false
editor.setValue('', -1) editor.setValue('', -1)
var pgns = localStorage.getItem('plugins') var pgns = localStorage.getItem('plugins')
var args = JSON.parse(pgns ? pgns : '[]') var args = JSON.parse(pgns ? pgns : '[]')

View File

@ -1,6 +1,6 @@
//ユーザーデータ表示 //ユーザーデータ表示
localStorage.removeItem('history') localStorage.removeItem('history')
//コード受信 //コード受信
if (location.search) { if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/) var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/)
var mode = m[1] var mode = m[1]
@ -45,30 +45,30 @@ async function udgEx(user, acct_id) {
onBeforeOpen: () => { onBeforeOpen: () => {
Swal.showLoading() Swal.showLoading()
}, },
onClose: () => {}, onClose: () => { },
}).then((result) => {}) }).then((result) => { })
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
Authorization: 'Bearer ' + at, Authorization: 'Bearer ' + at,
}, },
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
Swal.close() Swal.close()
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text) setLog(response.url, response.status, text)
}) })
} }
return response.json() return response.json()
}) })
.catch(function(error) { .catch(function (error) {
todo(error) todo(error)
setLog(start, 'JSON', error) setLog(start, 'JSON', error)
console.error(error) console.error(error)
}) })
.then(function(json) { .then(function (json) {
if (json.accounts[0]) { if (json.accounts[0]) {
var id = json.accounts[0].id var id = json.accounts[0].id
udg(id, acct_id, true) udg(id, acct_id, true)
@ -80,7 +80,7 @@ async function udgEx(user, acct_id) {
return true return true
} }
function udg(user, acct_id, isSwal) { async function udg(user, acct_id, isSwal) {
reset() reset()
if (!user) { if (!user) {
user = localStorage.getItem('user-id_' + acct_id) user = localStorage.getItem('user-id_' + acct_id)
@ -91,203 +91,203 @@ function udg(user, acct_id, isSwal) {
misskeyUdg(user, acct_id) misskeyUdg(user, acct_id)
return return
} }
var at = localStorage.getItem('acct_' + acct_id + '_at') const at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/accounts/' + user const start = 'https://' + domain + '/api/v1/accounts/' + user
fetch(start, { const response = await fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
Authorization: 'Bearer ' + at, Authorization: 'Bearer ' + at,
}, },
})
if (isSwal) Swal.close()
if (!response.ok) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
}) })
.then(function(response) { }
if (isSwal) Swal.close() const json = await response.json()
if (!response.ok) { //一つ前のユーザーデータ
response.text().then(function(text) { if (!localStorage.getItem('history')) {
setLog(response.url, response.status, text) $('#his-history-btn').prop('disabled', true)
}) } else {
} $('#his-history-btn').prop('disabled', false)
return response.json() $('#his-data').attr('history', localStorage.getItem('history'))
}
//moved設定時
if (json.moved) {
M.toast({
html: lang.lang_showontl_movetxt + '<button class="btn-flat toast-action" onclick="udg(\'' + json.moved.id + "','" + acct_id + '\')">' + lang.lang_showontl_movebtn + '</button>',
displayLength: 4000,
}) })
.catch(function(error) { }
todo(error) if (json.limited) {
setLog(start, 'JSON', error) const limitedCheck = await Swal.fire({
console.error(error) title: lang.lang_showontl_limited_title,
text: lang.lang_showontl_limited,
icon: 'info',
showCancelButton: true
}) })
.then(function(json) { if (!limitedCheck.isConfirmed) return false
//一つ前のユーザーデータ }
if (!localStorage.getItem('history')) { $('#his-data').modal('open')
$('#his-history-btn').prop('disabled', true) $('#his-data').attr('user-id', user)
} else { $('#his-data').attr('use-acct', acct_id)
$('#his-history-btn').prop('disabled', false) if (json.username != json.acct) {
$('#his-data').attr('history', localStorage.getItem('history')) //Remote
} $('#his-data').attr('remote', 'true')
//moved設定時 var fullname = json.acct
if (json.moved) { } else {
M.toast({ $('#his-data').attr('remote', 'false')
html: lang.lang_showontl_movetxt + '<button class="btn-flat toast-action" onclick="udg(\'' + json.moved.id + "','" + acct_id + '\')">' + lang.lang_showontl_movebtn + '</button>', var fullname = json.acct + '@' + domain
displayLength: 4000, }
}) utlShow(json.id, '', acct_id)
} flw(json.id, '', acct_id)
$('#his-data').modal('open') fer(json.id, '', acct_id)
$('#his-data').attr('user-id', user) var dis_name = escapeHTML(json.display_name)
$('#his-data').attr('use-acct', acct_id) dis_name = twemoji.parse(dis_name)
if (json.username != json.acct) {
//Remote
$('#his-data').attr('remote', 'true')
var fullname = json.acct
} else {
$('#his-data').attr('remote', 'false')
var fullname = json.acct + '@' + domain
}
utlShow(json.id, '', acct_id)
flw(json.id, '', acct_id)
fer(json.id, '', acct_id)
var dis_name = escapeHTML(json.display_name)
dis_name = twemoji.parse(dis_name)
var note = json.note var note = json.note
if (json.emojis) { if (json.emojis) {
var actemojick = json.emojis[0] var actemojick = json.emojis[0]
} else { } else {
var actemojick = false var actemojick = false
} }
//絵文字があれば //絵文字があれば
if (actemojick) { if (actemojick) {
Object.keys(json.emojis).forEach(function(key5) { Object.keys(json.emojis).forEach(function (key5) {
var emoji = json.emojis[key5] var emoji = json.emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" draggable="false">' var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" draggable="false">'
var regExp = new RegExp(':' + shortcode + ':', 'g') var regExp = new RegExp(':' + shortcode + ':', 'g')
dis_name = dis_name.replace(regExp, emoji_url) dis_name = dis_name.replace(regExp, emoji_url)
note = note.replace(regExp, emoji_url) note = note.replace(regExp, emoji_url)
})
}
//noteの解析
//var tags = '<a onclick="tl(\'tag\',\'$1\',' + acct_id +',\'add\')" class="pointer parsed">#$1</a>';
//var mens = '<a onclick="udgEx(\'$1\',' + acct_id +')" class="pointer parsed">@$1</a>';
//note=note.replace(/#(\S+)/gi, tags)
//note=note.replace(/\s@([a-zA-Z_0-9@.-]+)/gi, mens)
$('#his-name').html(dis_name)
$('#his-acct').text(json.acct)
$('#his-acct').attr('fullname', fullname)
$('#his-prof').attr('src', json.avatar)
$('#util-add').removeClass('hide')
const title = $('.column-first').html()
$('#my-data-nav .anc-link').removeClass('active-back')
$('.column-first').addClass('active-back')
$('#his-data-title').html(title)
$('#his-data').css('background-image', 'url(' + json.header + ')')
$('#his-sta').text(json.statuses_count)
$('#his-follow').text(json.following_count)
var flerc = json.followers_count
if (flerc < 0) {
flerc = '-'
}
$('#his-follower').text(flerc)
$('#his-since').text(crat(json.created_at))
$('#his-openin').attr('data-href', json.url)
if (json.fields) {
var table = ''
if (json.fields.length > 0) {
$('#his-des').css('max-height', '196px')
table = '<table id="his-field">'
for (var i = 0; i < json.fields.length; i++) {
var fname = json.fields[i].name
var fval = json.fields[i].value
if (json.fields[i].verified_at) {
var when = lang.lang_showontl_verified + ':' + crat(json.fields[i].verified_at)
var color = 'rgba(121,189,154,.25);'
} else {
var when = ''
var color = 'inherit'
}
table =
table +
'<tr><td class="his-field-title">' +
escapeHTML(fname) +
'</td><td class="his-field-content" title="' +
when +
'" style="background-color:' +
color +
'">' +
fval +
'</td></tr>'
}
table = table + '</table>'
$('#his-des').html(twemoji.parse(note))
} else {
$('#his-des').css('max-height', '400px')
}
$('#his-table').html(twemoji.parse(table))
} else {
$('#his-des').css('max-height', '400px')
}
$('#his-des').html(twemoji.parse(note))
if (json.bot) {
$('#his-bot').html(lang.lang_showontl_botacct)
$('#his-bot').removeClass('hide')
}
$('#his-des').attr('data-acct', acct_id)
$('#his-data').css('background-size', 'cover')
$('#his-float-timeline').css('height', $('#his-data-show').height() + 'px')
localStorage.setItem('history', user)
//自分の時
if (json.acct == localStorage.getItem('user_' + acct_id)) {
showFav('', acct_id)
showBlo('', acct_id)
showMut('', acct_id)
showDom('', acct_id)
showReq('', acct_id)
showFrl('', acct_id)
$('#his-name-val').val(json.display_name)
if (json.fields.length > 0) {
if (json.fields[0]) {
$('#his-f1-name').val(json.fields[0].name)
$('#his-f1-val').val($.strip_tags(json.fields[0].value))
}
if (json.fields[1]) {
$('#his-f2-name').val(json.fields[1].name)
$('#his-f2-val').val($.strip_tags(json.fields[1].value))
}
if (json.fields[2]) {
$('#his-f3-name').val(json.fields[2].name)
$('#his-f3-val').val($.strip_tags(json.fields[2].value))
}
if (json.fields[3]) {
$('#his-f4-name').val(json.fields[3].name)
$('#his-f4-val').val($.strip_tags(json.fields[3].value))
}
}
var des = json.note
des = des.replace(/<br \/>/g, '\n')
des = $.strip_tags(des)
$('#his-des-val').val(des)
$('#his-follow-btn').hide()
$('#his-block-btn').hide()
$('#his-mute-btn').hide()
$('#his-notf-btn').hide()
$('#his-domain-btn').hide()
$('#his-emp-btn').hide()
$('.only-my-data').show()
$('.only-his-data').hide()
if (localStorage.getItem('main') == acct_id) {
$('#his-main-acct').hide()
}
} else {
relations(user, acct_id)
$('.only-my-data').hide()
$('.only-his-data').show()
}
todc()
if (json.locked) {
$('#his-data').addClass('locked')
} else {
$('#his-data').removeClass('locked')
}
//外部データ取得(死かもしれないので)
udAdd(acct_id, user, json.url)
}) })
}
//noteの解析
//var tags = '<a onclick="tl(\'tag\',\'$1\',' + acct_id +',\'add\')" class="pointer parsed">#$1</a>';
//var mens = '<a onclick="udgEx(\'$1\',' + acct_id +')" class="pointer parsed">@$1</a>';
//note=note.replace(/#(\S+)/gi, tags)
//note=note.replace(/\s@([a-zA-Z_0-9@.-]+)/gi, mens)
$('#his-name').html(dis_name)
$('#his-acct').text(json.acct)
$('#his-acct').attr('fullname', fullname)
$('#his-prof').attr('src', json.avatar)
$('#util-add').removeClass('hide')
const title = $('.column-first').html()
$('#my-data-nav .anc-link').removeClass('active-back')
$('.column-first').addClass('active-back')
$('#his-data-title').html(title)
$('#his-data').css('background-image', 'url(' + json.header + ')')
$('#his-sta').text(json.statuses_count)
$('#his-follow').text(json.following_count)
var flerc = json.followers_count
if (flerc < 0) {
flerc = '-'
}
$('#his-follower').text(flerc)
$('#his-since').text(crat(json.created_at))
$('#his-openin').attr('data-href', json.url)
if (json.fields) {
var table = ''
if (json.fields.length > 0) {
$('#his-des').css('max-height', '196px')
table = '<table id="his-field">'
for (var i = 0; i < json.fields.length; i++) {
var fname = json.fields[i].name
var fval = json.fields[i].value
if (json.fields[i].verified_at) {
var when = lang.lang_showontl_verified + ':' + crat(json.fields[i].verified_at)
var color = 'rgba(121,189,154,.25);'
} else {
var when = ''
var color = 'inherit'
}
table =
table +
'<tr><td class="his-field-title">' +
escapeHTML(fname) +
'</td><td class="his-field-content" title="' +
when +
'" style="background-color:' +
color +
'">' +
fval +
'</td></tr>'
}
table = table + '</table>'
$('#his-des').html(twemoji.parse(note))
} else {
$('#his-des').css('max-height', '400px')
}
$('#his-table').html(twemoji.parse(table))
} else {
$('#his-des').css('max-height', '400px')
}
$('#his-des').html(twemoji.parse(note))
if (json.bot) {
$('#his-bot').html(lang.lang_showontl_botacct)
$('#his-bot').removeClass('hide')
}
$('#his-des').attr('data-acct', acct_id)
$('#his-data').css('background-size', 'cover')
$('#his-float-timeline').css('height', $('#his-data-show').height() + 'px')
localStorage.setItem('history', user)
//自分の時
if (json.acct == localStorage.getItem('user_' + acct_id)) {
showFav('', acct_id)
showBlo('', acct_id)
showMut('', acct_id)
showDom('', acct_id)
showReq('', acct_id)
showFrl('', acct_id)
$('#his-name-val').val(json.display_name)
if (json.fields.length > 0) {
if (json.fields[0]) {
$('#his-f1-name').val(json.fields[0].name)
$('#his-f1-val').val($.strip_tags(json.fields[0].value))
}
if (json.fields[1]) {
$('#his-f2-name').val(json.fields[1].name)
$('#his-f2-val').val($.strip_tags(json.fields[1].value))
}
if (json.fields[2]) {
$('#his-f3-name').val(json.fields[2].name)
$('#his-f3-val').val($.strip_tags(json.fields[2].value))
}
if (json.fields[3]) {
$('#his-f4-name').val(json.fields[3].name)
$('#his-f4-val').val($.strip_tags(json.fields[3].value))
}
}
var des = json.note
des = des.replace(/<br \/>/g, '\n')
des = $.strip_tags(des)
$('#his-des-val').val(des)
$('#his-follow-btn').hide()
$('#his-block-btn').hide()
$('#his-mute-btn').hide()
$('#his-notf-btn').hide()
$('#his-domain-btn').hide()
$('#his-emp-btn').hide()
$('.only-my-data').show()
$('.only-his-data').hide()
if (localStorage.getItem('main') == acct_id) {
$('#his-main-acct').hide()
}
} else {
relations(user, acct_id)
$('.only-my-data').hide()
$('.only-his-data').show()
}
todc()
if (json.locked) {
$('#his-data').addClass('locked')
} else {
$('#his-data').removeClass('locked')
}
//外部データ取得(死かもしれないので)
udAdd(acct_id, user, json.url)
} }
function misskeyUdg(user, acct_id) { function misskeyUdg(user, acct_id) {
@ -304,29 +304,29 @@ function misskeyUdg(user, acct_id) {
var at = localStorage.getItem('acct_' + acct_id + '_at') var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/users/show' var start = 'https://' + domain + '/api/users/show'
fetch(start, { fetch(start, {
method: 'POST', method: 'POST',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
userId: user, userId: user,
}), }),
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text) setLog(response.url, response.status, text)
}) })
} }
return response.json() return response.json()
}) })
.catch(function(error) { .catch(function (error) {
todo(error) todo(error)
setLog(start, 'JSON', error) setLog(start, 'JSON', error)
console.error(error) console.error(error)
}) })
.then(function(json) { .then(function (json) {
//一つ前のユーザーデータ //一つ前のユーザーデータ
if (!localStorage.getItem('history')) { if (!localStorage.getItem('history')) {
$('#his-history-btn').prop('disabled', true) $('#his-history-btn').prop('disabled', true)
@ -370,7 +370,7 @@ function misskeyUdg(user, acct_id) {
} }
$('#his-data').css('background-size', 'cover') $('#his-data').css('background-size', 'cover')
localStorage.setItem('history', user) localStorage.setItem('history', user)
//自分の時 //自分の時
if (json.username == localStorage.getItem('user_' + acct_id) && !json.host) { if (json.username == localStorage.getItem('user_' + acct_id) && !json.host) {
//showFav('', acct_id); //showFav('', acct_id);
//showMut('', acct_id); //showMut('', acct_id);
@ -438,26 +438,26 @@ function relations(user, acct_id) {
var at = localStorage.getItem('acct_' + acct_id + '_at') var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/accounts/relationships?id=' + user var start = 'https://' + domain + '/api/v1/accounts/relationships?id=' + user
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
Authorization: 'Bearer ' + at, Authorization: 'Bearer ' + at,
}, },
}) })
.then(function(response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function (text) {
setLog(response.url, response.status, text) setLog(response.url, response.status, text)
}) })
} }
return response.json() return response.json()
}) })
.catch(function(error) { .catch(function (error) {
todo(error) todo(error)
setLog(start, 'JSON', error) setLog(start, 'JSON', error)
console.error(error) console.error(error)
}) })
.then(function(json) { .then(function (json) {
var json = json[0] var json = json[0]
if (json.requested) { if (json.requested) {
//フォロリク中 //フォロリク中
@ -597,7 +597,7 @@ function reset() {
$('#his-data').removeClass('locked') $('#his-data').removeClass('locked')
$('#his-data').removeClass('requesting') $('#his-data').removeClass('requesting')
} }
$('#my-data-nav .anc-link').on('click', function() { $('#my-data-nav .anc-link').on('click', function () {
var target = $(this).attr('go') var target = $(this).attr('go')
if (target) { if (target) {
let title = $(this).html() let title = $(this).html()