daily pastebin goal
24%
SHARE
TWEET

Duolingo Remove Sticky

Elieder Jan 14th, 2017 364 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        RemoveSticky
  3. // @namespace   https://www.duolingo.com/EliederSousa
  4. // @description Removes all sticky posts in discussion board.
  5. // @include     https://www.duolingo.com/*
  6. // @include     http://www.duolingo.com/*
  7. // @version     1
  8. // @grant       none
  9. // ==/UserScript==
  10.  
  11. /*
  12.  
  13. |========================================================|
  14. |*                                                      *|
  15. |*               Remove Sticky Script                   *|
  16. |*       Proudly created to Duolingo's Community        *|
  17. |*                                                      *|
  18. |--------------------------------------------------------|
  19. |                                                        |
  20. |  * Author: Elieder D. Sousa                            |
  21. |  * https://www.duolingo.com/EliederSousa               |
  22. |  * January, 14, 2017                                   |
  23. |  * First Release                                       |
  24. |                                                        |
  25. |  * We use jquery: https://jquery.org/                  |
  26. |                                                        |
  27. |  This script hides (not removes) the sticky posts on   |
  28. |  Duolingo's forums, allowing you to see the others.    |
  29. |                                                        |
  30. |  This is a part of a big project, Duolingo Toolbox, a  |
  31. |  set of tools to help us to learn with more control    |
  32. |  over the site.                                        |
  33. |                                                        |
  34. |========================================================|
  35.  
  36. */
  37.  
  38. // This is giving Reference error, because JQuery call
  39. // I wonder I am forgeting something...
  40. function inject(f) {
  41.     var script;
  42.     script = document.createElement('script');
  43.     script.type = 'text/javascript';
  44.     script.setAttribute('name', 'next_level_box');
  45.     script.textContent = '(' + f.toString() + ')($)';
  46.     document.head.appendChild(script);
  47. }
  48.  
  49. inject(funcInjected);
  50.  
  51. function funcInjected($) { 
  52.     function RemoveSticky() {
  53.         var temp_DOMElement = document.getElementsByClassName('sticky-discussion-message');
  54.         for(var DOMCount = 0; DOMCount <= temp_DOMElement.length - 1; DOMCount++) {
  55.             temp_DOMElement[DOMCount].parentNode.parentNode.style.display='none';
  56.         }
  57.     }
  58.    
  59.     // Helps to update when update the page or its contents.
  60.     $(document).ready(function() {
  61.         RemoveSticky();
  62.     });
  63.     $(document).ajaxComplete(function() {
  64.         RemoveSticky();
  65.     });
  66.    
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top