Last active
August 20, 2023 15:01
-
-
Save iqiancheng/03884da9d319bbc752212e06cf5fb4b2 to your computer and use it in GitHub Desktop.
黄推屏蔽油猴脚本 Userscript Mute twitter user with one click 按住 alt 键点击推文一键 mute 用户, 共享黑名单:https://greasyfork.org/zh-CN/scripts/470359-twitter-block-porn
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