mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 06:08:34 +01:00
add channelurlfixer
This commit is contained in:
parent
ad4924afab
commit
5b90c0d5a4
1 changed files with 12 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue