// ==UserScript== // @name SugoiMusic Filter Toggle // @namespace http://sugoimusic.me // @version 0.1 // @description Modifies filter bar behavior on artist pages so that mutiple categories can be selected // @author herbert // @icon https://sugoimusic.me/favicon.ico // @match https://sugoimusic.me/artist.php?id=* // @grant none // ==/UserScript== function filter(e){ if (e.getAttribute('selected') === 'true'){ hideCategory(e); } else { showCategory(e); } apply_torrent_table_styling(); } function showAll(e){ let filterCats = document.querySelectorAll('li[id^="nav"]>a.filter-cat'); console.log(filterCats); for (let element of filterCats){ console.log(element); showCategory(element); } apply_torrent_table_styling(); } function hideCategory(e) { let className = e.parentElement.getAttribute('id').replace('nav_',''); if (e.closest('#discog_table')){ $('.non_contrib_table .'+className).ghide(); } else { $('.contrib_table .'+className).ghide(); } e.setAttribute('selected',false); e.style.fontWeight = 'normal'; } function showCategory(e) { let className = e.parentElement.getAttribute('id').replace('nav_',''); if (e.closest('#discog_table')){ $('.non_contrib_table .'+className).gshow(); } else { $('.contrib_table .'+className).gshow(); } e.setAttribute('selected',true); e.style.fontWeight = 'bold'; } (function() { 'use strict'; let filterAll = document.querySelector('a#nav_all'); filterAll.removeAttribute('onclick'); filterAll.setAttribute('href','#/'); filterAll.addEventListener('click',function(){ showAll(this); }); let filterCats = document.querySelectorAll('li[id^="nav"]>a.filter-cat'); for (let element of filterCats){ element.removeAttribute('onclick'); element.setAttribute('selected',true); element.setAttribute('href','#/'); element.style.fontWeight = 'bold'; element.addEventListener('click',function(event){ filter(this); }); } })();