Update url-preview.vue

This commit is contained in:
Acid Chicken (硫酸鶏) 2018-08-09 04:05:28 +09:00 committed by GitHub
parent 196c55edbc
commit ebf0479ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,9 @@
<iframe v-else-if="spotifyId" <iframe v-else-if="spotifyId"
:src="`https://open.spotify.com/embed/track/${spotifyId}`" :src="`https://open.spotify.com/embed/track/${spotifyId}`"
frameborder="0" allowtransparency="true" allow="encrypted-media" /> frameborder="0" allowtransparency="true" allow="encrypted-media" />
<iframe v-else-if="nicovideoId"
:src="`https://embed.nicovideo.jp/watch/${nicovideoId}?oldScript=1&referer=${misskeyUrl}&from=${position || '0'}&allowProgrammaticFullScreen=1`"
frameborder="0" allow="autoplay; encrypted-media" allowfullscreen />
<div v-else-if="tweetUrl && detail" class="twitter"> <div v-else-if="tweetUrl && detail" class="twitter">
<blockquote ref="tweet" class="twitter-tweet" :data-theme="$store.state.device.darkmode ? 'dark' : null"> <blockquote ref="tweet" class="twitter-tweet" :data-theme="$store.state.device.darkmode ? 'dark' : null">
<a :href="url"></a> <a :href="url"></a>
@ -52,6 +55,9 @@ export default Vue.extend({
icon: null, icon: null,
sitename: null, sitename: null,
youtubeId: null, youtubeId: null,
spotifyId: null,
nicovideoId: null,
position: null,
tweetUrl: null, tweetUrl: null,
misskeyUrl misskeyUrl
}; };
@ -65,6 +71,9 @@ export default Vue.extend({
this.youtubeId = url.pathname; this.youtubeId = url.pathname;
} else if (url.hostname == 'open.spotify.com') { } else if (url.hostname == 'open.spotify.com') {
this.spotifyId = url.pathname.split('/').reverse().filter(x => x !== '')[0]; this.spotifyId = url.pathname.split('/').reverse().filter(x => x !== '')[0];
} else if (['nicovideo.jp', 'www.nicovideo.jp', 'nico.ms'].includes(url.hostname)) {
this.nicovideoId = url.pathname.split('/').reverse().filter(x => x !== '')[0];
this.position = url.searchParams.get('from');
} else if (this.detail && url.hostname == 'twitter.com' && /^\/.+\/status(es)?\/\d+/.test(url.pathname)) { } else if (this.detail && url.hostname == 'twitter.com' && /^\/.+\/status(es)?\/\d+/.test(url.pathname)) {
this.tweetUrl = url; this.tweetUrl = url;
const twttr = (window as any).twttr || {}; const twttr = (window as any).twttr || {};