Skip to content

Instantly share code, notes, and snippets.

@asandroq
Created February 8, 2021 15:17
Show Gist options
  • Save asandroq/953d7733199bb58fbc9c541e16dd9d44 to your computer and use it in GitHub Desktop.
Save asandroq/953d7733199bb58fbc9c541e16dd9d44 to your computer and use it in GitHub Desktop.
(function(){
const delayMs = 500;
const keywords = `Prova do líder
BBB21
Tiago Leifert
paredão
BBB
BBB 21
Big brother
ludmilla
Anjo
Lumena
Programa
Koka
Gil
Big fone
Projota
Nego di
Karol
Brother
Reality
Conka
Lucas
Rodolfo
Fiuk
Juliette
Eliminado
#BBB21
Pocah
Negro Di
Viih
Fiuk
Kerline
Ker
Carla
Lucas
Camilla
Arcrebiano
Juliette
João Luiz
Caio
Arthur
Rodolffo
Lumena
Gilberto
Projota
Thaís
Sarah
Karol
Big Brother
Paredão
BBB
Jaque Patombá
Anjo
Lumenas
Koka
Bolinho`.split(/\n/);
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
const addMutedKeyword = keyword => {
const input = document.querySelector("[name='keyword']");
nativeInputValueSetter.call(input, keyword);
input.dispatchEvent(new Event('input', { bubbles: true }));
document.querySelector("[data-testid='settingsDetailSave']").click();
}
const delay = () => {
return new Promise(res => setTimeout(res, delayMs));
};
keywords.reduce(async (prev, keyword) => {
await prev;
// wait till the browser returns to the initial screen before clicking the add button again.
while(window.location.href !== 'https://twitter.com/settings/muted_keywords'){
await delay();
}
document.querySelector("a[href='/settings/add_muted_keyword']").click();
await delay();
addMutedKeyword(keyword);
return delay();
}, Promise.resolve());
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment