Advertisement
Kaanbaltlak

AO3 Primary Pairing - español

Jul 2nd, 2024
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Ao3 Only Show Primary Pairing
  3. // @namespace    https://greasyfork.org/en/users/36620
  4. // @version      1
  5. // @description  Hides works where specified pairing isn't the first listed.
  6. // @author       Modified by Neeve, originally by scriptfairy
  7. // @include      http://archiveofourown.org/*
  8. // @include      https://archiveofourown.org/*
  9. // @grant        none
  10. // @downloadURL https://update.greasyfork.org/scripts/377386/Ao3%20Only%20Show%20Primary%20Pairing.user.js
  11. // @updateURL https://update.greasyfork.org/scripts/377386/Ao3%20Only%20Show%20Primary%20Pairing.meta.js
  12. // ==/UserScript==
  13.  
  14. /* CONFIG
  15.    keep a plaintext file of your config because they will not be saved when the script updates */
  16.  
  17.  
  18. var relationships = ['Kakyoin Noriaki/Kujo Jotaro', 'Hobie Brown/Pavitr Prabhakar', 'Tiz Arrior/Ringabel', 'Cindy Moon/Peter Parker'];
  19. // the relationship tag you want to see (exact, case-sensitive). replace with your desired pairing.
  20.  
  21. var characters = ['Pavitr Prabhakar'];
  22. // the character tags you want to see (exact, case-sensitive) - - ignore this
  23.  
  24. var relpad = 1;
  25. // you want to see at least one of your relationships within this many relationship tags
  26.  
  27. var charpad = 5;
  28. // you want to see at least one of your characters within this many character tags
  29.  
  30. /* END CONFIG */
  31.  
  32. (function($) {
  33.     $('<style>').text(
  34.         '.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}'
  35.     ).appendTo($('head'));
  36.     if (relationships.length === 0 && characters.length === 0) {return;}
  37.     var checkfandom = document.createElement('div');
  38.     var fandomlink = $('h2.heading a')[0].href;
  39.     fandomlink = fandomlink.slice(fandomlink.indexOf('tags'));
  40.     $(checkfandom).load('/'+fandomlink+' .parent', function(){
  41.         if ($('ul', checkfandom).text() == "No Fandom") {return;}
  42.         else {
  43.             for(i=0;i<$('.index .blurb').length;i++){
  44.                 var tags = $('.index .blurb ul.tags')[i];
  45.                 var reltags = $('.relationships', tags).slice(0,relpad); var chartags = $('.characters', tags).slice(0,charpad);
  46.                 var temprel = []; var tempchar = [];
  47.                 $(reltags).map(function() {
  48.                     temprel.push(this.innerText);
  49.                 });
  50.                 $(chartags).map(function() {
  51.                     tempchar.push(this.innerText);
  52.                 });
  53.                 var relmatch = temprel.filter(function(n) {
  54.                     return relationships.indexOf(n) != -1;
  55.                 });
  56.                 var charmatch = tempchar.filter(function(n) {
  57.                     return characters.indexOf(n) != -1;
  58.                 });
  59.                 if (relmatch.length === 0 && charmatch.length === 0) {
  60.                     var work = $('.index .blurb')[i];
  61.                     work.style.display = 'none';
  62.                     var button = document.createElement('div');
  63.                     button.setAttribute('class','workhide');
  64.                     button.innerHTML = '<div class="left">Este trabajo no da prioridad a sus etiquetas preferidas.</div><div class="right"><button type="button" class="showwork">Mostrar</button></div>';
  65.                     $(work).after(button);
  66.                 }
  67.             }
  68.             $(document).ready(function(){
  69.                 $('.showwork').click(function() {
  70.                     var blurb = $(this).parents('.workhide').prev()[0];
  71.                     $(blurb).removeAttr('style');
  72.                     $(this).parents('.workhide').remove();
  73.                 });
  74.             });
  75.         }
  76.     });
  77.  
  78.  
  79. })(window.jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement