JAVASCRIPT 112
Twitter with less crap Guest on 15th May 2021 02:01:08 PM
  • Copy
  1. // ==UserScript==
  2. // @name         Twitter with less crap
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  Hide Useless Sidebar
  6. // @author       Razvan Cilibeanu
  7. // @match        *://twitter.com/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11.  
  12. (function() {
  13.     'use strict';
  14. function createfn(){
  15.     var element = document.createElement("div");
  16.     element.classList.add("cover-div");
  17.     element.id = "cid";
  18.     var showhide =document.createElement("div");
  19.     showhide.classList.add("hide-show");
  20.     document.getElementsByTagName('body')[0].appendChild(element);
  21.     document.getElementsByTagName('body')[0].appendChild(showhide);
  22.     showhide.innerHTML='<img onclick="showhide()"  id="toggle"   class="show-icon" src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F8%2F85%2FEye_Icon.svg%2F1024px-Eye_Icon.svg.png&f=1&nofb=1">';
  23.    }
  24.     window.onload=createfn();
  25.     var styles = `
  26.     .cover-div {width: calc(100% - 1200px);height: 100vh;position: fixed;background: #FFFFFF;right: 0;top: 0px;}
  27.     .hide-show{text-align:right;position:fixed;top:1em;right:1em;}
  28.     .show-icon{width:30px;height:auto;margin:1em}`
  29.     var styleSheet = document.createElement("style")
  30.     styleSheet.type = "text/css"
  31.     styleSheet.innerText = styles
  32.     document.head.appendChild(styleSheet)
  33.     document.getElementById ("toggle").addEventListener ("click", myFunction, false);
  34.     function myFunction() {
  35.     var x = document.getElementById("cid");
  36.     if (x.style.display === "none") {x.style.display = "block";} else { x.style.display = "none";}
  37. }
  38. })();