-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (34 loc) · 1.26 KB
/
script.js
File metadata and controls
38 lines (34 loc) · 1.26 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
function go() {
//remove all reposts already loaded into the page
var app = document.getElementById("app");
$(".stream__list .lazyLoadingList .lazyLoadingList__list").children().each(function(i,post){
if(jQuery(post).find("soundContext__repost") != null){
jQuery(post).remove();
}
})
//add a listener that removes reposts as they are added.
var containerMutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if(mutation.type == "childList" && mutation.addedNodes.length > 0 && mutation.addedNodes[0].className == "soundList__item" && mutation.addedNodes[0].innerHTML.includes("reposted by")){
chrome.storage.sync.get('percentage', function(data) {
if(Math.random() > 1 - (data.percentage / 100)){
mutation.addedNodes[0].remove();
}
});
}
});
});
//run the listener
containerMutationObserver.observe(app, {
childList: true,
subtree: true,
});
}
window.onload=function(){
if (typeof jQuery == 'undefined') {
console.log("error loading jquery")
} else {
console.log(jQuery);
go();
}
}