🏠 Home 

AniDB search for Nyaa

Turns the torrent title into a search for the anime on AniDB.


Install this script?
  1. // ==UserScript==
  2. // @name AniDB search for Nyaa
  3. // @namespace http://sushiyuki/
  4. // @version 0.1
  5. // @description Turns the torrent title into a search for the anime on AniDB.
  6. // @author Yuki
  7. // @match https://nyaa.si/view/*
  8. // @grant unsafeWindow
  9. // ==/UserScript==
  10. var $ = unsafeWindow.jQuery;
  11. (function() {
  12. 'use strict';
  13. // from https://stackoverflow.com/a/9756789/8267008
  14. function quoteattr(s) {
  15. return ('' + s)
  16. .replace(/&/g, '&')
  17. .replace(/'/g, ''')
  18. .replace(/"/g, '"')
  19. .replace(/</g, '&lt;')
  20. .replace(/>/g, '&gt;')
  21. .replace(/\r\n/g, '&#13;')
  22. .replace(/[\r\n]/g, '&#13;');
  23. }
  24. // the part about Japanese characters is adapted from http://www.localizingjapan.com/blog/2012/01/20/regular-expressions-for-japanese-text/
  25. let h3 = $('div.container > div.panel > div.panel-heading > h3.panel-title').first(),
  26. text = h3.text(),
  27. title = text.replace('_',' ').replace(/^\s*\[[^\]]+\]\s*/,'').replace(/[[(].*/,'').replace(/ - [0-9]+.*/,'').replace(/\s+S(eason)?\s*[0-9]+\s+(E\s*[0-9]+\s+)?/ig,' ').replace(/[^a-zA-Zぁ-ゟ゠-ヿ㐀-䶵一-鿋豈-頻⺀-⿕ヲ-゚]+/g,' '),
  28. url = 'https://anidb.net/perl-bin/animedb.pl?adb.search=' + quoteattr(title) + '&show=animelist&do.search=search',
  29. h3_with_link = $('<h3 class="panel-title"><a href="'+url+'">'+text+'</a></h3>');
  30. h3.replaceWith(h3_with_link);
  31. })();