Change InstanceTicker to OpenSticker

This commit is contained in:
cutls 2020-08-02 13:16:31 +09:00
parent 26fd6a72d6
commit b9be1529cc
5 changed files with 134 additions and 86 deletions

View File

@ -4,18 +4,21 @@ function verck(ver, jp) {
$('body').addClass(localStorage.getItem('platform')) $('body').addClass(localStorage.getItem('platform'))
var date = new Date() var date = new Date()
var showVer = false var showVer = false
//Spotify
if (localStorage.getItem('spotify')) {
localStorage.removeItem('spotify')
localStorage.removeItem('spotify-refresh')
var spDc = 'Spotify NowPlaying sysytem was changed, please re-login to Spotify'
if(lang.language == 'ja') {
spDc = 'Spotify NowPlayingの機能が変更されたため、もう一度ログインしてください'
}
Swal.fire({
type: 'info',
title: spDc,
})
}
//Spotify(e)
if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) { if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) {
//ちょっと削除とリンク解析の都合上アレ(s)
//対象外のアプデ:storageが20の最初まで"Usamin (18.6.5)"
if (!localStorage.getItem('usamin_18_6_5_flag')) {
localStorage.setItem('usamin_18_6_5_flag', true)
var multi = localStorage.getItem('column')
var obj = JSON.parse(multi)
for (var i = 0; i < obj.length; i++) {
localStorage.removeItem('card_' + i)
}
}
//ちょっと削除とリンク解析の都合上アレ(e)
showVer = true showVer = true
console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;') console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;')
$(document).ready(function() { $(document).ready(function() {

View File

@ -590,7 +590,7 @@ function enc(ver) {
} }
//インスタンスティッカー //インスタンスティッカー
function ticker() { function ticker() {
var start = 'https://toot-app.thedesk.top/toot/index.php' var start = 'https://s.0px.io/json'
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
cors: true, cors: true,
@ -611,7 +611,8 @@ function ticker() {
}) })
.then(function(json) { .then(function(json) {
if (json) { if (json) {
localStorage.setItem('ticker', JSON.stringify(json)) localStorage.removeItem('ticker')
localStorage.setItem('sticker', JSON.stringify(json))
} }
}) })
} }

View File

@ -918,9 +918,10 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
//Ticker //Ticker
var tickerdom = '' var tickerdom = ''
if (ticker) { if (ticker) {
var tickerdata = localStorage.getItem('ticker') var tickerdata = localStorage.getItem('sticker')
if (tickerdata) { if (tickerdata) {
var tickerdata = JSON.parse(tickerdata) var tickerdataRaw = JSON.parse(tickerdata)
var tickerdata = tickerdataRaw.data
var thisdomain = toot.account.acct.split('@') var thisdomain = toot.account.acct.split('@')
if (thisdomain.length > 1) { if (thisdomain.length > 1) {
@ -929,13 +930,40 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
for (var i = 0; i < tickerdata.length; i++) { for (var i = 0; i < tickerdata.length; i++) {
var value = tickerdata[i] var value = tickerdata[i]
if (value.domain == thisdomain) { if (value.domain == thisdomain) {
var tickerdom = `<div aria-hidden="true" style="user-select:none;cursor:default;background:linear-gradient(90deg, ${ var bgColor = value.bgColor
value.bg var fontColor = value.fontColor
}, transparent 96%) !important; color:${ if (!value.bgColor || !value.fontColor) {
value.text if (value.type == 'mastodon') {
if(!value.bgColor) bgColor = tickerdataRaw.default.mastodon.bgColor
if(!value.fontColor) fontColor = tickerdataRaw.default.mastodon.fontColor
} else if (value.type == 'pleroma') {
if(!value.bgColor) bgColor = tickerdataRaw.default.pleroma.bgColor
if(!value.fontColor) fontColor = tickerdataRaw.default.pleroma.fontColor
} else if (value.type == 'misskey') {
if(!value.bgColor) bgColor = tickerdataRaw.default.misskey.bgColor
if(!value.fontColor) fontColor = tickerdataRaw.default.misskey.fontColor
} else if (value.type == 'misskeylegacy') {
if(!value.bgColor) bgColor = tickerdataRaw.default.misskeylegacy.bgColor
if(!value.fontColor) fontColor = tickerdataRaw.default.misskeylegacy.fontColor
} else if (value.type == 'pixelfed') {
if(!value.bgColor) bgColor = tickerdataRaw.default.pixelfed.bgColor
if(!value.fontColor) fontColor = tickerdataRaw.default.pixelfed.fontColor
}
} else {
var bgColor = value.bgColor
var fontColor = value.fontColor
}
bgColorCSS = ''
for (let j = 0; j < bgColor.length; j++) {
const bg = bgColor[j]
bgColorCSS = bgColorCSS + bg + ','
}
bgColorCSS = `linear-gradient(90deg, ${bgColorCSS} transparent)`
var tickerdom = `<div aria-hidden="true" style="user-select:none;cursor:default;background:${bgColorCSS} !important; color:${
fontColor
};width:100%; height:0.9rem; font-size:0.8rem;" class="tickers"> };width:100%; height:0.9rem; font-size:0.8rem;" class="tickers">
<img draggable="false" src="${ <img draggable="false" src="${
value.image value.favicon
}" style="height:100%;" onerror="this.src=\'../../img/loading.svg\'"> }" style="height:100%;" onerror="this.src=\'../../img/loading.svg\'">
<span style="position:relative; top:-0.2rem;">${escapeHTML(value.name)}</span> <span style="position:relative; top:-0.2rem;">${escapeHTML(value.name)}</span>
</div>` </div>`

View File

@ -1,30 +1,44 @@
function spotifyConnect() { function spotifyConnect() {
var auth = 'https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing' var auth = 'https://spotify.thedesk.top/connect'
var platform = localStorage.getItem('platform')
if (platform == 'win32') {
postMessage(['openUrl', auth], '*')
postMessage(['sendSinmpleIpc', 'quit'], '*')
} else {
auth = auth + '&state=code'
$('#spotify-code-show').removeClass('hide') $('#spotify-code-show').removeClass('hide')
postMessage(['openUrl', auth], '*') postMessage(['openUrl', auth], '*')
} }
}
function spotifyAuth() { function spotifyAuth() {
var code = $('#spotify-code').val() var code = $('#spotify-code').val()
localStorage.setItem('spotify', 'code') localStorage.setItem('spotify-token', code)
localStorage.setItem('spotify-refresh', code)
$('#spotify-code-show').addClass('hide') $('#spotify-code-show').addClass('hide')
$('#spotify-enable').addClass('disabled') $('#spotify-enable').addClass('disabled')
$('#spotify-disable').removeClass('disabled') $('#spotify-disable').removeClass('disabled')
} }
function spotifyDisconnect() { function spotifyDisconnect() {
localStorage.removeItem('spotify') var start = 'https://spotify.thedesk.top/disconnect?code=' + localStorage.getItem('spotify-token')
localStorage.removeItem('spotify-refresh') fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
},
})
.then(function (response) {
if (!response.ok) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
})
}
return response.json()
})
.catch(function (error) {
todo(error)
setLog(start, 'JSON', error)
console.error(error)
})
.then(function (json) {
if(!json.success) alert('error')
localStorage.removeItem('spotify-token')
checkSpotify() checkSpotify()
})
} }
function checkSpotify() { function checkSpotify() {
if (localStorage.getItem('spotify')) { if (localStorage.getItem('spotify-token')) {
$('#spotify-enable').addClass('disabled') $('#spotify-enable').addClass('disabled')
$('#spotify-disable').removeClass('disabled') $('#spotify-disable').removeClass('disabled')
} else { } else {
@ -71,8 +85,8 @@ function aMusicFlagSave() {
} }
function nowplaying(mode) { function nowplaying(mode) {
if (mode == 'spotify') { if (mode == 'spotify') {
var start = 'https://thedesk.top/now-playing?at=' + localStorage.getItem('spotify') + '&rt=' + localStorage.getItem('spotify-refresh') var start = 'https://spotify.thedesk.top/current-playing?code=' + localStorage.getItem('spotify-token')
var at = localStorage.getItem('spotify') var at = localStorage.getItem('spotify-token')
if (at) { if (at) {
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
@ -93,7 +107,10 @@ function nowplaying(mode) {
setLog(start, 'JSON', error) setLog(start, 'JSON', error)
console.error(error) console.error(error)
}) })
.then(function (json) { .then(function (jsonRaw) {
var code = jsonRaw.token
localStorage.setItem('spotify-token', code)
var json = jsonRaw.data
console.table(json) console.table(json)
if (json.length < 1) { if (json.length < 1) {
return false return false

View File

@ -131,12 +131,8 @@ function trendTagonTip() {
spotint = null spotint = null
function spotifytips() { function spotifytips() {
if (spotint) clearInterval(spotint) if (spotint) clearInterval(spotint)
var start = var start = 'https://spotify.thedesk.top/current-playing?code=' + localStorage.getItem('spotify-token')
'https://thedesk.top/now-playing?at=' + var at = localStorage.getItem('spotify-token')
localStorage.getItem('spotify') +
'&rt=' +
localStorage.getItem('spotify-refresh')
var at = localStorage.getItem('spotify')
if (at) { if (at) {
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
@ -157,7 +153,10 @@ function spotifytips() {
setLog(start, 'JSON', error) setLog(start, 'JSON', error)
console.error(error) console.error(error)
}) })
.then(function(json) { .then(function(jsonRaw) {
var code = jsonRaw.token
localStorage.setItem('spotify-token', code)
var json = jsonRaw.data
var ms = json.progress_ms var ms = json.progress_ms
if(!ms) { if(!ms) {
tips('ver') tips('ver')