Twitter cleaner

Removes the Twitter sidebar and shortens longer tweets.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Twitter cleaner
// @namespace    http://www.emilioveois.com
// @description  Removes the Twitter sidebar and shortens longer tweets.
// @include      https://twitter.com/*
// @grant        none
// @version      0.2
// ==/UserScript==

window.addEventListener('load', function() {

setInterval(function() { 
    
  function disable() {
    document.querySelectorAll('[aria-label="Communities"]')[0].style.display='none';
    document.querySelectorAll('[aria-label="Tweet"]')[0].style.display='none';
    document.querySelectorAll('[data-testid="sidebarColumn"]')[0].style.display='none';
  }
  disable();
  
  function truncateString(str, num) {
    if (str.length > num) {
      return str.slice(0, num) + "...";
    } else {
      return str;
    }
  }
  function shortener() {
    nodes = document.querySelectorAll('[data-testid="tweetText"] span');
    for (i = 0; i < nodes.length; i++) {
      tweetText = nodes[i].innerText;
      nodes[i].textContent = truncateString(tweetText, 280);
    }
  }
  shortener();
  
}, 8000);
  
}, false);