-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgmailMaskEverything.js
More file actions
68 lines (61 loc) · 2.96 KB
/
gmailMaskEverything.js
File metadata and controls
68 lines (61 loc) · 2.96 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
Element.prototype.updateAttributeIfExists = function updateAttributeIfExists(name, value){
//TODO: allow passing a function that accepts a string (the current attribute value) as the value parameter
if (this.hasAttribute(name)){
this.setAttribute(name, value);
}
}
Element.prototype.maskAttributeIfExists = function maskAttributeIfExists(name, maskChar = '*'){
//silently allows maskChar to be longer than just 1 character, which may not be desirable
if (this.hasAttribute(name)){
this.setAttribute(name, maskChar.repeat(this.getAttribute(name).length));
}
}
function maskTextNodes(node, maskChar){
function __applyTextNodeMask(childNode){
if (childNode.nodeType === Node.TEXT_NODE){
childNode.textContent = childNode.textContent.replaceAll(/\w/, maskChar);
}
}
node.childNodes.forEach(__applyTextNodeMask);
}
function maskAllTextNodes(node, maskChar){
node.childNodes.forEach(function(childNode){
if (childNode.hasChildNodes()){
maskAllTextNodes(childNode, maskChar);
}
maskTextNodes(childNode,maskChar);
});
}
document.querySelectorAll('.bqe').forEach(e=>e.textContent = '*'.repeat(e.textContent.length));
document.querySelectorAll('.Zt').forEach(e=>e.nextSibling.textContent = e.nextSibling.textContent.replaceAll(/\w/,'X'));
document.querySelectorAll('.bA4 > .yP, .bA4 > .zF').forEach(function(e){
e.textContent = e.textContent.replaceAll(/\w/,'X');
if (e.hasAttribute('email')){
e.setAttribute('email', '*'.repeat(e.getAttribute('email').length));
};
if (e.hasAttribute('name')){
e.setAttribute('name', '*'.repeat(e.getAttribute('name').length));
};
if (e.hasAttribute('data-hovercard-id')){
e.setAttribute('data-hovercard-id', '*'.repeat(e.getAttribute('data-hovercard-id').length));
};
});
document.querySelectorAll('.yX.xY,.xY.a4W').forEach(ele => maskAllTextNodes(ele, 'X'));
document.querySelectorAll('.xY.a4W').forEach(function(e){
e.querySelectorAll('.at[title]').forEach(function(ee){
ee.setAttribute('title', ee.getAttribute('title').replaceAll(/\w/, 'X'));
ee.querySelectorAll('.av').forEach(eee => eee.textContent = eee.textContent.replaceAll(/\w/,'X'));
});
});
document.title = document.title.replaceAll(/\w/,'X');
whoamiLink = dq('[aria-label^="Google Account: "]');
whoamiLink.setAttribute('aria-label', 'Google Account: ' + whoamiLink.getAttribute('aria-label').slice(16).replaceAll(/\w/, 'X'));
document.querySelectorAll('.gb_de > :not(:first-child), .znj3je, .Wdz6e').forEach(e => e.textContent = e.textContent.replaceAll(/\w/,'X'));
document.querySelectorAll('.aim').forEach(function(e){
e.querySelectorAll('[data-tooltip]').forEach(ee => ee.setAttribute('data-tooltip', 'Placeholder Text'));
let lnk = e.querySelector('a');
lnk.href = lnk.href.replace(/#label\/.+/, '#label/PLACEHOLDER');
lnk.setAttribute('aria-label', lnk.getAttribute('aria-label').replace(lnk.textContent, 'PLACEHOLDER'));
lnk.textContent = 'PLACEHOLDER';
e.querySelectorAll('[data-label-name]').forEach(ee => ee.setAttribute('data-label-name', 'Placeholder Text'));
});