byuu.org
  1. byuu.org
  2. code
  3. twitter

Twitter

2019-09-22

[about:config]
general.useragent.override.twitter.com = Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.18
// ==UserScript==
// @name      Twitter
// @namespace Twitter
// @version   1.0
// @author    byuu
// @include   https://twitter.com/*
// @grant     none
// @run-at    document-start
// ==/UserScript==

var themed = 0;

(function() {
  const allowCutCopyPaste = function(e) {
    e.stopImmediatePropagation();
    return true;
  };
  document.addEventListener('cut', allowCutCopyPaste, true);
  document.addEventListener('copy', allowCutCopyPaste, true);
  document.addEventListener('paste', allowCutCopyPaste, true);
})();

function allowInlineTweets() {
  var domain = ".twitter.com";
  var expiryDate = new Date(-1).toUTCString();
  document.cookie = "rweb_optin=; domain=" + domain + "; path=/; expires=" + expiryDate;
}

function applyTheme() {
  if(themed == 1) return;
  var stylesheet = window.document.styleSheets[0];
  if(!stylesheet) return;
  themed = 1;
  var style = document.createElement("style");
  style.type = "text/css";
  style.innerText = "" +
    "* { border-radius: 0em !important; } " +                       //revert circular avatars
    ".Banner { display: none !important; } " +                      //remove bloat
    ".topbar-spacer { padding-top: 45px !important; } " +           //remove "deprecated browser" prompt
    ".wtf-module { display: none !important; } " +                  //remove "who to follow"
    ".WtfLargeCarouselStreamItem { display: none !important; } " +  //remove inline "who to follow"
    ".Footer { display: none !important; } " +                      //remove bloat
    ".Trends { display: none !important; } " +                      //remove trends
    ".stream-tombstone-container { display: none !important; } " +  //remove "blocked/muted tweet" indicator
    ".tooltip { display: none !important; } " +                     //remove annoying tooltips that tend to not go away
    ".DelightOptInModule { display: none !important; }" +           //remove "new Twitter" prompt
    "";
  document.head.appendChild(style);
}

function main() {
  applyTheme();
  allowInlineTweets();
}

main();
var timer = setInterval(main, 50);