-
Notifications
You must be signed in to change notification settings - Fork 0
/
No Fingerprint.user.js
399 lines (398 loc) · 16.9 KB
/
No Fingerprint.user.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
// ==UserScript==
// @name No Fingerprint
// @version 0.2
// @description Block browser fingerprinting attempts.
// @author Sam0230
// @match *://*/*
// @grant none
// @run-at document-start
// @noframes false
// @license The Unlicense
// @namespace https://github.com/Sam0230
// ==/UserScript==
let script = document.createElement("script");
script.textContent = "(" + (function() {
"use strict";
let debug = function (topOnly) {
if (!topOnly || window === window.top) {
// debugger;
}
};
(function () {
document.documentElement.dataset.fbscriptallow = true;
})();
let randomChange = function (n, m) {
if (!m) {
m = 0.1;
}
return Math.round(n + ((Math.random() - 0.5) * 2 * n * 0.3));
};
let setValue = function (object, propertyName, value, writable) {
if (!writable) {
writable = false;
}
Object.defineProperty(object, propertyName, {
value: value,
writable: writable,
enumerable: true
});
};
(function () { // Date
window.Date.prototype.getDate = window.Date.prototype.getUTCDate ;
window.Date.prototype.getDay = window.Date.prototype.getUTCDay ;
window.Date.prototype.getFullYear = window.Date.prototype.getUTCFullYear ;
window.Date.prototype.getHours = window.Date.prototype.getUTCHours ;
window.Date.prototype.getMilliseconds = window.Date.prototype.getUTCMilliseconds ;
window.Date.prototype.getMinutes = window.Date.prototype.getUTCMinutes ;
window.Date.prototype.getMonth = window.Date.prototype.getUTCMonth ;
window.Date.prototype.getSeconds = window.Date.prototype.getUTCSeconds ;
window.Date.prototype.getTimezoneOffset = function () { return 0; } ;
window.Date.prototype.getYear = function () { return this.getFullYear - 1900; } ;
window.Date.prototype.setDate = window.Date.prototype.setUTCDate ;
window.Date.prototype.setFullYear = window.Date.prototype.setUTCFullYear ;
window.Date.prototype.setHours = window.Date.prototype.setUTCHours ;
window.Date.prototype.setMilliseconds = window.Date.prototype.setUTCMilliseconds ;
window.Date.prototype.setMinutes = window.Date.prototype.setUTCMinutes ;
window.Date.prototype.setMonth = window.Date.prototype.setUTCMonth ;
window.Date.prototype.setSeconds = window.Date.prototype.setUTCSeconds ;
window.Date.prototype.setYear = function (n) { return this.setFullYear(n + 1900); } ;
window.Date.prototype.toLocaleDateString = function () { return ""; } ;
window.Date.prototype.toLocaleString = function () { return ""; } ;
window.Date.prototype.toLocaleTimeString = function () { return ""; } ;
window.Date.prototype.toString = function () { return ""; } ;
window.Date.prototype.toTimeString = function () { return ""; } ;
})();
(function () { // navigator
let a;
let fakeNavigator = {};
// fakeNavigator.appCodeName =
// fakeNavigator.appName =
// fakeNavigator.appVersion =
// fakeNavigator.platform =
fakeNavigator.product =
fakeNavigator.productSub =
// fakeNavigator.userAgent =
fakeNavigator.vendor =
fakeNavigator.vendorSub =
a = "";
fakeNavigator.deviceMemory =
fakeNavigator.hardwareConcurrency =
fakeNavigator.maxTouchPoints =
a = 0;
fakeNavigator.bluetooth =
fakeNavigator.clipboard =
fakeNavigator.connection =
// fakeNavigator.cookieEnabled =
fakeNavigator.credentials =
fakeNavigator.doNotTrack =
fakeNavigator.geolocation =
fakeNavigator.keyboard =
fakeNavigator.language =
fakeNavigator.languages =
fakeNavigator.locks =
fakeNavigator.mediaCapabilities =
fakeNavigator.mediaDevices =
fakeNavigator.mediaSession =
// fakeNavigator.mimeTypes =
fakeNavigator.onLine =
fakeNavigator.permissions =
fakeNavigator.presentation =
fakeNavigator.scheduling =
fakeNavigator.serviceWorker =
// fakeNavigator.storage =
fakeNavigator.usb =
fakeNavigator.userActivation =
fakeNavigator.userAgentData =
fakeNavigator.wakeLock =
fakeNavigator.webkitPersistentStorage =
fakeNavigator.webkitTemporaryStorage =
fakeNavigator.xr =
a = {};
fakeNavigator.hardwareConcurrency = 4;
fakeNavigator.deviceMemory = "undefined";
// fakeNavigator.platform = "Win32";
fakeNavigator.plugins = [];
setValue(fakeNavigator.plugins, "item", function item() { return null; }, false);
setValue(fakeNavigator.plugins, "namedItem", function namedItem() { return null; }, false);
setValue(fakeNavigator.plugins, "refresh", function refresh() { return null; }, false);
for (let i in window.navigator) {
if (fakeNavigator[i] !== undefined) {
try {
Object.defineProperty(window.navigator, i, {
get: function () {
if (fakeNavigator[i] === "undefined") {
return undefined;
}
return fakeNavigator[i];
}
});
} catch (e) {}
}
}
})();
(function () { // Screen size
let screenSize = [1920, 1080];
screen.availWidth && setValue(screen, "availWidth", screenSize[0]);
screen.availHeight && setValue(screen, "availHeight", screenSize[1] - 40);
screen.availLeft && setValue(screen, "availLeft", undefined, true);
screen.availTop && setValue(screen, "availTop", undefined, true);
screen.width && setValue(screen, "width", screenSize[0]);
screen.height && setValue(screen, "height", screenSize[1]);
screen.Brightness && setValue(screen, "Brightness", randomChange(screen.Brightness));
screen.mozBrightness && setValue(screen, "mozBrightness", randomChange(screen.mozBrightness));
screen.left && setValue(screen, "left", undefined, true);
screen.top && setValue(screen, "top", undefined, true);
screen.enabled && setValue(screen, "enabled", undefined);
screen.mozEnabled && setValue(screen, "mozEnabled", undefined);
screen.pixelDepth && setValue(screen, "pixelDepth", 32);
screen.colorDepth && setValue(screen, "colorDepth", 32);
})();
(function () { // Debugger panel size
let n = Math.round(71.5 + (Math.random() * 15)), wChanged = false, wValue, hChanged = false, hValue;
Object.defineProperty(window, "outerWidth", {
get: function () {
if (!wChanged) {
return window.innerWidth;
}
return wValue;
},
set: function (value) {
wChanged = true;
wValue = value;
}
});
Object.defineProperty(window, "outerHeight", {
get: function () {
if (!hChanged) {
return window.innerHeight + n;
}
return hValue;
},
set: function (value) {
hChanged = true;
hValue = value;
}
});
})();
(function () { // AudioContext
let origGetFloatFrequencyData = window.AnalyserNode.prototype.getFloatFrequencyData;
window.AnalyserNode.prototype.getFloatFrequencyData = function getFloatFrequencyData(array) {
let ret = origGetFloatFrequencyData.apply(this, arguments);
for (let i = 0; i < array.length; i++) {
array[i] = array[i] + Math.random() * 0.2;
}
return ret;
};
window.AnalyserNode.prototype.getFloatFrequencyData.toString = origGetFloatFrequencyData.toString.bind(origGetFloatFrequencyData);
let origGetChannelData = window.AudioBuffer.prototype.getChannelData;
window.AudioBuffer.prototype.getChannelData = function getChannelData() {
let ret = origGetChannelData.apply(this, arguments);
for (let i = 0; i < ret.length; i++) {
ret[i] = ret[i] + Math.random() * 0.0001;
}
return ret;
};
window.AudioBuffer.prototype.getChannelData.toString = origGetChannelData.toString.bind(origGetChannelData);
})();
(function () { // Canvas
let origGetContext = HTMLCanvasElement.prototype.getContext;
let origGetImageData = CanvasRenderingContext2D.prototype.getImageData;
let origReadPixels1 = WebGLRenderingContext.prototype.readPixels;
let origReadPixels2 = WebGL2RenderingContext.prototype.readPixels;
let origToDataURL = HTMLCanvasElement.prototype.toDataURL;
let origToBlob = HTMLCanvasElement.prototype.toBlob;
let getImageData = function getImageData() {
let imageData = origGetImageData.apply(this, arguments);
for (let i = 0; i < imageData.data.length; i++) {
imageData.data[i] += Math.round((Math.random() - 0.5) * 4.9);
}
return imageData;
};
CanvasRenderingContext2D.prototype.getImageData = getImageData;
CanvasRenderingContext2D.prototype.getImageData.toString = origGetImageData.toString.bind(origGetImageData);
let origIsPointInPath = CanvasRenderingContext2D.prototype.isPointInPath;
CanvasRenderingContext2D.prototype.isPointInPath = function isPointInPath() {
return false;
};
CanvasRenderingContext2D.prototype.isPointInPath.toString = origIsPointInPath.toString.bind(origIsPointInPath);
let readPixels1 = function readPixels() {
origReadPixels1.apply(this, arguments);
let pixels = arguments[6];
for (let i = 0; i < pixels.length; i++) {
pixels[i] += Math.round((Math.random() - 0.5) * 4.9);
}
};
WebGLRenderingContext.prototype.readPixels = readPixels1;
WebGLRenderingContext.prototype.readPixels.toString = origReadPixels1.toString.bind(origReadPixels1);
let readPixels2 = function readPixels() {
origReadPixels2.apply(this, arguments);
let pixels = arguments[6];
for (let i = 0; i < pixels.length; i++) {
pixels[i] += Math.round((Math.random() - 0.5) * 4.9);
}
};
WebGL2RenderingContext.prototype.readPixels = readPixels2;
WebGL2RenderingContext.prototype.readPixels.toString = origReadPixels2.toString.bind(origReadPixels2);
let toDataURL = function toDataURL() {
let context = origGetContext.apply(this, ["2d"]);
let imageData = origGetImageData.apply(context, [0, 0, this.height, this.width]), origImageData = origGetImageData.apply(context, [0, 0, this.height, this.width]), ret;
for (let i = 0; i < imageData.data.length; i++) {
imageData.data[i] += Math.round((Math.random() - 0.5) * 4.9);
}
context.putImageData(imageData, 0, 0);
ret = origToDataURL.apply(this, arguments);
context.putImageData(origImageData, 0, 0);
return ret;
};
let hookWebGLGetParameter = function (target) {
let random = {
"item": function (e) {
let rand = e.length * Math.random();
return e[Math.floor(rand)];
},
"number": function (power) {
let tmp = [];
for (let i = 0; i < power.length; i++) {
tmp.push(Math.pow(2, power[i]));
}
return random.item(tmp);
},
"int": function (power) {
let tmp = [];
for (let i = 0; i < power.length; i++) {
let n = Math.pow(2, power[i]);
tmp.push(new Int32Array([n, n]));
}
return random.item(tmp);
},
"float": function (power) {
let tmp = [];
for (let i = 0; i < power.length; i++) {
let n = Math.pow(2, power[i]);
tmp.push(new Float32Array([1, n]));
}
return random.item(tmp);
}
};
let origGetParameter = target.getParameter;
target.getParameter = function (a1) {
if (a1 === this.STENCIL_BITS ) { return 0; }
if (a1 === this.DEPTH_BITS ) { return 24; }
if (a1 === this.MAX_VARYING_VECTORS ) { return 30; }
if (a1 === this.VENDOR ) { return "WebKit"; }
if (a1 === 37445 ) { return "Google Inc."; }
if (a1 === this.RENDERER ) { return "WebKit WebGL"; }
if (a1 === this.MAX_TEXTURE_SIZE ) { return random.number([14, 15]); }
if (a1 === this.MAX_VERTEX_UNIFORM_VECTORS ) { return random.number([12, 13]); }
if (a1 === this.MAX_CUBE_MAP_TEXTURE_SIZE ) { return random.number([14, 15]); }
if (a1 === this.MAX_RENDERBUFFER_SIZE ) { return random.number([14, 15]); }
if (a1 === this.MAX_VIEWPORT_DIMS ) { return random.int([13, 14, 15]); }
if (a1 === this.ALPHA_BITS ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.BLUE_BITS ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.GREEN_BITS ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.RED_BITS ) { return random.number([1, 2, 3, 4]); }
if (a1 === 34047 ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.MAX_TEXTURE_IMAGE_UNITS ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.MAX_VERTEX_ATTRIBS ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.MAX_VERTEX_TEXTURE_IMAGE_UNITS ) { return random.number([1, 2, 3, 4]); }
if (a1 === this.MAX_COMBINED_TEXTURE_IMAGE_UNITS ) { return random.number([4, 5, 6, 7, 8]); }
if (a1 === this.MAX_FRAGMENT_UNIFORM_VECTORS ) { return random.number([10, 11, 12, 13]); }
if (a1 === this.ALIASED_LINE_WIDTH_RANGE ) { return random.float([0, 10, 11, 12, 13]); }
if (a1 === this.ALIASED_POINT_SIZE_RANGE ) { return random.float([0, 10, 11, 12, 13]); }
if (a1 === 37446 ) { return random.item(["Graphics", "HD Graphics", "Intel(R) HD Graphics"]); }
if (a1 === this.VERSION ) { return random.item(["WebGL 1.0", "WebGL 1.0 (OpenGL)", "WebGL 1.0 (OpenGL Chromium)"]); }
if (a1 === this.SHADING_LANGUAGE_VERSION ) { return random.item(["WebGL", "WebGL GLSL", "WebGL GLSL ES", "WebGL GLSL ES (OpenGL Chromium"]); }
return origGetParameter.apply(this, arguments);
};
target.getParameter.toString = origGetParameter.toString.bind(origGetParameter);
};
hookWebGLGetParameter(WebGLRenderingContext.prototype);
hookWebGLGetParameter(WebGL2RenderingContext.prototype);
HTMLCanvasElement.prototype.toDataURL = toDataURL;
HTMLCanvasElement.prototype.toDataURL.toString = origToDataURL.toString.bind(origToDataURL);
let toBlob = function toBlob(callback, type, encoderOptions) {
let context = origGetContext.apply(this, ["2d"]);
let imageData = origGetImageData.apply(context, [0, 0, this.height, this.width]), imageDataOrig = origGetImageData.apply(context, [0, 0, this.height, this.width]);
for (let i = 0; i < imageData.data.length; i++) {
imageData.data[i] += Math.round((Math.random() - 0.5) * 4.9);
}
context.putImageData(imageData, 0, 0);
return origToBlob.apply(this, [function (blob) {
context.putImageData(imageDataOrig, 0, 0);
callback(blob);
}, type, encoderOptions]);
};
HTMLCanvasElement.prototype.toBlob = toBlob;
HTMLCanvasElement.prototype.toBlob.toString = origToBlob.toString.bind(origToBlob);
})();
(function () { // Intl
window.Intl = undefined;
})();
(function () { // Fonts
let offsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "offsetWidth");
let origOffsetWidthGetter = offsetWidth.get;
offsetWidth.get = function offsetWidth() {
let ret = origOffsetWidthGetter.apply(this, arguments);
if (ret != 0) {
if (Math.random() >= 0.9) {
ret += Math.floor((Math.random() >= 0.5 ? -1 : 1) * Math.random() + Math.random());
}
}
return ret;
};
offsetWidth.get.toString = origOffsetWidthGetter.toString.bind(origOffsetWidthGetter);
Object.defineProperty(HTMLElement.prototype, "offsetWidth", offsetWidth);
let offsetHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, "offsetHeight");
let origOffsetHeightGetter = offsetHeight.get;
offsetHeight.get = function offsetHeight() {
let ret = origOffsetWidthGetter.apply(this, arguments);
if (ret != 0) {
if (Math.random() >= 0.9) {
ret += Math.floor((Math.random() >= 0.5 ? -1 : 1) * Math.random() + Math.random());
}
}
return ret;
};
offsetHeight.get.toString = origOffsetHeightGetter.toString.bind(origOffsetHeightGetter);
Object.defineProperty(HTMLElement.prototype, "offsetHeight", offsetHeight);
})();
let debuggerHook = function (n, m) {
try {
let orig = window[n].prototype[m];
let hook = function () {
debug();
try {
return orig.apply(this, arguments);
} catch (e) {}
};
Object.defineProperty(hook, "name", { value: orig.name, writable: false, enumerable: false, configurable: true });
window[n].prototype[m] = hook;
window[n].prototype[m].toString = orig.toString.bind(orig);
} catch (e) {}
};
let debuggerHookAll = function (n) {
try {
for (let i in window[n].prototype) {
try {
if (window[n].prototype[i] instanceof Function) {
debuggerHook(n, i);
}
} catch (e) {}
}
} catch (e) {}
};
debug(1);
try {
debuggerHookAll("AudioContext");
debuggerHookAll("BaseAudioContext");
debuggerHookAll("OfflineAudioCompletionEvent");
debuggerHookAll("OfflineAudioContext");
debuggerHookAll("AudioBuffer");
debuggerHookAll("AnalyserNode");
debuggerHookAll("HTMLCanvasElement");
debuggerHookAll("CanvasRenderingContext2D");
debuggerHookAll("WebGLRenderingContext");
debuggerHookAll("WebGL2RenderingContext");
} catch (e) {}
}) + ")()";
document.documentElement.prepend(script);