Remove social media fact checks

Removes Twitter's fact checking info links on political tweets

目前为 2020-11-07 提交的版本。查看 最新版本

// ==UserScript==
// @name        Remove social media fact checks
// @namespace   Violentmonkey Scripts
// @match       *://twitter.com/*
// @grant       none
// @version     1.3
// @author      qsniyg
// @description Removes Twitter's fact checking info links on political tweets
// ==/UserScript==

(function() {
  var remove_editorial_svgs = function() {
    var svgs = document.querySelectorAll("article a > div > svg");
    for (var i = 0; i < svgs.length; i++) {
      var svg = svgs[i];
      
      var parent = svg.parentElement;
      
      if (parent.children.length !== 2)
        continue;
      
      if (parent.children[0] !== svg)
        continue;
      
      if (parent.children[1].tagName !== "SPAN")
        continue;
      
      var dparent = parent.parentElement;
      
      if (!/\/i\/+events\/+[0-9]{10,}(?:[?#].*)?$/.test(dparent.href) && !/:\/\/help\.twitter\.com\/(?:[^/]+\/+)?rules-and-policies\//.test(dparent.href))
        continue;
      
      dparent.style.setProperty("display", "none", "important");
    }
  };
  
  // 0.2% of script time, according to chrome's profiler on my computer
  setInterval(remove_editorial_svgs, 100);
})();