This repository was archived by the owner on Dec 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgoogle.js
More file actions
34 lines (31 loc) · 1.28 KB
/
Copy pathgoogle.js
File metadata and controls
34 lines (31 loc) · 1.28 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
// Function to block Google Games elements
function blockGoogleGames() {
var styleElement, targetElement;
// Block Google Games on search page
if (
document.location.pathname.includes('search') &&
document.querySelectorAll('block-component div[data-parent-funbox]').length !== 0
) {
styleElement = document.createElement('style');
styleElement.innerHTML = 'block-component { display: none; }';
document.head.appendChild(styleElement);
targetElement = document.querySelector('block-component');
targetElement.parentElement.removeChild(targetElement);
}
// Block Google Games on fbx page
if (document.location.pathname.includes('fbx')) {
styleElement = document.createElement('style');
styleElement.innerHTML = 'body > div { display: none; }';
document.head.appendChild(styleElement);
targetElement = document.querySelector('body > div');
targetElement.parentElement.removeChild(targetElement);
}
}
// Check if document is already loaded, then block Google Games, otherwise wait for DOMContentLoaded event
if (document.readyState !== 'loading') {
blockGoogleGames();
} else {
document.addEventListener('DOMContentLoaded', function () {
blockGoogleGames();
});
}