-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcontent.js
73 lines (59 loc) · 2.13 KB
/
content.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
function findAndHide(element) {
let items = new Array;
let qs = [
// By URLs
"a[href*='youracclaim.com/badges/']",
"a[href*='credly.com/badges/']",
"a[href*='www.credential.net/']",
"a[href*='coursera.org/share/']",
"a[href*='certificates.cloudbees.com']",
"a[href*='educba.com/certificate/']",
"a[href*='bcert.me/']",
"a[href*='university.mongodb.com/course_completion/']",
"a[href*='verify.acloud.guru']",
// Everything with tags
"a[href*='linkedin.com/feed/hashtag/?keywords=awscertified']",
"a[href*='linkedin.com/feed/hashtag/?keywords=azurecertified']",
"a[href*='linkedin.com/feed/hashtag/?keywords=microsoftcertified']",
// Certificates
"img[alt='AWS Certified Developer-Associate']"
];
qs.forEach(function (qs) {
items.push(...element.querySelectorAll(qs));
});
// if (items.length > 0) {
// console.log("Searching in:", element);
// console.log("Found these items:", items);
// }
items.forEach(function (item) {
let current = item;
while (current && current.parentNode) {
if (current.hasAttribute("data-id")) {
if (!current.classList.contains("visually-hidden")) {
console.log("Hiding element: ", current);
current.classList.add("visually-hidden")
// current.style.border = "10px solid red"
}
}
current = current.parentNode;
}
});
}
// Hide during initial phase (sometimes it should help)
findAndHide(document);
// Select the node that will be observed for mutations
const targetNode = document.getElementById('voyager-feed');
// Options for the observer (which mutations to observe)
const config = { childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
for(const mutation of mutationsList) {
if (mutation.type === 'childList') {
findAndHide(mutation.target)
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);