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'))
var date = new Date()
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')) {
//ちょっと削除とリンク解析の都合上アレ(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
console.log('%c Thank you for your update🎉', 'color: red;font-size:200%;')
$(document).ready(function() {

View File

@ -590,7 +590,7 @@ function enc(ver) {
}
//インスタンスティッカー
function ticker() {
var start = 'https://toot-app.thedesk.top/toot/index.php'
var start = 'https://s.0px.io/json'
fetch(start, {
method: 'GET',
cors: true,
@ -611,7 +611,8 @@ function ticker() {
})
.then(function(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
var tickerdom = ''
if (ticker) {
var tickerdata = localStorage.getItem('ticker')
var tickerdata = localStorage.getItem('sticker')
if (tickerdata) {
var tickerdata = JSON.parse(tickerdata)
var tickerdataRaw = JSON.parse(tickerdata)
var tickerdata = tickerdataRaw.data
var thisdomain = toot.account.acct.split('@')
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++) {
var value = tickerdata[i]
if (value.domain == thisdomain) {
var tickerdom = `<div aria-hidden="true" style="user-select:none;cursor:default;background:linear-gradient(90deg, ${
value.bg
}, transparent 96%) !important; color:${
value.text
var bgColor = value.bgColor
var fontColor = value.fontColor
if (!value.bgColor || !value.fontColor) {
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">
<img draggable="false" src="${
value.image
value.favicon
}" style="height:100%;" onerror="this.src=\'../../img/loading.svg\'">
<span style="position:relative; top:-0.2rem;">${escapeHTML(value.name)}</span>
</div>`

View File

@ -1,30 +1,44 @@
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 platform = localStorage.getItem('platform')
if (platform == 'win32') {
postMessage(['openUrl', auth], '*')
postMessage(['sendSinmpleIpc', 'quit'], '*')
} else {
auth = auth + '&state=code'
var auth = 'https://spotify.thedesk.top/connect'
$('#spotify-code-show').removeClass('hide')
postMessage(['openUrl', auth], '*')
}
}
function spotifyAuth() {
var code = $('#spotify-code').val()
localStorage.setItem('spotify', 'code')
localStorage.setItem('spotify-refresh', code)
localStorage.setItem('spotify-token', code)
$('#spotify-code-show').addClass('hide')
$('#spotify-enable').addClass('disabled')
$('#spotify-disable').removeClass('disabled')
}
function spotifyDisconnect() {
localStorage.removeItem('spotify')
localStorage.removeItem('spotify-refresh')
var start = 'https://spotify.thedesk.top/disconnect?code=' + localStorage.getItem('spotify-token')
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()
})
}
function checkSpotify() {
if (localStorage.getItem('spotify')) {
if (localStorage.getItem('spotify-token')) {
$('#spotify-enable').addClass('disabled')
$('#spotify-disable').removeClass('disabled')
} else {
@ -71,8 +85,8 @@ function aMusicFlagSave() {
}
function nowplaying(mode) {
if (mode == 'spotify') {
var start = 'https://thedesk.top/now-playing?at=' + localStorage.getItem('spotify') + '&rt=' + localStorage.getItem('spotify-refresh')
var at = localStorage.getItem('spotify')
var start = 'https://spotify.thedesk.top/current-playing?code=' + localStorage.getItem('spotify-token')
var at = localStorage.getItem('spotify-token')
if (at) {
fetch(start, {
method: 'GET',
@ -93,7 +107,10 @@ function nowplaying(mode) {
setLog(start, 'JSON', 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)
if (json.length < 1) {
return false

View File

@ -131,12 +131,8 @@ function trendTagonTip() {
spotint = null
function spotifytips() {
if (spotint) clearInterval(spotint)
var start =
'https://thedesk.top/now-playing?at=' +
localStorage.getItem('spotify') +
'&rt=' +
localStorage.getItem('spotify-refresh')
var at = localStorage.getItem('spotify')
var start = 'https://spotify.thedesk.top/current-playing?code=' + localStorage.getItem('spotify-token')
var at = localStorage.getItem('spotify-token')
if (at) {
fetch(start, {
method: 'GET',
@ -157,7 +153,10 @@ function spotifytips() {
setLog(start, 'JSON', 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
if(!ms) {
tips('ver')