Sleazy Fork is available in English.

Nyaa.si - Load More Thumbnail

Load image from cover/screenshot links.

2022/04/16のページです。最新版はこちら。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Nyaa.si - Load More Thumbnail
  3. // @name:zh-CN Nyaa.si - 自动加载更多预览图
  4. // @namespace none
  5. // @description Load image from cover/screenshot links.
  6. // @description:zh-CN 从封面/截图链接加载图片并显示。
  7. // @version 0.3
  8. // @license MIT
  9. // @author York Wang
  10. // @match https://sukebei.nyaa.si/*
  11. // @match https://imgrock.pw/*
  12. // @match https://picrok.com/*
  13. // @match https://picbaron.com/*
  14. // @match https://imgbaron.com/*
  15. // @match https://kvador.com/*
  16. // @match https://kropic.com/*
  17. // @match https://imgsto.com/*
  18. // @match https://imgsen.com/*
  19. // @match https://imgstar.eu/*
  20. // @match https://picdollar.com/*
  21. // @match https://pics4you.net/*
  22. // @match https://silverpic.com/*
  23. // @match https://fotokiz.com/*
  24. // @match http://imglord.com/*
  25. // @match https://imgtaxi.com/*
  26. // @match https://imgadult.com/*
  27. // @match https://imgdrive.net/*
  28. // @match https://uvonahaze.xyz/*
  29. // @match https://trans.firm.in/*
  30. // @match https://imagetwist.com/*
  31. // @match https://imgair.net/*
  32. // @match http://imgair.net/*
  33. // @match http://imgfrost.net/*
  34. // @match http://imgblaze.net/*
  35. // @match https://hentai4free.net/*
  36. // @run-at document-end
  37. // @grant unsafeWindow
  38. // ==/UserScript==
  39.  
  40. (function() {
  41. 'use strict';
  42.  
  43. /**
  44. * type = 1: both Nyaa and non-Nyaa
  45. * type = 2: Nyaa only
  46. * type = 3: non-Nyaa only
  47. */
  48. function Handler(pattern, process, type) {
  49. this.pattern = pattern
  50. this.process = process
  51. this.type = type || 1
  52. }
  53. Handler.prototype.canHandle = function(url) {
  54. return this.pattern.test(url)
  55. }
  56. Handler.prototype.handle = function() {
  57. this.process(url => {
  58. document.location.href = url
  59. unsafeWindow.top.postMessage({"LMT": url}, '*')
  60. })
  61. }
  62. const handlers = []
  63. const addHandler = (pattern, process, nyaaOnly) => handlers.push(new Handler(pattern, process, nyaaOnly))
  64.  
  65. addHandler(/^https?:\/\/(imgrock\.pw)(\/[\w\-]+)+(\.[\w\-]+)+/, callback => {
  66. // pause on CAPTCHA
  67. const iframe = document.querySelector('iframe')
  68. if(iframe && iframe.src.indexOf('captcha') > -1) return
  69.  
  70. const img = document.querySelector('.picview')
  71. if(img) {
  72. callback(img.src)
  73. } else {
  74. const btns = document.querySelectorAll('input[name=fnext]')
  75. for(let i=0;i<btns.length;i++) {if(!btns[i].style.display) btns[i].click()}
  76. const forms = document.querySelectorAll('form')
  77. for(let i=0;i<forms.length;i++) {if(forms[i].hito) {forms[i].submit()}}
  78. }
  79. })
  80. addHandler(/^https?:\/\/(picrok\.com)(\/[\w\-]+)+\.php/, callback => {
  81. // pause on CAPTCHA
  82. const iframe = document.querySelector('iframe')
  83. if(iframe && iframe.src.indexOf('captcha') > -1) return
  84.  
  85. const img = document.querySelector('.picview')
  86. if(img) {
  87. callback(img.src)
  88. } else {
  89. unsafeWindow.setTimeout(() => {
  90. const forms = document.querySelectorAll('form')
  91. const btns = document.querySelectorAll('form>button')
  92. // for(let i=0;i<btns.length;i++) {if(btns[i].style.display) forms[i-1].submit()}
  93. }, 5000)
  94. }
  95. })
  96. addHandler(/^https?:\/\/(picbaron\.com|imgbaron\.com|kvador\.com|kropic\.com|imgsto\.com|imgsen\.com|imgstar\.eu|picdollar\.com|pics4you\.net|silverpic\.com|fotokiz\.com|imglord\.com)(\/.+)+(\.[\w\-]+)+/, callback => {
  97. const img = document.querySelector('.pic')
  98. if(img) {
  99. callback(img.src)
  100. } else {
  101. const form = document.querySelector('form')
  102. form && form.submit()
  103. }
  104. })
  105. addHandler(/^https?:\/\/(imgtaxi\.com|imgadult\.com|imgdrive\.net)(\/\w+)+/, callback => {
  106. unsafeWindow.ctipops = []
  107. unsafeWindow.adbctipops = []
  108. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  109. if(img) {
  110. callback(img.src)
  111. } else {
  112. const btn = document.querySelector('.overlay_ad_link')
  113. unsafeWindow.setTimeout(() => {
  114. if(btn) {
  115. btn.focus()
  116. btn.click()
  117. }
  118. }, 1000)
  119. }
  120. })
  121. addHandler(/^https?:\/\/uvonahaze\.xyz(\/\w+)+/, callback => {
  122. const img = document.querySelector('img.centred_resized')
  123. if(img) {
  124. callback(img.src)
  125. } else {
  126. const btn = document.querySelector('input[name=imgContinue]')
  127. btn && btn.click()
  128. }
  129. })
  130. addHandler(/^https?:\/\/trans\.firm\.in(\/\w+)+/, callback => {
  131. const img = document.querySelector('img.centred_resized')
  132. if(img) {
  133. callback(img.src)
  134. } else {
  135. const btn = document.querySelector('input[name=imgContinue]')
  136. btn && btn.click()
  137. }
  138. })
  139. addHandler(/^https?:\/\/imagetwist\.com(\/\w+)+/, callback => {
  140. const img = document.querySelector('.img-responsive')
  141. if(img) {
  142. callback(img.src)
  143. }
  144. })
  145. addHandler(/^https?:\/\/(imgair\.net|imgfrost\.net|imgblaze\.net)(\/\w+)+/, callback => {
  146. unsafeWindow.wuLu && unsafeWindow.wuLu()
  147. const img = document.querySelector('#newImgE')
  148. if(img) {
  149. callback(img.src)
  150. }
  151. }, 3)
  152. addHandler(/^https?:\/\/hentai4free\.net(\/\w+)+/, callback => {
  153. unsafeWindow.wuLu && unsafeWindow.wuLu()
  154. const img = document.querySelector('#image-viewer-container>img')
  155. if(img) {
  156. callback(img.src)
  157. }
  158. })
  159.  
  160. const href = document.location.href
  161. if(/^https?:\/\/(sukebei\.nyaa\.si).+/g.test(href)) {
  162. if(document.title === '502 Bad Gateway') {
  163. document.location.href = document.location.href
  164. return
  165. }
  166. if(/^https?:\/\/(sukebei\.nyaa\.si\/view\/).+/g.test(href)) {
  167. const desc = document.querySelector('#torrent-description')
  168. const links = desc.querySelectorAll('a')
  169. if(!desc || !links) return
  170.  
  171. const list = []
  172. for(let i in links) {
  173. if(!links[i].href) continue
  174. handlers.filter(h=>h.type!==3).forEach(h=>{h.canHandle(links[i].href) && list.push(links[i].href)})
  175. }
  176.  
  177. let LMT_Wrap, LMT_Frame, LMT_Loading
  178. function createWrap() {
  179. desc.parentNode.insertAdjacentHTML('afterend', '<div class="panel panel-default"><div class="panel-body" id="LMT_Wrap"></div></div>')
  180. LMT_Wrap = document.querySelector('#LMT_Wrap')
  181.  
  182. LMT_Loading = document.createElement('div')
  183. LMT_Loading.textContent = 'Loading Images...'
  184. LMT_Wrap.appendChild(LMT_Loading)
  185.  
  186. LMT_Frame = document.createElement('iframe')
  187. LMT_Frame.id = 'LMT_Frame'
  188. LMT_Frame.sandbox = 'allow-forms allow-scripts allow-same-origin'
  189. LMT_Frame.style.display = 'none'
  190. LMT_Wrap.appendChild(LMT_Frame)
  191. }
  192.  
  193. function process() {
  194. if(list.length) {
  195. if(!LMT_Frame) createWrap()
  196. let url = list.pop()
  197.  
  198. LMT_Frame.src = url
  199. } else {
  200. if(LMT_Frame) {
  201. LMT_Wrap.removeChild(LMT_Frame)
  202. LMT_Wrap.removeChild(LMT_Loading)
  203. }
  204. }
  205. }
  206.  
  207. unsafeWindow.addEventListener('message', function (e) {
  208. if(e.data.LMT) {
  209. LMT_Frame.src = ''
  210. const img = document.createElement('img')
  211. img.src = e.data.LMT
  212. img.style['max-width'] = '100%'
  213. LMT_Wrap.appendChild(img)
  214. process()
  215. }
  216. })
  217.  
  218. process()
  219. }
  220. } else {
  221. handlers.filter(h=>h.type!==2).forEach(h=>{h.canHandle(href) && h.handle()})
  222. }
  223. })();