mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 21:57:49 +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) => {
|
return text.replace(urlRegex, (url) => {
|
||||||
// wrap the URL in an <a> tag with the URL as the href attribute
|
// wrap the URL in an <a> tag with the URL as the href attribute
|
||||||
return `<a href="/api/redirect?u=${btoa(
|
return `<a href="/api/redirect?u=${btoa(url
|
||||||
url
|
|
||||||
.replace(/twitter\.com/g, "nitter.net")
|
.replace(/twitter\.com/g, "nitter.net")
|
||||||
.replace(/reddit\.com/g, "teddit.net")
|
.replace(/reddit\.com/g, "teddit.net")
|
||||||
.replace("https://youtube.com", "")
|
.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) {
|
function endsWithYouTubeAutoGenerated(text) {
|
||||||
const target = " Auto-generated by YouTube. ";
|
const target = " Auto-generated by YouTube. ";
|
||||||
return text.endsWith(target);
|
return text.endsWith(target);
|
||||||
|
@ -237,6 +245,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
if (uaos === "Windows XP" || uaos === "Windows Vista")
|
if (uaos === "Windows XP" || uaos === "Windows Vista")
|
||||||
res.redirect("/lite?v=" + req.query.v);
|
res.redirect("/lite?v=" + req.query.v);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
renderTemplate(res, req, "poketube.ejs", {
|
renderTemplate(res, req, "poketube.ejs", {
|
||||||
color: data.color,
|
color: data.color,
|
||||||
|
@ -244,6 +253,7 @@ module.exports = function (app, config, renderTemplate) {
|
||||||
linkify,
|
linkify,
|
||||||
engagement,
|
engagement,
|
||||||
IsOldWindows,
|
IsOldWindows,
|
||||||
|
channelurlfixer,
|
||||||
support,
|
support,
|
||||||
u: u.url,
|
u: u.url,
|
||||||
isvidious: u.isInvidiousURL,
|
isvidious: u.isInvidiousURL,
|
||||||
|
|
Loading…
Reference in a new issue