forked from newhouse/url-tracking-stripper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.js
202 lines (168 loc) · 6 KB
/
examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/* eslint-disable no-unused-vars */
const {
TRACKERS_BY_ROOT
} = require('./assets/js/trackers');
const {
REDIRECT_EXAMPLES_BY_TARGET_PARAM
} = require('./test/helpers');
const hostEtc = 'https://foo.com/path/to/whatever';
// SPECIFIC TRACKER EXAMPLES WE WANT TO ADD IN
const trackerExamples = [
{
fromm: 'https://mobile.twitter.com/rob_dodson/status/1054769558253256704?fbclid=IwAR1oP2nniRZt0LKF3DcjHWMBz1XYdRk7Q5S7RRldbCVc0zSPuHVWRlvmq2Q',
too: 'https://mobile.twitter.com/rob_dodson/status/1054769558253256704'
},
{
fromm: 'https://www.instagram.com/p/B7ToSDrg44K/?igshid=36gmy2rkwpsg',
too: 'https://www.instagram.com/p/B7ToSDrg44K/'
},
{
fromm: 'https://stripe.com/blog/ending-bitcoin-support?utm_source=newsletter&utm_medium=email&utm_campaign=&stream=top-stories',
too: 'https://stripe.com/blog/ending-bitcoin-support?stream=top-stories'
},
{
fromm: 'https://activity.alibaba.com/sale/march-expo/beauty-personal-care.html?spm=a2700.8293689.procates.6.46ce65aaHNdagx&tracelog=20180305_ICBU_HOME_CATEGORY_PROMOTION_26103',
too: 'https://activity.alibaba.com/sale/march-expo/beauty-personal-care.html?tracelog=20180305_ICBU_HOME_CATEGORY_PROMOTION_26103'
}
];
// STORE REDIRECT EXAMPLES
const redirectExamples = [
{
fromm: 'https://go.redirectingat.com/?id=66960X1514734&xs=1&url=https%3A%2F%2Fwww.target.com%2Fp%2Fgoogle-vision-kit-aiy%2F-%2FA-53417081',
too: 'https://www.target.com/p/google-vision-kit-aiy/-/A-53417081'
},{
fromm: 'https://out.reddit.com/t3_7jwyol?url=https%3A%2F%2Fexample.com%2Fexamplepath&token=some-UUID-like-token&app_name=reddit.com',
too: 'https://example.com/examplepath'
},
{
fromm: 'https://out.reddit.com/t3_8an64b?url=https%3A%2F%2Fexample.com%2Fanotherexamplepath&token=some-different-UUID-like-token&app_name=reddit.com',
too: 'https://example.com/anotherexamplepath',
},
{
fromm: 'http://clkde.tradedoubler.com/click?=&p=259740&a=2821835&g=0&url=https%3a%2f%2fwww.microsoft.com%2fen-us%2fstore%2fp%2fthe-witness%2fbx1wpt5rjsb2',
too: 'https://www.microsoft.com/en-us/store/p/the-witness/bx1wpt5rjsb2'
},
{
fromm: 'https://www.ojrq.net/p/?return=http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dhi&cid=2092&tpsync=yes',
too: 'http://www.google.com/search?q=hi'
},
{
fromm: 'https://www.anrdoezrs.net/click-7516178-12533333-1501183926000?SID=2051691FOF71282629031314812&url=http%3a%2f%2fwww.google.com%2fsearch%3fq%3dhi',
too: 'http://www.google.com/search?q=hi'
},
{
fromm: 'http://rd.connexity.net/rd?t=http%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dhi',
too: 'http://www.google.com/search?q=hi'
},
{
fromm: 'https://t.cfjump.com/6421/t/42872?Url=http%3a%2f%2fwww.google.com%2fsearch%3fq%3dhi',
too: 'http://www.google.com/search?q=hi'
},
{
fromm: 'https://slack-redir.net/link?url=https%3A%2F%2Fwww.google.com%2fsearch%3fq%3dhi',
too: 'https://www.google.com/search?q=hi'
}
];
// STORE REDIRECT WITH TRACKERS EXAMPLES
const redirectWithTrackerExamples = [
];
// ALL THE ACTUAL TRACKER PARAMS WE'VE PROCESSED SO FAR
const allTrackersSoFar = [];
// ADD IN ALL THE COMBINATIONS OF TRACKERS:
for (let root in TRACKERS_BY_ROOT) {
TRACKERS_BY_ROOT[root].forEach(suffix => {
// CREATE THIS TRACKER
const thisTracker = `${root}${suffix}=foo`;
// ADD IT TO ALL THE ONES WE'VE DONE SO FAR
allTrackersSoFar.push(thisTracker);
// COMBINE ALL THE ONES WE'VE DONE SO FAR
const allTrackersSoFarCombined = allTrackersSoFar.join('&');
// ADD THIS TRACKER ALONE
trackerExamples.push(
{
fromm: `${hostEtc}?${thisTracker}`,
too: `${hostEtc}`
}
);
// ADD THIS TRACKER AT THE BEGINNING
trackerExamples.push(
{
fromm: `${hostEtc}?${thisTracker}&foo=bar`,
too: `${hostEtc}?foo=bar`
}
);
// ADD THIS TRACKER AT THE END
trackerExamples.push(
{
fromm: `${hostEtc}?foo=bar&${thisTracker}`,
too: `${hostEtc}?foo=bar`
}
);
// CREATE A SUPER MEGA TRACKER URL CONTAINING ALL THE TRACKERS THUS FAR
trackerExamples.push(
{
fromm: `${hostEtc}?${allTrackersSoFarCombined}`,
too: `${hostEtc}`
}
);
// CREATE A SUPER MEGA TRACKER URL CONTAINING ALL THE TRACKERS THUS FAR
// WITH AN EXTRA ONE AT THE END
trackerExamples.push(
{
fromm: `${hostEtc}?${allTrackersSoFarCombined}&foo=bar`,
too: `${hostEtc}?foo=bar`
}
);
// CREATE A SUPER MEGA TRACKER URL CONTAINING ALL THE TRACKERS THUS FAR
// WITH AN EXTRA ONE AT THE BEGINNING
trackerExamples.push(
{
fromm: `${hostEtc}?foo=bar&${allTrackersSoFarCombined}`,
too: `${hostEtc}?foo=bar`
}
);
});
}
// ADD IN ALL THE COMBINATIONS OF REDIRECTS:
for (let targetParam in REDIRECT_EXAMPLES_BY_TARGET_PARAM) {
REDIRECT_EXAMPLES_BY_TARGET_PARAM[targetParam].forEach(root => {
// CAN'T HANDLE NON-URI-ENCODED RIGHT NOW
// ADD A BASIC REDIRECT EXAMPLE THAT IS NOT PROPERLY ENCODED
// redirectExamples.push(
// {
// fromm: `${root}${targetParam}=${hostEtc}`,
// too: hostEtc
// }
// );
// ADD A BASIC REDIRECT EXAMPLE THAT IS PROPERLY ENCODED
redirectExamples.push(
{
fromm: `${root}${targetParam}=${encodeURIComponent(hostEtc)}`,
too: hostEtc
}
);
// GO THROUGH EACH TRACKER EXAMPLE
trackerExamples.forEach(({fromm, too}) => {
// CAN'T HANDLE NON-URI-ENCODED RIGHT NOW
// ADD A REDIRECT THAT HAS TRACKERS EXAMPLE THAT IS NOT PROPERLY ENCODED
// redirectWithTrackerExamples.push(
// {
// fromm: `${root}${targetParam}=${fromm}`,
// too: too
// }
// );
// ADD A REDIRECT THAT HAS TRACKERS EXAMPLE THAT IS PROPERLY ENCODED
redirectWithTrackerExamples.push(
{
fromm: `${root}${targetParam}=${encodeURIComponent(fromm)}`,
too: too
}
);
});
});
}
module.exports = {
trackerExamples,
redirectExamples,
redirectWithTrackerExamples
};