diff --git a/src/clean_url.js b/src/clean_url.js index edf6f1f2..9b62d342 100644 --- a/src/clean_url.js +++ b/src/clean_url.js @@ -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) }