Advertisement
Snuggledash

Prune All Archived Threads

Apr 15th, 2019
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name Thread Watcher Pruner
  3. // @namespace http://www.4chan.org/
  4. // @match *://boards.4chan.org/*
  5. // @match *://boards.4channel.org/*
  6. // @grant none
  7. // @run-at document-start
  8. // ==/UserScript==
  9.  
  10. document.addEventListener('4chanMainInit', function(e) {
  11.   let config = window.Config || window.FC.extConfig;
  12.   if (!config.threadWatcher) return;
  13.   ThreadWatcher.pruneArchivedThreads = function() {
  14.     let w = ThreadWatcher.watched;
  15.     let bl = ThreadWatcher.blacklisted;
  16.     Object.keys(w).forEach(k => {
  17.       // archived flag
  18.       if (w[k].length > 3 && w[k][3]) {
  19.         delete w[k];
  20.         bl[k] = 1;
  21.       }
  22.     });
  23.     ThreadWatcher.save();
  24.     ThreadWatcher.build(true);
  25.   };
  26.   let addPruneLink = function(e) {
  27.     let pruneLink = document.createElement('img');
  28.     pruneLink.id = 'twRealPrune';
  29.     pruneLink.alt = 'P';
  30.     pruneLink.title = 'Prune';
  31.     // behold the prune broom
  32.     pruneLink.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASBAMAAACk4JNkAAAAElBMVEUBAAD///+5elcAAACDUTb+/v6YObyPAAAAAXRSTlMAQObYZgAAAGBJREFUeNo9jdERwCAMQnUDuU4g6QKaCdpzAfdfpjnUJj8cvIOEWdK6y/GrthW87Ti7HxUgDsgKFIGkE4pp3apMWrzMCINVT7fOIc/8frkayaFOMCwNZXA8azKT3Aox9wH5Rgw7swlc4wAAAABJRU5ErkJggg==';
  33.     pruneLink.classList.add('pointer');
  34.     pruneLink.classList.add('right');
  35.     pruneLink.addEventListener('click', function() {
  36.       ThreadWatcher.pruneArchivedThreads();
  37.     });
  38.     document.getElementById('twHeader').appendChild(pruneLink);
  39.   };
  40.   if (document.readyState === 'loading') {
  41.     document.addEventListener('DOMContentLoaded', addPruneLink);
  42.   } else {
  43.     addPruneLink();
  44.   }
  45. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement