mirror of
				https://codeberg.org/ashley/poke
				synced 2025-07-17 16:52:11 +00:00 
			
		
		
		
	add channelurlfixer
This commit is contained in:
		
							parent
							
								
									ad4924afab
								
							
						
					
					
						commit
						5b90c0d5a4
					
				| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ashley
						Ashley