Reddit - auto pause NeverEndingReddit every X pages

Pauses NER every X pages for you to reload Reddit at the new position and unpauses it after the reload. Helps stopping the ressources-guzzling which slows down the browser.

  1. // ==UserScript==
  2. // @name Reddit - auto pause NeverEndingReddit every X pages
  3. // @namespace https://greasyfork.org/users/5174-jesuis-parapluie
  4. // @author jesuis-parapluie
  5. // @version 0.0.1
  6. // @description Pauses NER every X pages for you to reload Reddit at the new position and unpauses it after the reload. Helps stopping the ressources-guzzling which slows down the browser.
  7. //
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  9. // @grant none
  10. // @include /^https?:\/\/(.+\.)?reddit\.com\/?.*$/
  11. // @exclude /^https?:\/\/(.+\.)?reddit\.com\/.+\/comments\/.*$/
  12. // ==/UserScript==
  13.  
  14.  
  15. (function ($) {
  16. 'use strict';
  17. /*jslint browser: true */
  18. /*global jQuery */
  19.  
  20. $.noConflict();
  21.  
  22. var options = {
  23. pauseAtPage: 5,
  24. restartNER: true
  25. },
  26.  
  27. restarter = function () {
  28. if ($('div#NREPause').size()) {
  29. $('div#NREPause').click();
  30. } else {
  31. setTimeout(restarter, 300);
  32. }
  33. };
  34.  
  35.  
  36. if (options.restartNER && $('div#NREPause').hasClass('paused') && document.location.search.search("after=") > 0) { restarter(); }
  37.  
  38. $(document).bind('DOMNodeInserted', function (e) {
  39. if (e.target.tagName === 'DIV' && e.target.hasAttribute('class') && e.target.getAttribute('class') === 'NERPageMarker') {
  40. if (!$('div#NREPause').hasClass('paused') && parseInt($(e.target).text().split(' ').pop(), 10) >= options.pauseAtPage) {
  41. $('div#NREPause').click();
  42. }
  43. }
  44. });
  45.  
  46. }(jQuery));