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.3.5
  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 (exact, case-sensitive)
  15.  
  16. var characters = ['Bruce Banner', 'EVE (WALL-E)', 'Jamie Moriarty | Irene Adler'];
  17. // the character tags you want to see (exact, case-sensitive)
  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. var checkfandom = document.createElement('div');
  33. var fandomlink = $('h2.heading a')[0].href;
  34. fandomlink = fandomlink.slice(fandomlink.indexOf('tags'));
  35. $(checkfandom).load('/'+fandomlink+' .parent', function(){
  36. if ($('ul', checkfandom).text() == "No Fandom") {return;}
  37. else {
  38. for(i=0;i<$('.index .blurb').length;i++){
  39. var tags = $('.index .blurb ul.tags')[i];
  40. var reltags = $('.relationships', tags).slice(0,relpad); var chartags = $('.characters', tags).slice(0,charpad);
  41. var temprel = []; var tempchar = [];
  42. $(reltags).map(function() {
  43. temprel.push(this.innerText);
  44. });
  45. $(chartags).map(function() {
  46. tempchar.push(this.innerText);
  47. });
  48. var relmatch = temprel.filter(function(n) {
  49. return relationships.indexOf(n) != -1;
  50. });
  51. var charmatch = tempchar.filter(function(n) {
  52. return characters.indexOf(n) != -1;
  53. });
  54. if (relmatch.length === 0 && charmatch.length === 0) {
  55. var work = $('.index .blurb')[i];
  56. work.style.display = 'none';
  57. var button = document.createElement('div');
  58. button.setAttribute('class','workhide');
  59. 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>';
  60. $(work).after(button);
  61. }
  62. }
  63. $(document).ready(function(){
  64. $('.showwork').click(function() {
  65. var blurb = $(this).parents('.workhide').prev()[0];
  66. $(blurb).removeAttr('style');
  67. $(this).parents('.workhide').remove();
  68. });
  69. });
  70. }
  71. });
  72.  
  73.  
  74. })(window.jQuery);