Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Thread Watcher Pruner
- // @namespace http://www.4chan.org/
- // @match *://boards.4chan.org/*
- // @match *://boards.4channel.org/*
- // @grant none
- // @run-at document-start
- // ==/UserScript==
- document.addEventListener('4chanMainInit', function(e) {
- let config = window.Config || window.FC.extConfig;
- if (!config.threadWatcher) return;
- ThreadWatcher.pruneArchivedThreads = function() {
- let w = ThreadWatcher.watched;
- let bl = ThreadWatcher.blacklisted;
- Object.keys(w).forEach(k => {
- // archived flag
- if (w[k].length > 3 && w[k][3]) {
- delete w[k];
- bl[k] = 1;
- }
- });
- ThreadWatcher.save();
- ThreadWatcher.build(true);
- };
- let addPruneLink = function(e) {
- let pruneLink = document.createElement('img');
- pruneLink.id = 'twRealPrune';
- pruneLink.alt = 'P';
- pruneLink.title = 'Prune';
- // behold the prune broom
- pruneLink.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASBAMAAACk4JNkAAAAElBMVEUBAAD///+5elcAAACDUTb+/v6YObyPAAAAAXRSTlMAQObYZgAAAGBJREFUeNo9jdERwCAMQnUDuU4g6QKaCdpzAfdfpjnUJj8cvIOEWdK6y/GrthW87Ti7HxUgDsgKFIGkE4pp3apMWrzMCINVT7fOIc/8frkayaFOMCwNZXA8azKT3Aox9wH5Rgw7swlc4wAAAABJRU5ErkJggg==';
- pruneLink.classList.add('pointer');
- pruneLink.classList.add('right');
- pruneLink.addEventListener('click', function() {
- ThreadWatcher.pruneArchivedThreads();
- });
- document.getElementById('twHeader').appendChild(pruneLink);
- };
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', addPruneLink);
- } else {
- addPruneLink();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement