ao3 secondary char&pairing filter

hides works if chosen tags are late in sequence

目前为 2016-04-10 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name ao3 secondary char&pairing filter
  3. // @namespace https://greasyfork.org/en/users/36620
  4. // @version 0.2
  5. // @description hides works if chosen tags are late in sequence
  6. // @author scriptfairy
  7. // @match http*://archiveofourown.org/tags*works*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /* CONFIG */
  12.  
  13. var relationships = ["Pepper Potts/Tony Stark", "Poe Dameron/Finn/Rey", "Loren & Tobias (Animorphs)"];
  14. // the relationship tags you want to see
  15.  
  16. var characters = ["Bruce Banner", "EVE (WALL-E)", "Jamie Moriarty | Irene Adler"];
  17. // the character tags you want to see
  18.  
  19. var relpad = 3;
  20. // you want to see at least one of your relationships within this many relationship tags
  21.  
  22. var charpad = 5;
  23. // you want to see at least one of your characters within this many character tags
  24.  
  25. /* END CONFIG */
  26.  
  27. (function($) {
  28. $('<style>').text(
  29. '.workhide{border:1px solid rgb(221,221,221);margin:0.643em 0em;padding:0.429em 0.75em;height:29px;} .workhide .left{float:left;padding-top:5px;} .workhide .right{float:right}'
  30. ).appendTo($('head'));
  31. if (relationships.length === 0 && characters.length === 0) {return;}
  32. for(i=0;i<$('.index .blurb').length;i++){
  33. var tags = $('.index .blurb ul.tags')[i];
  34. var reltags = $('.relationships', tags).slice(0,relpad); var chartags = $('.characters', tags).slice(0,charpad);
  35. var temprel = []; var tempchar = [];
  36. $(reltags).map(function() {
  37. temprel.push(this.innerText);
  38. });
  39. $(chartags).map(function() {
  40. tempchar.push(this.innerText);
  41. });
  42. var relmatch = temprel.filter(function(n) {
  43. return relationships.indexOf(n) != -1;
  44. });
  45. var charmatch = tempchar.filter(function(n) {
  46. return characters.indexOf(n) != -1;
  47. });
  48. if (relmatch.length === 0 && charmatch.length === 0) {
  49. var work = $('.index .blurb')[i];
  50. work.style.display = 'none';
  51. var button = document.createElement('div');
  52. button.setAttribute('class','workhide');
  53. button.innerHTML = '<div class="left">This work does not prioritize your preferred tags.</div><div class="right"><button type="button" class="showwork">Show Work</button></div>';
  54. $(work).after(button);
  55. }
  56. }
  57. $(document).ready(function(){
  58. $('.showwork').click(function() {
  59. var blurb = $(this).parents('.workhide').prev()[0];
  60. $(blurb).removeAttr('style');
  61. $(this).parents('.workhide').remove();
  62. });
  63. });
  64. })(window.jQuery);