-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_google_detection.html
More file actions
80 lines (73 loc) · 2.68 KB
/
test_google_detection.html
File metadata and controls
80 lines (73 loc) · 2.68 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Test Google RNG Detection</title>
</head>
<body>
<h1>Test Google RNG Detection</h1>
<!-- Simulate Google's RNG structure -->
<div class="g">
<div class="kp-blk">
<block-component data-attrid="random_number_generator">
<div>
<div>Random number generator</div>
<div style="font-size: 48px;">42</div>
<div>
<input type="number" aria-label="Minimum value" value="1">
<input type="number" aria-label="Maximum value" value="100">
</div>
<div role="button" aria-label="Generate random number">Generate</div>
</div>
</block-component>
</div>
</div>
<script type="module">
// Test our detection logic
const checkForGenerator = (element) => {
const selectors = [
'[class*="randomnumber"]',
'[data-attrid*="random"]',
'[aria-label*="random number"]',
'[aria-label*="Random number"]',
'div[role="button"][aria-label*="Generate"]'
];
for (const selector of selectors) {
if (element.querySelector(selector)) {
console.log('RNG detected with selector:', selector);
return true;
}
}
return false;
}
const getGeneratorContainer = () => {
const attributeSelectors = [
'[class*="randomnumber"]',
'[data-attrid*="random"]',
'[aria-label*="random number"]',
'[aria-label*="Random number"]'
];
for (const selector of attributeSelectors) {
const element = document.querySelector(selector);
if (element) {
let container = element;
while (container && container.tagName !== 'BLOCK-COMPONENT' && container.parentElement) {
if (container.classList.contains('g') ||
container.classList.contains('kp-blk') ||
container.getAttribute('data-attrid')) {
break;
}
container = container.parentElement;
}
console.log('Found container via attribute selector:', selector, container);
return container;
}
}
return null;
}
// Test
console.log('Testing RNG detection...');
console.log('RNG detected:', checkForGenerator(document));
console.log('Container found:', getGeneratorContainer());
</script>
</body>
</html>