forked from FoundKeyGang/FoundKey
Update url-preview.vue
This commit is contained in:
parent
ebf0479ecc
commit
6a92c19227
1 changed files with 21 additions and 14 deletions
|
@ -67,13 +67,20 @@ export default Vue.extend({
|
||||||
|
|
||||||
if (url.hostname == 'www.youtube.com') {
|
if (url.hostname == 'www.youtube.com') {
|
||||||
this.youtubeId = url.searchParams.get('v');
|
this.youtubeId = url.searchParams.get('v');
|
||||||
|
return;
|
||||||
} else if (url.hostname == 'youtu.be') {
|
} else if (url.hostname == 'youtu.be') {
|
||||||
this.youtubeId = url.pathname;
|
this.youtubeId = url.pathname;
|
||||||
|
return;
|
||||||
} 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];
|
||||||
|
return;
|
||||||
} else if (['nicovideo.jp', 'www.nicovideo.jp', 'nico.ms'].includes(url.hostname)) {
|
} else if (['nicovideo.jp', 'www.nicovideo.jp', 'nico.ms'].includes(url.hostname)) {
|
||||||
this.nicovideoId = url.pathname.split('/').reverse().filter(x => x !== '')[0];
|
const id = url.pathname.split('/').reverse().filter(x => x !== '')[0];
|
||||||
|
if (['sm', 'nm', 'ax', 'ca', 'cd', 'cw', 'fx', 'ig', 'na', 'om', 'sd', 'sk', 'yk', 'yo', 'za', 'zb', 'zc', 'zd', 'ze', 'nl', 'so', ...Array(10).keys()].some(x => id.startsWith(x)) {
|
||||||
|
this.nicovideoId = id;
|
||||||
this.position = url.searchParams.get('from');
|
this.position = url.searchParams.get('from');
|
||||||
|
return;
|
||||||
|
}
|
||||||
} 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 || {};
|
||||||
|
@ -93,7 +100,8 @@ export default Vue.extend({
|
||||||
twttr.ready = loadTweet;
|
twttr.ready = loadTweet;
|
||||||
(window as any).twttr = twttr;
|
(window as any).twttr = twttr;
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
fetch('/url?url=' + encodeURIComponent(this.url)).then(res => {
|
fetch('/url?url=' + encodeURIComponent(this.url)).then(res => {
|
||||||
res.json().then(info => {
|
res.json().then(info => {
|
||||||
this.title = info.title;
|
this.title = info.title;
|
||||||
|
@ -106,7 +114,6 @@ export default Vue.extend({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue