Skip to content

Commit f30cb4a

Browse files
mikeniklestechniq
andauthored
Fix a Brave fingerprinting bug (#755)
* Fix a Brave fingerprinting bug * Improve changeset --------- Co-authored-by: Sean Lynch <[email protected]>
1 parent 2cd8040 commit f30cb4a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.changeset/upset-rings-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'layerchart': patch
3+
---
4+
5+
fix(Canvas): Fix pointer events (hit canvas) when using Brave browser with fingerprinting protection enabled
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/** Generator to create a new color on each call */
2-
export function* rgbColorGenerator(step = 500) {
2+
export function* rgbColorGenerator(step = 200) {
33
let nextColor = 0;
44

5-
while (nextColor < 16777216) {
6-
const r = nextColor & 0xff;
7-
const g = (nextColor & 0xff00) >> 8;
8-
const b = (nextColor & 0xff0000) >> 16;
5+
while (nextColor < 1 << 21) {
6+
const r = nextColor & 0x7f;
7+
const g = (nextColor >> 7) & 0x7f;
8+
const b = (nextColor >> 14) & 0x7f;
99

1010
nextColor += step;
11-
yield { r, g, b, a: 255 };
11+
yield { r: r * 2, g: g * 2, b: b * 2, a: 255 };
1212
}
1313

1414
return { r: 0, g: 0, b: 0, a: 255 };
@@ -17,9 +17,12 @@ export function* rgbColorGenerator(step = 500) {
1717
type RGBColor = { r: number; g: number; b: number; a?: number };
1818

1919
export function getColorStr(color: RGBColor) {
20+
const r = color.r & 0xfe;
21+
const g = color.g & 0xfe;
22+
const b = color.b & 0xfe;
2023
if (color.a !== undefined) {
21-
return `rgba(${color.r},${color.g},${color.b},${color.a})`;
24+
return `rgba(${r},${g},${b},${color.a})`;
2225
} else {
23-
return `rgb(${color.r},${color.g},${color.b})`;
26+
return `rgb(${r},${g},${b})`;
2427
}
2528
}

0 commit comments

Comments
 (0)