Skip to content

Instantly share code, notes, and snippets.

@shabin-slr
Last active March 3, 2021 15:38
Show Gist options
  • Save shabin-slr/2a727c5b60b7c712f09942a610ef59af to your computer and use it in GitHub Desktop.
Save shabin-slr/2a727c5b60b7c712f09942a610ef59af to your computer and use it in GitHub Desktop.
var findNodes = async function(styleClass="k4xni2cv"){
var elem = document.getElementsByClassName("k4xni2cv");
if(elem.length === 1){
elem = elem[0];
elem.scrollTop = elem.scrollHeight;
await new Promise(resolve => setTimeout(resolve, 5000));
_2020DesignParser();
}
}
var _2020DesignParser = async function(){
var items = document.querySelectorAll('[aria-label="Action options"]');
for(i = 0; i< items.length; ++i){
items[i].scrollIntoView();
items[i].click();
await new Promise(resolve => setTimeout(resolve, 1000));
// Need to escape rakhshed polls
var btn = findByText("span", ["Move to Recycle bin","Unlike","Delete", "Remove reaction"]);
if(btn){
btn.click();
await new Promise(resolve => setTimeout(resolve, 1000));
var cfn = findByText("span", "Move to Recycle bin");
if(cfn){
cfn.click();
await new Promise(resolve => setTimeout(resolve, 1000));
}
} else {
btn = findByText("span", "Delete");
if(btn){
btn.click();
await new Promise(resolve => setTimeout(resolve, 1000));
var cfn = findByText("span", "Delete");
if(cfn){
cfn.click();
await new Promise(resolve => setTimeout(resolve, 1000));
}
}
}
}
findNodes();
}
var findByText = function(tag, searchText){
var elems = document.getElementsByTagName(tag);
var found = null;
for (var i = 0; i < elems.length; i++) {
if (searchText.includes(elems[i].textContent)) {
found = elems[i];
break;
}
}
return found;
}
var purgeComments = function(){
var a = document.getElementsByClassName("_-xe")[0];
if(!a) return;
if(a.parentElement.parentElement.parentElement.parentElement.parentElement.innerText.includes("mentioned")){
x = a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.removeChild(x);
window.scrollTo(0,document.body.scrollHeight);
purgeComments();
return ;
}
a.click();
els = document.querySelectorAll('[data-ownerid="'+a.parentElement.id+'"]');
els[0].getElementsByClassName("_54nc")[0].click();
x = a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.removeChild(x);
setTimeout(()=>{
window.scrollTo(0,document.body.scrollHeight);
purgeComments();
},1500);
};
var purgeReactions = function(){
var a = document.getElementsByClassName("_-xe")[0];
if(!a){
console.log("No more reactions found");
return;
}
a.click();
console.log(a.parentElement.id)
let els = document.querySelectorAll('[data-ownerid="'+a.parentElement.id+'"]');
if(!els.length){
console.log("No element with ownerid found");
}
for(i = 0; i< els.length; ++i){
if(els[i].getElementsByClassName("_54nh").length){
els[i].getElementsByClassName("_54nh")[0].click();
x = a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.removeChild(x);
setTimeout(()=>{
window.scrollTo(0,document.body.scrollHeight);
purgeReactions();
},1000);
} else {
console.log("No clickable list found");
}
};
setTimeout(()=>{
x = a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
a.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.removeChild(x);
window.scrollTo(0,document.body.scrollHeight);
purgeReactions();
},1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment