-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter.js
79 lines (69 loc) · 2.43 KB
/
filter.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
/****************************************************************************
* remove-workspace-button.js
*
* Removes Teams button from workspace bar
* Works on mobile and desktop
* Persists across navigation and DOM updates
****************************************************************************/
(function() {
// Create and inject CSS
const buttonRemovalStyle = document.createElement('style');
buttonRemovalStyle.id = 'button-removal-style';
buttonRemovalStyle.innerHTML = `
/* Hide Teams button specifically */
button[data-element-id="workspace-tab-teams"] {
display: none !important;
visibility: hidden !important;
pointer-events: none !important;
width: 0 !important;
height: 0 !important;
margin: 0 !important;
padding: 0 !important;
opacity: 0 !important;
}
`;
// Add style to head if not already present
if (!document.getElementById('button-removal-style')) {
document.head.appendChild(buttonRemovalStyle);
}
// Function to remove the Teams button
function removeTeamsButton() {
const teamsButton = document.querySelector('button[data-element-id="workspace-tab-teams"]');
if (teamsButton) {
teamsButton.remove();
console.log('Teams button removed successfully');
}
}
// Initial removal
removeTeamsButton();
// Monitor for DOM changes
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (mutation.addedNodes.length) {
removeTeamsButton();
}
}
});
// Start observing
observer.observe(document.body, {
childList: true,
subtree: true
});
// Monitor for style removal
const styleObserver = new MutationObserver(() => {
if (!document.getElementById('button-removal-style')) {
document.head.appendChild(buttonRemovalStyle.cloneNode(true));
console.log('Button removal style re-added');
}
});
// Start observing document head
styleObserver.observe(document.head, {
childList: true,
subtree: true
});
// Handle page load
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', removeTeamsButton);
}
console.log('remove-workspace-button.js: Loaded successfully');
})();