Skip to content

Instantly share code, notes, and snippets.

@NHZEX
Last active April 7, 2024 13:26
Show Gist options
  • Save NHZEX/c17b204cfcc7d881cc0c1ff9788a917b to your computer and use it in GitHub Desktop.
Save NHZEX/c17b204cfcc7d881cc0c1ff9788a917b to your computer and use it in GitHub Desktop.
自用浏览器脚本
// ==UserScript==
// @name 自动解除敏感内容隐藏
// @namespace x
// @version 0.0.3
// @description 自动解除推敏感内容隐藏
// @author You
// @match https://twitter.com/*/media
// @match https://x.com/*/media
// @match https://twitter.com/home
// @match https://x.com/home
// @icon https://twitter.com/favicon.ico
// @downloadURL https://gist.githubusercontent.com/NHZEX/c17b204cfcc7d881cc0c1ff9788a917b/raw/X_AutoShowHiddenContent.js
// @updateURL https://gist.githubusercontent.com/NHZEX/c17b204cfcc7d881cc0c1ff9788a917b/raw/X_AutoShowHiddenContent.js
// @run-at document-idle
// @grant none
// ==/UserScript==
(function() {
'use strict';
let loopFun;
let tid = null;
function showHiddenContent() {
let result
result = Array.from(document.querySelectorAll('span')).filter(v => v.textContent === '警告:敏感内容').filter(v => v.parentNode.nextElementSibling.innerText === '显示');
if (result.length > 0) {
console.log("show media hidden content count: " + result.length)
result.map(v => v.parentNode.nextElementSibling.click())
}
result = Array.from(document.querySelectorAll('span')).filter(v => v.textContent === '帖子作者已将这个帖子标记为显示敏感内容。').filter(v => v.parentNode?.parentNode?.parentNode?.childNodes[1]?.innerText === '显示');
if (result.length > 0) {
console.log("show home hidden content count: " + result.length)
result.map(v => v.parentNode.parentNode.parentNode.childNodes[1].click())
}
loopFun()
}
loopFun = function () {
if (tid) {
window.clearTimeout(tid)
tid = null
}
window.requestAnimationFrame(() => {
tid = window.setTimeout(() => showHiddenContent(), 3000)
})
}
loopFun()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment