1
Fork 0

add channelurlfixer

This commit is contained in:
Ashley 2023-09-13 19:06:20 +00:00
parent ad4924afab
commit 5b90c0d5a4

View file

@ -26,8 +26,7 @@ function linkify(text) {
return text.replace(urlRegex, (url) => {
// wrap the URL in an <a> tag with the URL as the href attribute
return `<a href="/api/redirect?u=${btoa(
url
return `<a href="/api/redirect?u=${btoa(url
.replace(/twitter\.com/g, "nitter.net")
.replace(/reddit\.com/g, "teddit.net")
.replace("https://youtube.com", "")
@ -36,6 +35,15 @@ function linkify(text) {
});
}
function channelurlfixer(text) {
// Create a regular expression to match <a> tags with href containing "/channel/"
const regex = /<a\s+href="\/channel\/([^"]+)"/g;
// Replace matching <a> tags with the modified href attribute
const updatedDescription = text.replace(regex, '<a href="/channel?id=$1"');
return updatedDescription;
}
function endsWithYouTubeAutoGenerated(text) {
const target = " Auto-generated by YouTube. ";
return text.endsWith(target);
@ -237,6 +245,7 @@ module.exports = function (app, config, renderTemplate) {
if (uaos === "Windows XP" || uaos === "Windows Vista")
res.redirect("/lite?v=" + req.query.v);
try {
renderTemplate(res, req, "poketube.ejs", {
color: data.color,
@ -244,6 +253,7 @@ module.exports = function (app, config, renderTemplate) {
linkify,
engagement,
IsOldWindows,
channelurlfixer,
support,
u: u.url,
isvidious: u.isInvidiousURL,