AO3: Wrangling home filter

Show only fandoms with unwrangled/unfilterable tags.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        AO3: Wrangling home filter
// @description Show only fandoms with unwrangled/unfilterable tags.
// @namespace	https://greasyfork.org/en/scripts/10496-ao3-wrangling-home-filter
// @author	Min
// @version	1.1.2
// @grant       none
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js
// @include     *archiveofourown.org/tag_wranglers/*
// ==/UserScript==


(function($) {
	
	// check if the fandoms have unfilterable and unwrangled tags
	$('div.tag_wranglers-show.dashboard #user-page table tbody tr').each(function() {
		
		var tag_counters = $(this).find('td');
		
		if (tag_counters.slice(0,3).text() == '   ') {
			$(this).addClass('no-unfilterable');
		}
		
		if (tag_counters.slice(3,6).text() == '   ') {
			$(this).addClass('no-unwrangled');
		}
	});
	
	addToggle();
	
	var style = $('<style type="text/css"></style>').appendTo($('head'));
	
	// add toggle menu above the table
	function addToggle() {
		
		var toggle_p = $('<p></p>').html('Show only fandoms with:&nbsp;&nbsp;');
		
		var only_unwrangled = $('<a></a>').html('[ unwrangled tags ]');
		only_unwrangled.click(function() {
			addCss(1);
			toggle_p.find('a').css('font-weight', 'normal');
			$(this).css('font-weight', 'bold');
		});
		
		var unfilterable_unwrangled = $('<a></a>').html('[ unfilterable or unwrangled tags ]');
		unfilterable_unwrangled.click(function() {
			addCss(2);
			toggle_p.find('a').css('font-weight', 'normal');
			$(this).css('font-weight', 'bold');
		});
		
		var all_fandoms = $('<a style="font-weight: bold"></a>').html('[ all fandoms ]');
		all_fandoms.click(function() {
			addCss(3);
			toggle_p.find('a').css('font-weight', 'normal');
			$(this).css('font-weight', 'bold');
		});
		
		toggle_p.append(only_unwrangled, '&nbsp;&nbsp;', unfilterable_unwrangled, '&nbsp;&nbsp;', all_fandoms);
		
		$('#user-page table').before(toggle_p);
	}

	// add css rules to page head; 1 - unwrangled, 2 - unfilterable or unwrangled, 3 - all fandoms
	function addCss(option) {
		var css_unwrangled = '.no-unwrangled {display: none;}';
		var css_unfilterable = '.no-unfilterable.no-unwrangled {display: none;}';
		
		switch (option) {
			case 1:
				style.html(css_unwrangled);
				break;
			case 2:
				style.html(css_unfilterable);
				break;
			default:
				style.html('');
		}
	}
	
})(jQuery);