FA Advanced Filter

On furaffinity.net, hides thumbnails according to desired rating(s) and/or art medium.

  1. // ==UserScript==
  2. // @name FA Advanced Filter
  3. // @namespace FurAffinity
  4. // @version 1.03
  5. // @description On furaffinity.net, hides thumbnails according to desired rating(s) and/or art medium.
  6. // @author Toboe
  7. // @grant none
  8. // @run-at document-end
  9. // @match *://*.furaffinity.net/*
  10. // @exclude *://*.furaffinity.net/search
  11. // @exclude *://*.furaffinity.net/search/*
  12. // @require https://code.jquery.com/jquery-latest.js
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. console.log("FA Advanced Filter");
  19.  
  20. const $ = jQuery;
  21.  
  22. const artRatings = {
  23. general: { key: 'general', classId: 'r-general', on: true},
  24. mature: { key: 'mature', classId: 'r-mature', on: true},
  25. adult: { key: 'adult', classId: 'r-adult', on: true}
  26. };
  27.  
  28. const artTypes = {
  29. img: { key: 'image', classId: 't-image', on: true},
  30. txt: { key: 'text', classId: 't-text', on: true},
  31. audio: { key: 'audio', classId: 't-audio', on: true}
  32. };
  33.  
  34. const updateFilteredView = function() {
  35. for(let rating in artRatings) {
  36. for(let type in artTypes) {
  37. let selector = 'figure.' + artRatings[rating].classId + '.' + artTypes[type].classId;
  38. let figure = $(selector);
  39. figure.each(function(){
  40. $(this).toggle(artRatings[rating].on && artTypes[type].on);
  41. }
  42. );
  43. }
  44. }
  45. };
  46.  
  47. const attachPoint = $("body");
  48. if (attachPoint.length) {
  49. attachPoint.prepend(`
  50. <input type="checkbox" id="generalControl" checked /> <strong>General</strong>
  51. <input type="checkbox" id="matureControl" checked /> <strong>Mature</strong>
  52. <input type="checkbox" id="adultControl" checked /> <strong>Adult</strong>
  53. <input type="checkbox" id="imageControl" checked /> <strong>Images</strong>
  54. <input type="checkbox" id="textControl" checked /> <strong>Writing</strong>
  55. <input type="checkbox" id="audioControl" checked /> <strong>Music</strong>
  56. `);
  57. }
  58.  
  59. const checkboxChanged = function(key) {
  60. let isOn = $('#' + key + 'Control').prop('checked');
  61. for(let rating in artRatings) {
  62. if(artRatings[rating].key === key) {
  63. artRatings[rating].on = isOn;
  64. }
  65. }
  66. for(let type in artTypes) {
  67. if(artTypes[type].key === key) {
  68. artTypes[type].on = isOn;
  69. }
  70. }
  71. updateFilteredView();
  72. };
  73.  
  74. for(let rating in artRatings) {
  75. $('#' + artRatings[rating].key + 'Control').click(function() { checkboxChanged(artRatings[rating].key); } );
  76. }
  77. for(let type in artTypes) {
  78. $('#' + artTypes[type].key + 'Control').click(function() { checkboxChanged(artTypes[type].key); } );
  79. }
  80.  
  81. updateFilteredView();
  82. }
  83. )();