mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-17 18:58:33 +00:00
more Twitter link support
* fixvx.com (vxtwitter / BetterTwitFix) * fxtwitter.com (FixTweet) * d.fxtwitter.com (FixTweet) * twittpr.com (FixTweet) * d.twittpr.com (FixTweet) * fixupx.com (FixTweet) * d.fixupx.com (FixTweet)
This commit is contained in:
parent
3c1fedc4ef
commit
82523bffc8
@ -14,7 +14,9 @@ export async function getJSON(originalURL, lang, obj) {
|
|||||||
hostname = new URL(url).hostname.split('.'),
|
hostname = new URL(url).hostname.split('.'),
|
||||||
host = hostname[hostname.length - 2];
|
host = hostname[hostname.length - 2];
|
||||||
|
|
||||||
|
if (url.startsWith('http://')) url = url.replace('http://', 'https://');
|
||||||
if (!url.startsWith('https://')) return apiJSON(0, { t: errorUnsupported(lang) });
|
if (!url.startsWith('https://')) return apiJSON(0, { t: errorUnsupported(lang) });
|
||||||
|
if (url.startsWith("https://www.")) url = url.replace("https://www.", "https://");
|
||||||
|
|
||||||
let overrides = hostOverrides(host, url);
|
let overrides = hostOverrides(host, url);
|
||||||
host = overrides.host;
|
host = overrides.host;
|
||||||
|
@ -3,12 +3,49 @@ export default function (inHost, inURL) {
|
|||||||
let url = String(inURL);
|
let url = String(inURL);
|
||||||
|
|
||||||
switch(host) {
|
switch(host) {
|
||||||
case "youtube":
|
case "tumblr":
|
||||||
if (url.startsWith("https://youtube.com/live/") || url.startsWith("https://www.youtube.com/live/")) {
|
if (!url.includes("blog/view")) {
|
||||||
url = url.split("?")[0].replace("www.", "");
|
if (url.slice(-1) === '/') url = url.slice(0, -1);
|
||||||
url = `https://youtube.com/watch?v=${url.replace("https://youtube.com/live/", "")}`
|
url = url.replace(url.split('/')[5], '')
|
||||||
}
|
}
|
||||||
if (url.includes('youtube.com/shorts/')) {
|
break;
|
||||||
|
case "twitch":
|
||||||
|
if (url.startsWith("https://clips.twitch.tv")) {
|
||||||
|
url = url.split('?')[0].replace('clips.twitch.tv/', 'twitch.tv/_/clip/');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "vxtwitter":
|
||||||
|
case "fixvx":
|
||||||
|
case "fxtwitter":
|
||||||
|
case "twittpr":
|
||||||
|
case "fixupx":
|
||||||
|
case "x":
|
||||||
|
if (url.startsWith("https://vxtwitter.com/")) {
|
||||||
|
host = "twitter";
|
||||||
|
url = url.replace("https://vxtwitter.com/", "https://twitter.com/")
|
||||||
|
}
|
||||||
|
if (url.startsWith("https://fixvx.com/")) {
|
||||||
|
host = "twitter";
|
||||||
|
url = url.replace("https://fixvx.com/", "https://twitter.com/")
|
||||||
|
}
|
||||||
|
if (url.match(/^https:\/\/(d\.|dl\.|)(fxtwitter|twittpr|fixupx).com\//g)) {
|
||||||
|
host = "twitter";
|
||||||
|
url = url.replace(url.match(/^https:\/\/(d\.|dl\.|)(fxtwitter|twittpr|fixupx).com\//g)[0], "https://twitter.com/")
|
||||||
|
if (url.endsWith(".mp4")) url = url.replace(".mp4", "")
|
||||||
|
if (url.endsWith('.jpg')) url = url.replace(".jpg", "")
|
||||||
|
if (url.startsWith("https://twitter.com/dl/")) url = url.replace("https://twitter.com/dl/", "https://twitter.com/")
|
||||||
|
if (url.startsWith("https://twitter.com/dir/")) url = url.replace("https://twitter.com/dir/", "https://twitter.com/")
|
||||||
|
}
|
||||||
|
if (url.startsWith("https://x.com/")) {
|
||||||
|
host = "twitter";
|
||||||
|
url = url.replace("https://x.com/", "https://twitter.com/")
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "youtube":
|
||||||
|
if (url.startsWith("https://youtube.com/live/")) {
|
||||||
|
url = `https://youtube.com/watch?v=${url.split("?")[0].replace("https://youtube.com/live/", "")}`
|
||||||
|
}
|
||||||
|
if (url.startsWith("https://youtube.com/shorts/")) {
|
||||||
url = url.split('?')[0].replace('shorts/', 'watch?v=');
|
url = url.split('?')[0].replace('shorts/', 'watch?v=');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -18,28 +55,6 @@ export default function (inHost, inURL) {
|
|||||||
url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}`
|
url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}`
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "vxtwitter":
|
|
||||||
case "x":
|
|
||||||
if (url.startsWith("https://x.com/")) {
|
|
||||||
host = "twitter";
|
|
||||||
url = url.replace("https://x.com/", "https://twitter.com/")
|
|
||||||
}
|
|
||||||
if (url.startsWith("https://vxtwitter.com/")) {
|
|
||||||
host = "twitter";
|
|
||||||
url = url.replace("https://vxtwitter.com/", "https://twitter.com/")
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "tumblr":
|
|
||||||
if (!url.includes("blog/view")) {
|
|
||||||
if (url.slice(-1) === '/') url = url.slice(0, -1);
|
|
||||||
url = url.replace(url.split('/')[5], '')
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "twitch":
|
|
||||||
if (url.includes('clips.twitch.tv')) {
|
|
||||||
url = url.split('?')[0].replace('clips.twitch.tv/', 'twitch.tv/_/clip/');
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
host: host,
|
host: host,
|
||||||
|
Loading…
Reference in New Issue
Block a user