Sukebei nyaa video previews

Facilitates access to video previews

  1. // ==UserScript==
  2. // @name Sukebei nyaa video previews
  3. // @namespace https://greasyfork.org/scripts/33079
  4. // @description Facilitates access to video previews
  5. // @include https://sukebei.nyaa.si/*
  6. // @version 2017.09.11
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. function pad(n, width, z) {
  11. z = z || '0';
  12. n = n + '';
  13. return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
  14. }
  15.  
  16. function loadHosts() {
  17. var hosts = [
  18. {r:/Caribbeancom(pr)?[ _]{1}([0-9]{6}_[0-9]{3})/, i:[2], u:'https://www.caribbeancompr.com/moviepages/{0}/index.html'},
  19. {r:/加勒比PPV動畫 ([0-9]{6}_[0-9]{3})/, i:[1], u:'https://www.caribbeancompr.com/moviepages/{0}/index.html'},
  20. {r:/Caribbeancom[ _]{1}([0-9]{6}-[0-9]{3})/, i:[1], u:'https://www.caribbeancom.com/moviepages/{0}/index.html'},
  21. {r:/カリビアンコム ([0-9]{6}-[0-9]{3})/, i:[1], u:'https://www.caribbeancom.com/moviepages/{0}/index.html'},
  22. {r:/HEYZO[ _]{1}([0-9]{4})/, i:[1], u:'http://www.heyzo.com/moviepages/{0}/index.html'},
  23. {r:/Heyzo[ _]{1}([0-9]{4})/, i:[1], u:'http://www.heyzo.com/moviepages/{0}/index.html'},
  24. {r:/HEY-([0-9]{3})/, i:[1], u:''},
  25. {r:/Tokyo Hot (RED-[0-9]{3})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  26. {r:/Tokyo[ _]{1}Hot[ _]{1}(th[0-9]{3}-[0-9]{3}-[0-9]{6})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  27. {r:/Tokyo Hot (SE[0-9]{3})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  28. {r:/Tokyo Hot (kb[0-9]{4})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  29. {r:/Tokyo Hot (CZ[0-9]{3})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  30. {r:/Tokyo[ -_]{1}Hot[ -_]{1}([kn]{1}[0-9]{4})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  31. {r:/Tokyo Hot (gedo[0-9]{2})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  32. {r:/Tokyo Hot ([bs]{1}[0-9]{3})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  33. {r:/Tokyo Hot (bouga[0-9]{2})/, i:[1], u:'http://my.tokyo-hot.com/product/{0}/'},
  34. {r:/1[pP]{1}ondo[ _]{1}([0-9]{6}_[0-9]{3})/, i:[1], u:'https://en.1pondo.tv/movies/{0}/'},
  35. {r:/一本道 ([0-9]{6}_[0-9]{3})/, i:[1], u:'https://en.1pondo.tv/movies/{0}/'},
  36. {r:/[pP]{1}acopacomama[ _]{1}([0-9]{6}_[0-9]{3})/, i:[1], u:'http://en.pacopacomama.com/eng/moviepages/{0}/index.html'},
  37. {r:/パコパコママ ([0-9]{6}_[0-9]{3})/, i:[1], u:'http://en.pacopacomama.com/eng/moviepages/{0}/index.html'},
  38. {r:/10musume[ _]{1}([0-9]{6}_[0-9]{2})/, i:[1], u:'http://en.10musume.com/eng/moviepages/{0}/index.html'},
  39. {r:/天然むすめ ([0-9]{6}_[0-9]{2})/, i:[1], u:'http://en.10musume.com/eng/moviepages/{0}/index.html'},
  40. {r:/[kK]{1}in8tengoku[ -]{1}([0-9]{4})/, i:[1], u:'http://en.kin8tengoku.com/moviepages/{0}/index.html'},
  41. {r:/JVRPorn ([0-9]{6})/, i:[1], u:'https://jvrporn.com/video/{0}/'},
  42. {r:/Hey[Dd]{1}ouga ([0-9]{4})-([0-9]{3,4})/, i:[1,2], u:'http://en.heydouga.com/moviepages/{0}/{1}/index.html'},
  43. {r:/(SMD-[0-9]{3})/, i:[1], u:'http://www.aventertainments.com/search_Products.aspx?languageID=1&dept_id=29&keyword={0}&searchby=keyword'},
  44. {r:/S-[cC]{1}ute[ -]{1}([0-9]{3})[ -]{1}([a-zA-Z]{2,})[ -]{1}#?([0-9]{1})/, i:[1,2,3], u:'http://www.s-cute.com/contents/{0}_{1}_{2}/', t:function(item, index) {if (index == 1) { return item; } else if (index == 2) { return item.toLowerCase(); } else if (index == 3) { return pad(item, 2); }}},
  45. {r:/[rR]{1}oselip(-fetish)?[ -]{1}([0-9]{4})/, i:[2], u:'http://www.roselip-fetish.com/movie/?num={0}'},
  46. {r:/[sS]{1}[mM]{1}[-_]{1}[mM]{1}iracle[ -]{1}e?([0-9]{4})/, i:[1], u:'http://sm-miracle.com/movie3.php?num=e{0}'},
  47. {r:/H4610[ -]{1}(ki[0-9]{6})/, i:[1], u:'http://www.h4610.com/moviepages/{0}/index.html'},
  48. {r:/H4610[ -]{1}(ori[0-9]{4})/, i:[1], u:'http://www.h4610.com/moviepages/{0}/index.html'},
  49. {r:/H4610[ -]{1}(pla[0-9]{4})/, i:[1], u:'http://www.h4610.com/moviepages/{0}/index.html'},
  50. {r:/H4610[ -]{1}(gol[0-9]{3,4})/, i:[1], u:'http://www.h4610.com/moviepages/{0}/index.html'},
  51. {r:/H0930[ -]{1}(ki[0-9]{6})/, i:[1], u:'http://www.h0930.com/moviepages/{0}/index.html'},
  52. {r:/H0930[ -]{1}(ori[0-9]{4})/, i:[1], u:'http://www.h0930.com/moviepages/{0}/index.html'},
  53. {r:/H0930[ -]{1}(pla[0-9]{4})/, i:[1], u:'http://www.h0930.com/moviepages/{0}/index.html'},
  54. {r:/H0930[ -]{1}(gol[0-9]{3,4})/, i:[1], u:'http://www.h0930.com/moviepages/{0}/index.html'},
  55. {r:/C0930[ -]{1}(ki[0-9]{6})/, i:[1], u:'http://www.c0930.com/moviepages/{0}/index.html'},
  56. {r:/C0930[ -]{1}(ori[0-9]{4})/, i:[1], u:'http://www.c0930.com/moviepages/{0}/index.html'},
  57. {r:/C0930[ -]{1}(pla[0-9]{4})/, i:[1], u:'http://www.c0930.com/moviepages/{0}/index.html'},
  58. {r:/C0930[ -]{1}(gol[0-9]{3,4})/, i:[1], u:'http://www.c0930.com/moviepages/{0}/index.html'},
  59. {r:/GirlsDelta ([0-9]{4})/, i:[1], u:'https://girlsdelta.com/product/{0}'},
  60. {r:/([a-zA-Z]{2,5}-[0-9]{2,5})/, i:[1], u:'http://www.javlibrary.com/en/vl_searchbyid.php?keyword={0}'},
  61. ];
  62. return hosts;
  63. }
  64.  
  65. function isAV(jQueryObject) {
  66. var a = jQueryObject.find('td:nth-child(1) > a').first();
  67. return (a.attr('href') == '/?c=2_2');
  68. }
  69.  
  70. function getTitle(jQueryObject) {
  71. var a = jQueryObject.find('td:nth-child(2) > a:last').first();
  72. return a.attr('title');
  73. }
  74.  
  75. function matchHost(title, regex) {
  76. var match = regex.exec(title);
  77. if (match) {
  78. return match;
  79. }
  80. return undefined;
  81. }
  82.  
  83. function setLink(jQueryObject, matched, link, indexes, transform) {
  84. var t = transform;
  85. if (t == undefined) {
  86. t = function(item, index) { return item; }
  87. }
  88. var td = jQueryObject.find('td:nth-child(3)').first();
  89. var finalLink = link.replace("{0}", t(matched[indexes[0]], 1));
  90. for(var i = 1; i < indexes.length; i++) {
  91. finalLink = finalLink.replace("{"+i+"}", t(matched[indexes[i]], i+1));
  92. }
  93. td.append($('<a href="' + finalLink + '"><i class="fa fa-fw fa-picture-o"></i></a>'))
  94. }
  95.  
  96. function addLink(jQueryObject) {
  97. var title = getTitle(jQueryObject);
  98. var hosts = loadHosts();
  99. for(var i = 0; i < hosts.length; i++) {
  100. var matched = matchHost(title, hosts[i].r);
  101. if (matched != undefined) {
  102. setLink(jQueryObject, matched, hosts[i].u, hosts[i].i, hosts[i].t);
  103. break;
  104. }
  105. }
  106. }
  107.  
  108. $('.default,.success').each(function (index, value) {
  109. var jQueryObject = $(this);
  110. if (isAV(jQueryObject)) {
  111. addLink(jQueryObject);
  112. }
  113. }
  114. )