Last active
July 4, 2023 02:55
-
-
Save weijarz/439a48717c10dd790cdb793c4f47ff4d to your computer and use it in GitHub Desktop.
Mute twitter user with one click 按住 alt 键点击推文一键 mute 用户
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name One click to mute the twitter user - twitter.com | |
// @namespace Violentmonkey Scripts | |
// @match https://twitter.com/* | |
// @grant none | |
// @version 1.0 | |
// @author weijarz | |
// @description 6/28/2023, 12:46:22 PM | |
// ==/UserScript== | |
document.addEventListener('click', (ev) => { | |
if (!(ev.altKey || ev.button === 1)) return; | |
const article = ev.target.closest('article'); | |
if (!article) return; | |
const btnArr = article.querySelectorAll('div[aria-haspopup="menu"][role="button"][data-testid="caret"]'); | |
if (btnArr.length !== 1) return; | |
ev.stopPropagation(); | |
ev.preventDefault(); | |
setTimeout(() => { | |
btnArr[0].click(); | |
setTimeout(() => { | |
const menuArr = document.querySelectorAll('div[data-testid="Dropdown"]'); | |
if (menuArr.length !== 1) return | |
for (const mi of menuArr[0].querySelectorAll('div[role="menuitem"]')) { | |
console.log('MenuItem', mi.innerText); | |
if (/^(隐藏|Mute)\s@/u.test(mi.innerText)) { | |
console.log('Fuck', mi.innerText); | |
mi.click(); | |
break; | |
} | |
} | |
}, 200); | |
}, 10); | |
}, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment