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
if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) { //Spotify
//ちょっと削除とリンク解析の都合上アレ(s) if (localStorage.getItem('spotify')) {
//対象外のアプデ:storageが20の最初まで"Usamin (18.6.5)" localStorage.removeItem('spotify')
if (!localStorage.getItem('usamin_18_6_5_flag')) { localStorage.removeItem('spotify-refresh')
localStorage.setItem('usamin_18_6_5_flag', true) var spDc = 'Spotify NowPlaying sysytem was changed, please re-login to Spotify'
var multi = localStorage.getItem('column') if(lang.language == 'ja') {
var obj = JSON.parse(multi) spDc = 'Spotify NowPlayingの機能が変更されたため、もう一度ログインしてください'
for (var i = 0; i < obj.length; i++) {
localStorage.removeItem('card_' + i)
}
} }
//ちょっと削除とリンク解析の都合上アレ(e) Swal.fire({
type: 'info',
title: spDc,
})
}
//Spotify(e)
if (localStorage.getItem('ver') != ver && localStorage.getItem('winstore')) {
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

@ -194,7 +194,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
var local = [] var local = []
var times = [] var times = []
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function (key) {
var domain = localStorage.getItem('domain_' + acct_id) var domain = localStorage.getItem('domain_' + acct_id)
var toot = obj[key] var toot = obj[key]
if (type == 'dm') { if (type == 'dm') {
@ -214,7 +214,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//絵文字があれば //絵文字があれば
if (actemojick) { if (actemojick) {
Object.keys(toot.account.emojis).forEach(function(key5) { Object.keys(toot.account.emojis).forEach(function (key5) {
var emoji = toot.account.emojis[key5] var emoji = toot.account.emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
if (gif == 'yes') { if (gif == 'yes') {
@ -273,7 +273,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
</i><span class="voice">${lang.lang_parse_notffilter}</span></span> </i><span class="voice">${lang.lang_parse_notffilter}</span></span>
<span class="cbadge cbadge-hover" title="${date(toot.created_at, 'absolute')}(${ <span class="cbadge cbadge-hover" title="${date(toot.created_at, 'absolute')}(${
lang.lang_parse_notftime lang.lang_parse_notftime
})" aria-hidden="true"><i class="far fa-clock"></i> })" aria-hidden="true"><i class="far fa-clock"></i>
${date(toot.created_at, datetype)} ${date(toot.created_at, datetype)}
</span> </span>
<span class="voice">${date(toot.created_at, 'absolute')}(${lang.lang_parse_notftime})</span> <span class="voice">${date(toot.created_at, 'absolute')}(${lang.lang_parse_notftime})</span>
@ -369,7 +369,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//絵文字があれば //絵文字があれば
if (actemojick) { if (actemojick) {
Object.keys(toot.account.emojis).forEach(function(key5) { Object.keys(toot.account.emojis).forEach(function (key5) {
var emoji = toot.account.emojis[key5] var emoji = toot.account.emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
if (gif == 'yes') { if (gif == 'yes') {
@ -426,7 +426,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//絵文字があれば //絵文字があれば
if (actemojick) { if (actemojick) {
Object.keys(toot.account.emojis).forEach(function(key5) { Object.keys(toot.account.emojis).forEach(function (key5) {
var emoji = toot.account.emojis[key5] var emoji = toot.account.emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
if (gif == 'yes') { if (gif == 'yes') {
@ -454,7 +454,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
var fullname = toot.account.acct + '@' + domain var fullname = toot.account.acct + '@' + domain
} }
if (useremp) { if (useremp) {
Object.keys(useremp).forEach(function(key10) { Object.keys(useremp).forEach(function (key10) {
var user = useremp[key10] var user = useremp[key10]
if (user == fullname) { if (user == fullname) {
boostback = 'emphasized' boostback = 'emphasized'
@ -494,7 +494,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
var via = escapeHTML(toot.application.name) var via = escapeHTML(toot.application.name)
if (empCli) { if (empCli) {
//強調チェック //強調チェック
Object.keys(empCli).forEach(function(key6) { Object.keys(empCli).forEach(function (key6) {
var empCliList = empCli[key6] var empCliList = empCli[key6]
if (empCliList == via) { if (empCliList == via) {
boostback = 'emphasized' boostback = 'emphasized'
@ -503,7 +503,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
if (muteCli) { if (muteCli) {
//ミュートチェック //ミュートチェック
Object.keys(muteCli).forEach(function(key7) { Object.keys(muteCli).forEach(function (key7) {
var muteCliList = muteCli[key7] var muteCliList = muteCli[key7]
if (muteCliList == via) { if (muteCliList == via) {
boostback = 'hide' boostback = 'hide'
@ -597,7 +597,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
if (mediack) { if (mediack) {
hasmedia = 'hasmedia' hasmedia = 'hasmedia'
var cwdt = 100 / toot.media_attachments.length var cwdt = 100 / toot.media_attachments.length
Object.keys(toot.media_attachments).forEach(function(key2) { Object.keys(toot.media_attachments).forEach(function (key2) {
var media = toot.media_attachments[key2] var media = toot.media_attachments[key2]
var purl = media.preview_url var purl = media.preview_url
media_ids = media_ids + media.id + ',' media_ids = media_ids + media.id + ','
@ -669,7 +669,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
if (menck) { if (menck) {
mentions = '' mentions = ''
var to_mention = [] var to_mention = []
Object.keys(toot.mentions).forEach(function(key3) { Object.keys(toot.mentions).forEach(function (key3) {
var mention = toot.mentions[key3] var mention = toot.mentions[key3]
//自分は除外 //自分は除外
//自インスタンスかどうかを確認し、IDの一致 //自インスタンスかどうかを確認し、IDの一致
@ -704,19 +704,19 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
var tags = '' var tags = ''
//タグであれば //タグであれば
if (tagck) { if (tagck) {
Object.keys(toot.tags).forEach(function(key4) { Object.keys(toot.tags).forEach(function (key4) {
var tag = toot.tags[key4] var tag = toot.tags[key4]
var featured = ` <a onclick="tagFeature('${tag.name}','${acct_id}')" class="pointer" title="add it to Featured tags">Feature</a> ` var featured = ` <a onclick="tagFeature('${tag.name}','${acct_id}')" class="pointer" title="add it to Featured tags">Feature</a> `
tags = tags =
tags + tags +
`<span class="hide" data-tag="${tag.name}" data-regTag="${tag.name.toLowerCase()}">#${ `<span class="hide" data-tag="${tag.name}" data-regTag="${tag.name.toLowerCase()}">#${
tag.name tag.name
}: }:
<a onclick="tl('tag','${tag.name}','${acct_id}','add')" class="pointer" <a onclick="tl('tag','${tag.name}','${acct_id}','add')" class="pointer"
title="${lang.lang_parse_tagTL.replace( title="${lang.lang_parse_tagTL.replace(
'{{tag}}', '{{tag}}',
'#' + tag.name '#' + tag.name
)}">TL</a> <a onclick="brInsert('#${tag.name}')" )}">TL</a> <a onclick="brInsert('#${tag.name}')"
class="pointer" title="${lang.lang_parse_tagtoot.replace('{{tag}}', '#' + tag.name)}">Toot</a>  class="pointer" title="${lang.lang_parse_tagtoot.replace('{{tag}}', '#' + tag.name)}">Toot</a> 
<a onclick="tagPin('${tag.name}')" class="pointer" title="${lang.lang_parse_tagpin.replace( <a onclick="tagPin('${tag.name}')" class="pointer" title="${lang.lang_parse_tagpin.replace(
'{{tag}}', '{{tag}}',
@ -812,7 +812,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//ワードミュート //ワードミュート
if (wordmuteList) { if (wordmuteList) {
Object.keys(wordmuteList).forEach(function(key8) { Object.keys(wordmuteList).forEach(function (key8) {
var worde = wordmuteList[key8] var worde = wordmuteList[key8]
if (worde) { if (worde) {
if (worde.tag) { if (worde.tag) {
@ -829,7 +829,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//ワード強調 //ワード強調
if (wordempList) { if (wordempList) {
Object.keys(wordempList).forEach(function(key9) { Object.keys(wordempList).forEach(function (key9) {
var wordList = wordempList[key9] var wordList = wordempList[key9]
if (wordList) { if (wordList) {
var wordList = wordList.tag var wordList = wordList.tag
@ -845,7 +845,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//絵文字があれば //絵文字があれば
if (emojick) { if (emojick) {
Object.keys(toot.emojis).forEach(function(key5) { Object.keys(toot.emojis).forEach(function (key5) {
var emoji = toot.emojis[key5] var emoji = toot.emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
if (gif == 'yes') { if (gif == 'yes') {
@ -871,7 +871,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
} }
//絵文字があれば(nico) //絵文字があれば(nico)
if (nicoemojick) { if (nicoemojick) {
Object.keys(toot.profile_emojis).forEach(function(keynico) { Object.keys(toot.profile_emojis).forEach(function (keynico) {
var emoji = toot.profile_emojis[keynico] var emoji = toot.profile_emojis[keynico]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
var emoji_url = `<img draggable="false" src="${emoji.url}" class="emoji-img" data-emoji="${shortcode}" alt=" :${shortcode}: " var emoji_url = `<img draggable="false" src="${emoji.url}" class="emoji-img" data-emoji="${shortcode}" alt=" :${shortcode}: "
@ -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,14 +930,41 @@ 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') {
};width:100%; height:0.9rem; font-size:0.8rem;" class="tickers"> 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="${ <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>`
break break
@ -950,14 +978,14 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
if (!quoteUser) { if (!quoteUser) {
quoteUser = toot.quote.account.acct quoteUser = toot.quote.account.acct
} }
if(!toot.quote.quote_muted) { if (!toot.quote.quote_muted) {
poll = poll =
poll + poll +
`<div class="quote-renote"> `<div class="quote-renote">
<div class="renote-icon"> <div class="renote-icon">
<a onclick="udg('${toot.quote.account.id}','${acct_id}');" user="${ <a onclick="udg('${toot.quote.account.id}','${acct_id}');" user="${
toot.quote.account.acct toot.quote.account.acct
}" class="udg"> }" class="udg">
<img draggable="false" src="${toot.quote.account.avatar}"> <img draggable="false" src="${toot.quote.account.avatar}">
</a> </a>
</div> </div>
@ -969,18 +997,18 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
</div> </div>
<div class="renote-details"> <div class="renote-details">
<a onclick="details('${ <a onclick="details('${
toot.quote.id toot.quote.id
}','${acct_id}','${tlid}','normal')" class="waves-effect waves-dark btn-flat details" style="padding:0"> }','${acct_id}','${tlid}','normal')" class="waves-effect waves-dark btn-flat details" style="padding:0">
<i class="text-darken-3 material-icons">more_vert</i> <i class="text-darken-3 material-icons">more_vert</i>
</a> </a>
</div> </div>
</div>` </div>`
} else { } else {
poll = poll =
poll + poll +
`<span class="gray sml">${lang.lang_parse_hidden}</span>` `<span class="gray sml">${lang.lang_parse_hidden}</span>`
} }
} }
//menuは何個 //menuは何個
var menuct = 2 var menuct = 2
@ -1069,8 +1097,8 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
</div> </div>
<div class="action ${can_rt} ${disp['rt']} ${noauth}"> <div class="action ${can_rt} ${disp['rt']} ${noauth}">
<a onclick="rt('${ <a onclick="rt('${
toot.id toot.id
}','${acct_id}','${tlid}')" class="waves-effect waves-dark btn-flat actct bt-btn" }','${acct_id}','${tlid}')" class="waves-effect waves-dark btn-flat actct bt-btn"
style="padding:0" title="${lang.lang_parse_bt}"> style="padding:0" title="${lang.lang_parse_bt}">
<i class="fas fa-retweet ${if_rt} rt_${toot.id}"></i> <i class="fas fa-retweet ${if_rt} rt_${toot.id}"></i>
<span class="voice">${lang.lang_parse_bt} </span> <span class="voice">${lang.lang_parse_bt} </span>
@ -1181,7 +1209,7 @@ function userparse(obj, auth, acct_id, tlid, popup) {
} }
var templete = '' var templete = ''
var datetype = localStorage.getItem('datetype') var datetype = localStorage.getItem('datetype')
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function (key) {
var toot = obj[key] var toot = obj[key]
if (toot) { if (toot) {
if (!toot.username) { if (!toot.username) {
@ -1258,7 +1286,7 @@ function userparse(obj, auth, acct_id, tlid, popup) {
} }
//絵文字があれば //絵文字があれば
if (actemojick) { if (actemojick) {
Object.keys(toot.emojis).forEach(function(key5) { Object.keys(toot.emojis).forEach(function (key5) {
var emoji = toot.emojis[key5] var emoji = toot.emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
if (gif == 'yes') { if (gif == 'yes') {
@ -1369,7 +1397,7 @@ function client(name) {
M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 })
} else { } else {
var can var can
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function (key) {
var cliT = obj[key] var cliT = obj[key]
if (cliT != name && !can) { if (cliT != name && !can) {
can = false can = false
@ -1457,7 +1485,7 @@ function pollParse(poll, acct_id, emojis) {
var max = 0 var max = 0
} }
Object.keys(choices).forEach(function(keyc) { Object.keys(choices).forEach(function (keyc) {
var choice = choices[keyc] var choice = choices[keyc]
var voteit = '' var voteit = ''
for (var i = 0; i < minechoice.length; i++) { for (var i = 0; i < minechoice.length; i++) {
@ -1492,7 +1520,7 @@ function pollParse(poll, acct_id, emojis) {
var choiceText = escapeHTML(choice.title) var choiceText = escapeHTML(choice.title)
if (emojis) { if (emojis) {
//絵文字があれば //絵文字があれば
Object.keys(emojis).forEach(function(key5) { Object.keys(emojis).forEach(function (key5) {
var emoji = emojis[key5] var emoji = emojis[key5]
var shortcode = emoji.shortcode var shortcode = emoji.shortcode
if (gif == 'yes') { if (gif == 'yes') {

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') $('#spotify-code-show').removeClass('hide')
if (platform == 'win32') { postMessage(['openUrl', auth], '*')
postMessage(['openUrl', auth], '*')
postMessage(['sendSinmpleIpc', 'quit'], '*')
} else {
auth = auth + '&state=code'
$('#spotify-code-show').removeClass('hide')
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, {
checkSpotify() 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() { 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
@ -169,9 +186,9 @@ function nowplaying(mode) {
return false return false
} }
var item = json.recenttracks.track[0] var item = json.recenttracks.track[0]
if(!item['@attr']) return false if (!item['@attr']) return false
var img = item.image[3]['#text'] var img = item.image[3]['#text']
var isImg = item.streamable*1 var isImg = item.streamable * 1
var flag = localStorage.getItem('artwork') var flag = localStorage.getItem('artwork')
if (flag && isImg && img) { if (flag && isImg && img) {
postMessage(['bmpImage', [img, 0]], '*') postMessage(['bmpImage', [img, 0]], '*')
@ -187,7 +204,7 @@ function nowplaying(mode) {
var regExp = new RegExp('{artist}', 'g') var regExp = new RegExp('{artist}', 'g')
content = content.replace(regExp, item.artist['#text']) content = content.replace(regExp, item.artist['#text'])
var regExp = new RegExp('{url}', 'g') var regExp = new RegExp('{url}', 'g')
content = content.replace(regExp,'') content = content.replace(regExp, '')
var regExp = new RegExp('{composer}', 'g') var regExp = new RegExp('{composer}', 'g')
content = content.replace(regExp, '') content = content.replace(regExp, '')
var regExp = new RegExp('{hz}', 'g') var regExp = new RegExp('{hz}', 'g')

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')