newhouse / url-tracking-stripper

An open-source Chrome Extension that will remove the tracking parameters from URLs to keep them short and cleaner for sharing, bookmarking, etc. It will also skip any known redirects and take you straight to the target URL instead of passing you through an intermediate URL.
MIT License
192 stars 26 forks source link

Add support for ad.doubleclick.net track link #58

Open rayou opened 6 years ago

rayou commented 6 years ago

Example URLs:

- http://ad.doubleclick.net/clk;274204538;98873843;y?http://www.food.com/recipe/cuban-pork-adobo-salad-501729
- http://ad.doubleclick.net/clk;272664759;101583304;i?http://www.porkbeinspired.com/RecipeDetail/2770/Cuban_Pork_Adobo_Salad.aspx

As you can see, doubleclick track link doesn't put target URL in any parameters, targetParam method can't fit this case.

I'd like to propose to use regex for parsing target URLs also keep the current "param" parse method:

Add targetRegex:

  {
    name: 'Doubleclick',
    targetRegex: /\?(.*)$/,
//  targetParam: "url", 
    patterns: [
      `${SCHEMA}ad.doubleclick.net${PATH}?`
    ],
    types: ['main_frame']
  }

OR

Add parseMethod to make it explicit:

  {
    name: 'Doubleclick',
    parseMethod: "regex", // Accepts: "param" | "regex" 
    target: /\?(.*)$/, // Accept types: string | regex
    patterns: [
      `${SCHEMA}ad.doubleclick.net${PATH}?`
    ],
    types: ['main_frame']
  }

OR

Use target: (one property to rule them all)

  {
    name: 'Doubleclick',
    target: /\?(.*)$/, // Accept types: string | regex
    patterns: [
      `${SCHEMA}ad.doubleclick.net${PATH}?`
    ],
    types: ['main_frame']
  }

However, this implementation requires a major revamp, so would like to hear some feedback.