feat(clean_url): shopmy, disqus, vkontakte, whatsapp, google ads/search links

This commit is contained in:
MDLeom 2025-05-24 03:12:03 +00:00
parent 8f95fd3182
commit 496967732f
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
1 changed files with 28 additions and 0 deletions

View File

@ -46,6 +46,34 @@ const deSafelink = (urlStr) => {
url = new URL(url.searchParams.get('a'))
}
// ShopMy & Disqus
if ((url.hostname === 'api.shopmy.us' && url.pathname === '/api/redirect_click') || url.hostname === 'disq.us') {
url = new URL(url.searchParams.get('url'))
}
// VKontakte
if ((url.hostname === 'vk.com' || url.hostname === 'vkontakte.ru') && url.pathname === '/away.php') {
url = new URL(url.searchParams.get('to'))
}
// WhatsApp
if (url.hostname === 'l.wl.co' && url.pathname === '/l') {
url = new URL(url.searchParams.get('u'))
}
// Google Ads
if (url.hostname.endsWith('doubleclick.net') || url.hostname.endsWith('googleadservices.com')) {
const paramUrl = url.searchParams.getAll('adurl').at(-1) || url.searchParams.getAll('url').at(-1) || url.searchParams.getAll('ds_dest_url').at(-1)
if (paramUrl) url = new URL(paramUrl)
}
// Google Search
// Google AMP does not redirect (e.g. google.com/amp/example.com)
if (url.hostname.endsWith('google.com') && (url.pathname.startsWith('/url') || url.pathname.startsWith('/travel/clk'))) {
const paramUrl = url.searchParams.get('q') || url.searchParams.get('url') || url.searchParams.get('pcurl')
if (paramUrl) url = new URL(paramUrl)
}
if (url.hostname.match(new RegExp(safeLinks.join('|')))) {
return deSafelink(url.href)
}