Nyaa.si - Load More Thumbnail

Load image from cover/screenshot links.

Устаревшая версия за 19.12.2021. Перейдите к последней версии.

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