urluntrackify 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of urluntrackify might be problematic. Click here for more details.
- urluntrackify/__init__.py +1 -0
- urluntrackify/arguments.py +457 -0
- urluntrackify/untrackify.py +40 -0
- urluntrackify-0.1.0.dist-info/METADATA +100 -0
- urluntrackify-0.1.0.dist-info/RECORD +8 -0
- urluntrackify-0.1.0.dist-info/WHEEL +5 -0
- urluntrackify-0.1.0.dist-info/licenses/LICENSE.md +9 -0
- urluntrackify-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .untrackify import sanitize
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
arguments = [ #{{{1
|
|
2
|
+
{
|
|
3
|
+
'type': 'tracker',
|
|
4
|
+
'company': 'Generic/Unknown',
|
|
5
|
+
'service': 'Campaign identifier',
|
|
6
|
+
'arg': 'CMP'
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
'type': 'tracker',
|
|
10
|
+
'company': 'Generic/Unknown',
|
|
11
|
+
'service': 'Campaign identifier',
|
|
12
|
+
'arg': r'c(?:a|a?mp)(?:id)?'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
'type': 'tracker',
|
|
16
|
+
'company': 'Generic/Unknown',
|
|
17
|
+
'service': 'Campaign identifier',
|
|
18
|
+
'arg': r'(?:source|campaign_)id'
|
|
19
|
+
},
|
|
20
|
+
# {
|
|
21
|
+
# 'type': 'unknown',
|
|
22
|
+
# 'arg': 'cd-origin'
|
|
23
|
+
# },
|
|
24
|
+
# {
|
|
25
|
+
# 'type': 'unknown',
|
|
26
|
+
# 'arg': 'ncid'
|
|
27
|
+
# 'comment': 'may have legitimate use in CiNii-based databases'
|
|
28
|
+
# },
|
|
29
|
+
{
|
|
30
|
+
'type': 'misc',
|
|
31
|
+
'company': 'Generic',
|
|
32
|
+
'service': 'Accelerated mobile pages',
|
|
33
|
+
'arg': r'amp(?:_action|_ts)',
|
|
34
|
+
'comment': 'https://amp.dev/documentation/guides-and-tutorials/'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
'type': 'ads',
|
|
38
|
+
'company': 'Adobe',
|
|
39
|
+
'service': 'Advertising',
|
|
40
|
+
'arg': r'(?:ef_|s_kwc)id'
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
'type': 'tracker',
|
|
44
|
+
'company': 'Adobe',
|
|
45
|
+
'service': 'Marketo',
|
|
46
|
+
'arg': 'mkt_tok'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
'type': 'analytics',
|
|
50
|
+
'company': 'Adobe',
|
|
51
|
+
'service': 'SiteCatalyst',
|
|
52
|
+
'arg': 's_cid'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
'type': 'tracker',
|
|
56
|
+
'company': 'Branch',
|
|
57
|
+
'service': 'branch.io',
|
|
58
|
+
'arg': '_branch_match_id'
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
'type': 'bulkmailer',
|
|
62
|
+
'service': 'dotdigital',
|
|
63
|
+
'arg': 'dm_i'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
'type': 'bulkmailer',
|
|
67
|
+
'service': 'drip.com',
|
|
68
|
+
'arg': '__s'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
'type': 'internal',
|
|
72
|
+
'company': 'eBay',
|
|
73
|
+
'dom': r'[./]ebay\.',
|
|
74
|
+
'arg': r'(?:c(?:amp|ustom)|mk[cr]|site|tool)id|mkevt|_trkparms|_from'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
'type': 'tracker',
|
|
78
|
+
'company': 'EMCI media',
|
|
79
|
+
'arg': 'emci'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
'type': 'tracker',
|
|
83
|
+
'company': 'Unknown, possibly EMCI media as well',
|
|
84
|
+
'arg': 'emdi'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
'type': 'ads',
|
|
88
|
+
'company': 'Meta, formerly Facebook',
|
|
89
|
+
'arg': 'fbclid'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
'type': 'tracker',
|
|
93
|
+
'company': 'GoDataFeed',
|
|
94
|
+
'arg': r'gdf(?:fi|ms|trk)'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
'type': 'ads',
|
|
98
|
+
'company': 'Google',
|
|
99
|
+
'service': 'Ads',
|
|
100
|
+
'arg': 'gad_source'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
'type': 'ads',
|
|
104
|
+
'company': 'Google',
|
|
105
|
+
'service': 'Marketing Platform, formerly DoubleClick',
|
|
106
|
+
'arg': 'dclid'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
'type': 'analytics',
|
|
110
|
+
'company': 'Google',
|
|
111
|
+
'service': 'Analytics',
|
|
112
|
+
'arg': r'_g[al]|gcl(?:id|src)|[gw]braid|_gac|_gid'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
'type': 'analytics',
|
|
116
|
+
'company': 'Google',
|
|
117
|
+
'service': 'Analytics, formerly Urchin',
|
|
118
|
+
'arg': r'utm_(?:campaign|content|creative_format|marketing_tactic|medium|source(?:_platform)?|term)'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
'type': 'tracker',
|
|
122
|
+
'company': 'Hootsuite',
|
|
123
|
+
'arg': 'hootPostID'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
'type': 'tracker',
|
|
127
|
+
'company': 'HubSpot',
|
|
128
|
+
'arg': r'hsa_(?:a(?:cc|d)|grp|kw|mt|net|src|tgt|ver)|__hs(?:fp|[st]c)|_hsenc|hsCtaTracking'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
'type': 'tracker',
|
|
132
|
+
'company': 'Meta, formerly Instagram',
|
|
133
|
+
'arg': 'igshid'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
'type': 'tracker',
|
|
137
|
+
'company': 'Impact, formerly Impact Radius',
|
|
138
|
+
'arg': 'irclickid'
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
'type': 'tracker',
|
|
142
|
+
'company': 'Klaviyo',
|
|
143
|
+
'arg': r'_k[ex]'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
'type': 'tracker',
|
|
147
|
+
'company': 'Listrak',
|
|
148
|
+
'arg': r'trk_(?:contact|m(?:sg|odule)|sid)'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
'type': 'tracker',
|
|
152
|
+
'company': 'Microsoft (LinkedIn)',
|
|
153
|
+
'arg': 'li_fat_id'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
'type': 'bulkmailer',
|
|
157
|
+
'company': 'MailChimp',
|
|
158
|
+
'arg': r'mc_[ce]id'
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
'type': 'bulkmailer',
|
|
162
|
+
'company': 'MailerLite',
|
|
163
|
+
'arg': r'ml_subscriber(?:_hash)'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
'type': 'tracker',
|
|
167
|
+
'company': 'Marin',
|
|
168
|
+
'arg': r'(?:mkw|pcr)id'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
'type': 'analytics',
|
|
172
|
+
'company': 'Matomo',
|
|
173
|
+
'arg': r'(?:mtm|matomo)_(?:c(?:ampaign|ontent|id)|group|keyword|medium|placement|source)'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
'type': 'ads',
|
|
177
|
+
'company': 'Microsoft',
|
|
178
|
+
'arg': 'msclkid'
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
'type': 'ads',
|
|
182
|
+
'company': 'NextDoor',
|
|
183
|
+
'arg': 'ndclid'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
'type': 'tracker',
|
|
187
|
+
'company': 'Omeda',
|
|
188
|
+
'arg': r'oly_(?:anon|enc)_id'
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
'type': 'tracker',
|
|
192
|
+
'company': 'Dialog Insight',
|
|
193
|
+
'arg': r'oft_(?:ck?|d|ids?|s?k)'
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
'type': 'tracker',
|
|
197
|
+
'company': 'Openstat',
|
|
198
|
+
'arg': '_openstat',
|
|
199
|
+
'comment': 'frequently seen on Yandex'
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
'type': 'tracker',
|
|
203
|
+
'company': 'Oracle',
|
|
204
|
+
'service': 'Bronto',
|
|
205
|
+
'arg': r'_bta_(?:c|tid)'
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
'type': 'tracker',
|
|
209
|
+
'company': 'Pinterest',
|
|
210
|
+
'arg': 'epik'
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
'type': 'tracker',
|
|
214
|
+
'company': 'possibly Mapp, formerly WebTrekk',
|
|
215
|
+
'arg': 'ceid'
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
'type': 'analytics',
|
|
219
|
+
'company': 'Matomo, formerly Piwik',
|
|
220
|
+
'arg': r'p(?:iwi)k_(?:campaign|k(?:eywor|w)d)'
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
'type': 'tracker',
|
|
224
|
+
'company': 'Rokt',
|
|
225
|
+
'arg': 'rtid'
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
'type': 'tracker',
|
|
229
|
+
'company': 'Snap Inc. (SnapChat)',
|
|
230
|
+
'arg': 'ScCid'
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
'type': 'tracker',
|
|
234
|
+
'company': 'Seznam',
|
|
235
|
+
'service': 'Sklik',
|
|
236
|
+
'arg': 'sznclid'
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
'type': 'internal',
|
|
240
|
+
'company': 'Spotify, Google (YouTube)',
|
|
241
|
+
'dom': r'(?:(?:.*\.)?spotify\.com|youtube\.com|youtu\.be)(?=/)',
|
|
242
|
+
'arg': 'si',
|
|
243
|
+
'comment': "possibly 'share identifer'"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
'type': 'bulkmailer',
|
|
247
|
+
'company': 'SpringBot',
|
|
248
|
+
'arg': r'redirect(?:_log)?_mongo_id|sb_referer_host'
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
'type': 'tracker',
|
|
252
|
+
'company': 'TikTok',
|
|
253
|
+
'arg': 'ttclid'
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
'type': 'tracker',
|
|
257
|
+
'company': 'X, formerly Twitter',
|
|
258
|
+
'arg': 'twclid'
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
'type': 'tracker',
|
|
262
|
+
'company': 'Unknown, possible russsian origin',
|
|
263
|
+
'arg': 'rb_clickid'
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
'type': 'tracker',
|
|
267
|
+
'company': 'Vero',
|
|
268
|
+
'arg': r'vero_(?:conv|id)'
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
'type': 'analytics',
|
|
272
|
+
'company': 'WebTrends',
|
|
273
|
+
'arg': r'WT\.(?:mc_id|nav)'
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
'type': 'tracker',
|
|
277
|
+
'company': 'Wicked Reports',
|
|
278
|
+
'arg': 'wickedid'
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
'type': 'tracker',
|
|
282
|
+
'company': 'Wikimedia',
|
|
283
|
+
'service': 'Provenance',
|
|
284
|
+
'arg': 'wprov'
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
'type': 'tracker',
|
|
288
|
+
'company': 'Wunderkind',
|
|
289
|
+
'arg': r'sms_(?:click|source|uph)'
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
'type': 'tracker',
|
|
293
|
+
'company': 'both Yahoo! and Yandex',
|
|
294
|
+
'service': 'Yahoo! Japan ads and Yandex Direct respectively',
|
|
295
|
+
'arg': 'yclid'
|
|
296
|
+
},
|
|
297
|
+
# {
|
|
298
|
+
# 'type': 'tracker',
|
|
299
|
+
# 'company': 'Yahoo!',
|
|
300
|
+
# 'service': 'Mail consent tracking',
|
|
301
|
+
# 'arg': 'guccounter',
|
|
302
|
+
# 'comment': 'breaks login sessions when removed'
|
|
303
|
+
# },
|
|
304
|
+
{
|
|
305
|
+
'type': 'tracker',
|
|
306
|
+
'service': 'Awin, formerly Zanox',
|
|
307
|
+
'arg': 'zanpid'
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
'type': 'tracker',
|
|
311
|
+
'service': 'Awin',
|
|
312
|
+
'arg': 'awinaffid'
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
'type': 'tracker',
|
|
316
|
+
'company': 'CJ Affiliate',
|
|
317
|
+
'arg': 'cje'
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
'type': 'tracker',
|
|
321
|
+
'company': 'Disney+',
|
|
322
|
+
'arg': 'tgclid'
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
'type': 'analytics',
|
|
326
|
+
'company': 'Generic',
|
|
327
|
+
'service': 'Google News Showcase entitlement',
|
|
328
|
+
'arg': r'gaa_(?:at|n|ts|sig)'
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
'type': 'analytics',
|
|
332
|
+
'company': 'Google',
|
|
333
|
+
'service': 'Shopping tracking',
|
|
334
|
+
'arg': 'srsltid'
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
'type': 'tracker',
|
|
338
|
+
'company': 'Generic',
|
|
339
|
+
'service': 'Campaign (itm variant)',
|
|
340
|
+
'arg': r'itm_(?:campaign|medium|source)'
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
'type': 'tracker',
|
|
344
|
+
'company': 'Meta, formerly Facebook',
|
|
345
|
+
'arg': r'fb_action_(?:types|ids)|fb_(?:source|ref)|action_(?:object|type|ref)_map'
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
'type': 'tracker',
|
|
349
|
+
'company': 'Meta (cross-platform share identifier)',
|
|
350
|
+
'arg': 'mibextid'
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
'type': 'tracker',
|
|
354
|
+
'company': 'Meta, formerly Facebook',
|
|
355
|
+
'dom': r'[./]facebook\.com',
|
|
356
|
+
'arg': r'hc_[a-z_%\[\]0-9]*|__tn__|sfnsn|paipv|_rdr'
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
'type': 'tracker',
|
|
360
|
+
'company': 'Meta, formerly Instagram',
|
|
361
|
+
'dom': r'[./]instagram\.com',
|
|
362
|
+
'arg': 'igsh'
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
'type': 'tracker',
|
|
366
|
+
'company': 'X, formerly Twitter',
|
|
367
|
+
'arg': '__twitter_impression'
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
'type': 'tracker',
|
|
371
|
+
'company': 'X, formerly Twitter',
|
|
372
|
+
'dom': r'[./](?:twitter|x)\.com',
|
|
373
|
+
'arg': r's|cn'
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
'type': 'tracker',
|
|
377
|
+
'company': 'Google (YouTube)',
|
|
378
|
+
'dom': r'(?:youtube\.com|youtu\.be)(?=/)',
|
|
379
|
+
'arg': r'feature|pp'
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
'type': 'tracker',
|
|
383
|
+
'company': 'Microsoft (LinkedIn)',
|
|
384
|
+
'dom': r'[./]linkedin\.com',
|
|
385
|
+
'arg': r'refId|trk|li[a-z]{2}|trackingId'
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
'type': 'internal',
|
|
389
|
+
'company': 'Netflix',
|
|
390
|
+
'dom': r'[./]netflix\.com',
|
|
391
|
+
'arg': r'trackId|tctx|jb[a-z]*'
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
'type': 'internal',
|
|
395
|
+
'company': 'Steam (Valve)',
|
|
396
|
+
'dom': r'[./]steam(?:powered|community)\.com',
|
|
397
|
+
'arg': 'snr'
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
'type': 'tracker',
|
|
401
|
+
'company': 'Mindbox',
|
|
402
|
+
'arg': 'mindbox-click-id'
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
'type': 'tracker',
|
|
406
|
+
'company': 'Omnisend',
|
|
407
|
+
'arg': 'omnisendContactID'
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
'type': 'tracker',
|
|
411
|
+
'company': 'Echobox',
|
|
412
|
+
'arg': 'Echobox'
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
'type': 'tracker',
|
|
416
|
+
'company': 'Ceneo',
|
|
417
|
+
'arg': 'ceneo_spo'
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
'type': 'tracker',
|
|
421
|
+
'company': 'Canva',
|
|
422
|
+
'arg': 'analyticsCorrelationId'
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
'type': 'tracker',
|
|
426
|
+
'company': 'Vero',
|
|
427
|
+
'arg': 'vgo_ee'
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
'type': 'tracker',
|
|
431
|
+
'company': 'Spotify',
|
|
432
|
+
'service': 'Deep link share identifier',
|
|
433
|
+
'arg': 'dlsi'
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
'type': 'analytics',
|
|
437
|
+
'company': 'Generic',
|
|
438
|
+
'arg': 'tracking_source'
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
# 'type': 'unknown|tracker|analytics|ads|bulkmailer|internal|misc',
|
|
442
|
+
# tracker - tracks users across sites
|
|
443
|
+
# analytics - external service to track users' behavior on site
|
|
444
|
+
# ads - ad provider's own metrics, tracks ad interaction behavior
|
|
445
|
+
# bulkmailer - tracks email link behavior
|
|
446
|
+
# internal - site's own tracking/analytics features, no cross-site usage
|
|
447
|
+
# misc - miscellaneous potentially unwanted features like AMP developed by Google
|
|
448
|
+
# 'company': 'Generic|<OrganizationName>|<OmitIfUnknown>',
|
|
449
|
+
# 'service': '<ServiceName>', #use if company has more than one service
|
|
450
|
+
# 'comment': 'this terminator element is intentionally left blank so you don't have to worry about commas'
|
|
451
|
+
#
|
|
452
|
+
# 'dom': r'domain', #only apply the filter on these domains
|
|
453
|
+
# 'arg': 'ncid', #string or regex, the key of the url parameter to remove
|
|
454
|
+
}
|
|
455
|
+
] #1}}}
|
|
456
|
+
|
|
457
|
+
# vim: ts=2 sw=2 et fdm=marker
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from re import search, sub, subn
|
|
2
|
+
|
|
3
|
+
from .arguments import arguments
|
|
4
|
+
|
|
5
|
+
def filter_url(url, pattern, verbose=False):
|
|
6
|
+
dom = pattern.get('dom', None)
|
|
7
|
+
arg = pattern.get('arg', None)
|
|
8
|
+
if arg is None:
|
|
9
|
+
return url
|
|
10
|
+
|
|
11
|
+
if dom is not None and not search(dom, url):
|
|
12
|
+
if verbose:
|
|
13
|
+
print(f'DOM /{dom}/ did not match')
|
|
14
|
+
return url
|
|
15
|
+
|
|
16
|
+
if verbose:
|
|
17
|
+
print(f'DOM /{dom}/ matched' if dom else 'DOM any')
|
|
18
|
+
|
|
19
|
+
def _remove(m):
|
|
20
|
+
# preserve the leading ? so the query string stays valid; drop & separators
|
|
21
|
+
return '?' if m.group(1) == '?' else ''
|
|
22
|
+
|
|
23
|
+
new_url, n = subn(r'([?&])(?:' + arg + r')(?:=[^&#]*)?(?=[&#]|$)', _remove, url)
|
|
24
|
+
|
|
25
|
+
if n:
|
|
26
|
+
if verbose:
|
|
27
|
+
print(f'ARG /{arg}/ matched, removing')
|
|
28
|
+
return new_url
|
|
29
|
+
if verbose:
|
|
30
|
+
print(f'ARG /{arg}/ did not match')
|
|
31
|
+
return url
|
|
32
|
+
|
|
33
|
+
def sanitize(url, verbose=False):
|
|
34
|
+
for a in arguments:
|
|
35
|
+
url = filter_url(url, a, verbose)
|
|
36
|
+
url = sub(r'\?&+', '?', url) # ?& artifact when first param was removed
|
|
37
|
+
url = sub(r'\?(?=#|$)', '', url) # trailing ? when all params were removed
|
|
38
|
+
return url
|
|
39
|
+
|
|
40
|
+
# vim: ts=2 sw=2 et fdm=marker
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: urluntrackify
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Strip tracking and analytics query parameters from URLs
|
|
5
|
+
Author: sph
|
|
6
|
+
License: [MIT](https://spdx.org/licenses/MIT.html)
|
|
7
|
+
|
|
8
|
+
Copyright 2024 sph
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
15
|
+
|
|
16
|
+
Project-URL: Source, https://tools.sphnet.in/git/sph/python-urluntrackify
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.md
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# DESCRIPTION
|
|
27
|
+
Python library for stripping tracking and analytics query parameters from URLs.
|
|
28
|
+
Covers trackers, ad click IDs, bulk mailer tokens, analytics tags (UTM etc.),
|
|
29
|
+
and miscellaneous unwanted parameters from a wide range of vendors.
|
|
30
|
+
|
|
31
|
+
# USAGE
|
|
32
|
+
```python
|
|
33
|
+
from urluntrackify import sanitize
|
|
34
|
+
|
|
35
|
+
clean_url = sanitize("https://example.com/page?utm_source=twitter&real=1")
|
|
36
|
+
# => "https://example.com/page?real=1"
|
|
37
|
+
|
|
38
|
+
clean_url = sanitize(url, verbose=True) # print matched/unmatched rules to stdout
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
# INSTALL
|
|
42
|
+
```
|
|
43
|
+
pip install -e /path/to/python-urluntrackify
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
# DEPENDENCIES
|
|
47
|
+
-
|
|
48
|
+
|
|
49
|
+
# DETAILS
|
|
50
|
+
Each rule in `arguments` (defined in `untrackify.py`) may contain:
|
|
51
|
+
|
|
52
|
+
| Field | Required | Description |
|
|
53
|
+
|-----------|----------|-------------|
|
|
54
|
+
| `arg` | yes | Regex matched against query parameter keys (full match) |
|
|
55
|
+
| `dom` | no | Regex searched against the full URL; rule only applies on match |
|
|
56
|
+
| `type` | no | Category: `tracker`, `analytics`, `ads`, `bulkmailer`, `internal`, `misc` |
|
|
57
|
+
| `company` | no | Vendor name |
|
|
58
|
+
| `service` | no | Specific service within vendor |
|
|
59
|
+
| `comment` | no | Freeform notes |
|
|
60
|
+
|
|
61
|
+
Currently covers: Adobe (Advertising, Marketo, SiteCatalyst), Branch, dotdigital,
|
|
62
|
+
drip.com, eBay, EMCI, Meta/Facebook, GoDataFeed, Google (Ads, Analytics/UTM,
|
|
63
|
+
DoubleClick), Hootsuite, HubSpot, Instagram, Impact, Klaviyo, Listrak, LinkedIn,
|
|
64
|
+
MailChimp, MailerLite, Marin, Matomo/Piwik, Microsoft, NextDoor, Omeda,
|
|
65
|
+
Dialog Insight, Openstat/Yandex, Oracle/Bronto, Pinterest, Rokt, Snapchat,
|
|
66
|
+
Seznam/Sklik, Spotify/YouTube share IDs, SpringBot, TikTok, X/Twitter,
|
|
67
|
+
Vero, WebTrends, Wicked Reports, Wikimedia, Wunderkind, Yahoo!/Yandex,
|
|
68
|
+
Awin/Zanox, and generic campaign identifiers.
|
|
69
|
+
|
|
70
|
+
# TECHNICAL INFORMATION
|
|
71
|
+
Query parameters appended to URLs by ad networks, email platforms, and analytics
|
|
72
|
+
services allow cross-site user tracking and campaign attribution without any
|
|
73
|
+
involvement from the target site. They are present purely for the benefit of
|
|
74
|
+
the sender/advertiser and add no information value to the recipient.
|
|
75
|
+
|
|
76
|
+
Query parameters appended to URLs by ad networks, email platforms, and analytics
|
|
77
|
+
services allow cross-site user tracking and campaign attribution without any
|
|
78
|
+
involvement from the target site. They are present purely for the benefit of
|
|
79
|
+
the sender/advertiser and add no information value to the recipient.
|
|
80
|
+
|
|
81
|
+
Each URL is processed by running the rule list against the raw URL string using
|
|
82
|
+
`re.subn`. Each rule matches `([?&])key(?:=value)?` at a query parameter
|
|
83
|
+
boundary; domain-restricted rules are pre-checked with `re.search` against the
|
|
84
|
+
full URL. Two cleanup passes handle separator artifacts left by removals at the
|
|
85
|
+
start or end of the query string.
|
|
86
|
+
|
|
87
|
+
# META
|
|
88
|
+
|
|
89
|
+
## LICENSE
|
|
90
|
+
[LICENSE.md](LICENSE.md)
|
|
91
|
+
|
|
92
|
+
## ATTRIBUTION
|
|
93
|
+
- https://en.wikipedia.org/wiki/Click_identifier
|
|
94
|
+
- https://webmasters.stackexchange.com/questions/109914/is-there-a-set-of-well-known-tracking-parameters-besides-utm
|
|
95
|
+
- https://github.com/spekulatius/url-parameter-tracker-list
|
|
96
|
+
- https://maxchadwick.xyz/tracking-query-params-registry/
|
|
97
|
+
- https://gitlab.torproject.org/tpo/applications/mullvad-browser/-/issues/166
|
|
98
|
+
- https://github.com/xojoc/cleanurl
|
|
99
|
+
- https://github.com/DandelionSprout/adfilt (LegitimateURLShortener)
|
|
100
|
+
- https://gitlab.com/ClearURLs/rules (data.json) — not yet integrated
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
urluntrackify/__init__.py,sha256=AEDwgYBVoerJAMqKeEgrtBn00Eymvw4raRjm7OBcm3s,33
|
|
2
|
+
urluntrackify/arguments.py,sha256=avizTyBOy4bUSwms6PUDWKR8OflSyK3HPWIZTcJ7zUY,12172
|
|
3
|
+
urluntrackify/untrackify.py,sha256=6dfOpkQngn902df3nDJagBkxnimTzmnn5XP4KnvV9pA,1167
|
|
4
|
+
urluntrackify-0.1.0.dist-info/licenses/LICENSE.md,sha256=GUk6aZ-93Hsv-GJsKVsGyt5nVulcQvb-hei-lw4WNFY,1086
|
|
5
|
+
urluntrackify-0.1.0.dist-info/METADATA,sha256=Yu29Bmy5knrxHy27WtaUf6gUFia7qnv2PxMAWP9OnDU,4969
|
|
6
|
+
urluntrackify-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
7
|
+
urluntrackify-0.1.0.dist-info/top_level.txt,sha256=6vd58Nfj-WBTPjM8HEkLDU_yjnFM1bySArqjw28MvTg,14
|
|
8
|
+
urluntrackify-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
[MIT](https://spdx.org/licenses/MIT.html)
|
|
2
|
+
|
|
3
|
+
Copyright 2024 sph
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
urluntrackify
|