Twitter remove content warning

Remove twitter content warning

Instalează acest script?
Script sugerat de autor

Poate îți va plăcea șiTwitter image viewing enhancement.

Instalează acest script
  1. // ==UserScript==
  2. // @name Twitter remove content warning
  3. // @name:zh-CN Twitter 移除内容警告
  4. // @name:zh-TW Twitter 移除内容警告
  5. // @icon https://twitter.com/favicon.ico
  6. // @namespace https://github.com/Tsuk1ko
  7. // @version 1.0.2
  8. // @description Remove twitter content warning
  9. // @description:zh-CN 移除 twitter 的敏感内容警告
  10. // @description:zh-TW 移除 twitter 的敏感内容警告
  11. // @author 神代綺凛
  12. // @include https://x.com/*
  13. // @include https://twitter.com/*
  14. // @include https://mobile.twitter.com/*
  15. // @license MIT
  16. // @grant GM_addStyle
  17. // @run-at document-end
  18. // ==/UserScript==
  19.  
  20. (async () => {
  21. 'use strict';
  22.  
  23. const css = (strings, ...values) => GM_addStyle(String.raw({ raw: strings }, ...values));
  24.  
  25. /**
  26. * @template {Function} T
  27. * @param {T} func
  28. * @param {number} timeout
  29. * @returns {ReturnType<T>}
  30. */
  31. const waitValue = (func, timeout = 10000) =>
  32. new Promise((resolve, reject) => {
  33. const val = func();
  34. if (val) {
  35. resolve(val);
  36. return;
  37. }
  38. const timeoutTimer = setTimeout(() => {
  39. clearInterval(timer);
  40. reject();
  41. }, timeout);
  42. const timer = setInterval(() => {
  43. const val = func();
  44. if (val) {
  45. clearTimeout(timeoutTimer);
  46. clearInterval(timer);
  47. resolve(val);
  48. }
  49. }, 500);
  50. });
  51.  
  52. const findBlurCssRule = () => {
  53. for (const ss of document.styleSheets) {
  54. for (const rule of ss.cssRules) {
  55. if (!(rule instanceof CSSStyleRule)) continue;
  56. if (rule.style.filter === 'blur(30px)') {
  57. return rule;
  58. }
  59. }
  60. }
  61. };
  62.  
  63. const rule = await waitValue(findBlurCssRule);
  64. if (!rule) {
  65. console.warn('[trcw] css rule not found');
  66. return;
  67. }
  68.  
  69. css`
  70. ${rule.selectorText} {
  71. filter: none !important;
  72. }
  73. ${rule.selectorText} + div {
  74. display: none !important;
  75. }
  76. `;
  77.  
  78. console.log('[trcw] done', rule.selectorText);
  79. })();