Youtube End-Screen Remover (End Screen disposer)

Remove annoyed end-screens on youtube videos

  1. // ==UserScript==
  2. // @name Youtube End-Screen Remover (End Screen disposer)
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description Remove annoyed end-screens on youtube videos
  6. // @author #EMBER (htps://fb.com/embermaxx)
  7. // @match *://www.youtube.com/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var intvl, i=0, loop = 3E3, ig = 0;
  15. //startToAppend -> Time for wait till YouTube classes load;
  16. setInterval(checkIfAppend, loop);
  17. //loop = check interval for new End-Screens;
  18.  
  19. function appendElement() {
  20. var el = document.createElement("div");
  21. el.id = "ess-info";
  22. el.style.textAlign = "center";
  23. el.style.fontSize = "17px";
  24. el.style.padding = "8px 8px";
  25. el.style.marginRight = "6px";
  26. el.style.backgroundColor = "rgba(255,255,255,0.1)";
  27. el.style.color = "#f1f1f1";
  28. el.style.border = "none";
  29. el.style.borderRadius = "17px";
  30. el.style.cursor = "pointer";
  31. el.setAttribute("title", "Total Disposed End-Screens");
  32. el.style.userSelect = "none";
  33.  
  34. el.addEventListener("mouseover", function() {
  35. el.setAttribute("title", "Total "+ig+" End-Screens were Disposed!");
  36. el.style.backgroundColor = "rgba(128,128,128,0.5)"; // Gray style on hover
  37. });
  38.  
  39. // Mouseout event listener
  40. el.addEventListener("mouseout", function() {
  41. el.style.backgroundColor = "rgba(255,255,255,0.1)"; // Original color
  42. });
  43.  
  44. var actionsElement = document.getElementById("top-level-buttons-computed");
  45. if(actionsElement == null)
  46. actionsElement = document.getElementById("actions");
  47. actionsElement.insertBefore(el, actionsElement.firstChild);
  48.  
  49. }
  50.  
  51. function addIndicator(element){
  52. var span = document.createElement("span");
  53. span.id="ess-info-ind";
  54. span.textContet = "✋ 0";
  55. element.append(span);
  56. }
  57.  
  58. function checkIfAppend()
  59. {
  60. let essInfo = document.getElementById("ess-info");
  61. let essInfoInd = document.getElementById("ess-info-ind");
  62.  
  63. if(essInfo == null)
  64. appendElement();
  65. if(essInfoInd == null && essInfo != null)
  66. addIndicator(essInfo);
  67. removeEndScreens("ytp-ce-element");
  68. }
  69.  
  70. function removeEndScreens(className){
  71. var elements = document.getElementsByClassName(className);
  72. while(elements.length > 0){
  73. if(elements[0].parentNode.removeChild(elements[0])){
  74. ig = ++i;
  75. let essInfoInd = document.getElementById("ess-info-ind");
  76. if(essInfoInd != null)
  77. essInfoInd.textContent = "✋ "+i;
  78. else
  79. checkIfAppend();
  80.  
  81. console.log("Disposed ES Count: "+i);}
  82. else{
  83. console.log("No ES found");
  84. }
  85. }
  86. }
  87. //Script by #EMBER
  88. })();