Advertisement
Guest User

Remove Twitch Pills

a guest
Apr 7th, 2020
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // @namespace   TWITCHLOC
  2. // @version  1
  3. // @include     https://www.twitch.tv/*
  4. // @include     https://twitch.tv/*
  5. // @grant    none
  6. // @run-at      document-end
  7. // ==/UserScript==
  8.  
  9. function twitchRemovePill() {
  10.   var pillsRemoved = false; // Pills already removed or not
  11.   var pillsDisplayed = 0; // Pills currently displayed
  12.   var timerCheck = 1000; // Checking rate of pills displayed
  13.   var timerForceEnd = 60000; // Timer to force ClearInterval call
  14.   var timerElapsedTime = 0; // Timer to trigger ^
  15.  
  16.   // Check if there're pills to expand
  17.   function checkPills()
  18.   {
  19.     timerElapsedTime += timerCheck;
  20.     if (timerElapsedTime >= timerForceEnd)
  21.     {
  22.       clearInterval(autoCheck);
  23.       console.log("Forced to end pills check.");
  24.       return;
  25.     }
  26.     var pills = document.getElementsByClassName('prime-offers__pill');
  27.     if (pillsRemoved == false || pillsDisplayed < pills.length)
  28.     {
  29.       pillsRemoved = false;
  30.       if (pills.length >= 1) removePills(pills);
  31.     }
  32.   }
  33.  
  34.   // Expanding pills
  35.   function removePills(pills)
  36.   {
  37.     if (pillsRemoved == false)
  38.     {
  39.       for (var i = 0; i < pills.length; i++)
  40.       {
  41.           pills[i].setAttribute("style", "display: none !important;");
  42.       }
  43.       pillsRemoved = true;
  44.       pillsDisplayed = pills.length;
  45.       clearInterval(autoCheck);
  46.       console.log("Pills ("+pillsDisplayed+") fully removed.");
  47.     }
  48.   }
  49.  
  50. var autoCheck = setInterval(checkPills, timerCheck);
  51. }
  52. twitchRemovePill();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement