Nyaa.si - Load More Thumbnail

Load image from cover/screenshot links.

2023-05-20 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

  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.6
  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://xxxwebdlxxx.org/*
  29. // @match https://uvonahaze.xyz/*
  30. // @match https://trans.firm.in/*
  31. // @match https://imgdawgknuttz.com/*
  32. // @match https://imagetwist.netlify.app/*
  33. // @match https://imagetwist.com/*
  34. // @match https://imagexport.com/*
  35. // @match https://hentai4free.net/*
  36. // @match https://pixhost.to/*
  37. // @match https://imgair.net/*
  38. // @match http://imgair.net/*
  39. // @match http://imgfrost.net/*
  40. // @match http://imgblaze.net/*
  41. // @run-at document-end
  42. // @grant unsafeWindow
  43. // @grant GM_xmlhttpRequest
  44. // ==/UserScript==
  45.  
  46. (function() {
  47. 'use strict';
  48.  
  49. function Handler(pattern, process, processNyaa) {
  50. this.pattern = pattern
  51. this.process = process
  52. this.processNyaa = processNyaa
  53. }
  54. Handler.prototype.canHandle = function(url) {
  55. return this.pattern.test(url)
  56. }
  57. Handler.prototype.handle = function() {
  58. this.process(url => {
  59. document.location.href = url
  60. unsafeWindow.top.postMessage({"LMT": url}, '*')
  61. })
  62. }
  63. const handlers = []
  64. const addHandler = (pattern, process, processNyaa) => handlers.push(new Handler(pattern, process, processNyaa))
  65.  
  66. addHandler(/^https?:\/\/(imgrock\.pw)(\/[\w\-]+)+(\.[\w\-]+)+/, callback => {
  67. // pause on CAPTCHA
  68. const iframe = document.querySelector('iframe')
  69. if(iframe && iframe.src.indexOf('captcha') > -1) return
  70.  
  71. const img = document.querySelector('.picview')
  72. if(img) {
  73. callback(img.src)
  74. } else {
  75. const btns = document.querySelectorAll('input[name=fnext]')
  76. for(let i=0;i<btns.length;i++) {if(!btns[i].style.display) btns[i].click()}
  77. const forms = document.querySelectorAll('form')
  78. for(let i=0;i<forms.length;i++) {if(forms[i].hito) {forms[i].submit()}}
  79. }
  80. })
  81. addHandler(/^https?:\/\/(picrok\.com)(\/[\w\-]+)+\.php/, callback => {
  82. // pause on CAPTCHA
  83. const iframe = document.querySelector('iframe')
  84. if(iframe && iframe.src.indexOf('captcha') > -1) return
  85.  
  86. const img = document.querySelector('.picview')
  87. if(img) {
  88. callback(img.src)
  89. } else {
  90. unsafeWindow.setTimeout(() => {
  91. const forms = document.querySelectorAll('form')
  92. const btns = document.querySelectorAll('form>button')
  93. // for(let i=0;i<btns.length;i++) {if(btns[i].style.display) forms[i-1].submit()}
  94. }, 5000)
  95. }
  96. })
  97. 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 => {
  98. const img = document.querySelector('.pic')
  99. if(img) {
  100. callback(img.src)
  101. } else {
  102. const form = document.querySelector('form')
  103. form && form.submit()
  104. }
  105. })
  106. addHandler(/^https?:\/\/(imgtaxi\.com|imgadult\.com|imgdrive\.net)(\/\w+)+/, callback => {
  107. unsafeWindow.ctipops = []
  108. unsafeWindow.adbctipops = []
  109. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  110. if(img) {
  111. callback(img.src)
  112. } else {
  113. unsafeWindow.setTimeout(() => {
  114. const btn = document.querySelector('.overlay_ad_link')
  115. if(btn) {
  116. btn.focus()
  117. btn.click()
  118. }
  119. }, 1000)
  120. }
  121. }, url => {
  122. GM_xmlhttpRequest({
  123. method: 'GET',
  124. url: url,
  125. onload: res => {
  126. const src = res.responseText.match(/og:image:secure_url" content="(.*)"/)
  127. if(src.length > 1) window.postMessage({"LMT": src[1].replace('small','big')}, '*')
  128. }
  129. });
  130. })
  131. addHandler(/^https?:\/\/(xxxwebdlxxx\.org)(\/\w+)+/, callback => {
  132. unsafeWindow.ctipops = []
  133. unsafeWindow.adbctipops = []
  134. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  135. if(img) {
  136. callback(img.src)
  137. } else {
  138. unsafeWindow.setTimeout(() => {
  139. const btn = document.querySelector('.overlay_ad_link')
  140. if(btn) {
  141. btn.focus()
  142. btn.click()
  143. }
  144. }, 1000)
  145. }
  146. })
  147. addHandler(/^https?:\/\/(uvonahaze\.xyz|trans\.firm\.in||imgdawgknuttz\.com)(\/\w+)+/, callback => {
  148. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  149. if(img) {
  150. callback(img.src)
  151. } else {
  152. const btn = document.querySelector('input[name=imgContinue]')
  153. btn && btn.click()
  154. }
  155. })
  156. addHandler(/^https?:\/\/(imagetwist\.netlify\.app)(\/\w+)+/, callback => {
  157. if(unsafeWindow.targetURL) document.location.href = unsafeWindow.targetURL
  158. })
  159. addHandler(/^https?:\/\/(imagetwist\.com|imagexport\.com)(\/\w+)+/, callback => {
  160. const img = document.querySelector('.img-responsive')
  161. if(img) {
  162. callback(img.src)
  163. }
  164. })
  165. addHandler(/^https?:\/\/hentai4free\.net(\/\w+)+/, callback => {
  166. unsafeWindow.wuLu && unsafeWindow.wuLu()
  167. const img = document.querySelector('#image-viewer-container>img')
  168. if(img) {
  169. callback(img.src)
  170. }
  171. })
  172. addHandler(/^https?:\/\/pixhost\.to(\/\w+)+/, callback => {
  173. const img = document.querySelector('img.image-img')
  174. if(img) {
  175. callback(img.src)
  176. } else {
  177. const btn = document.querySelector('a.continue')
  178. btn && btn.click()
  179. }
  180. })
  181. addHandler(/^https?:\/\/(imgair\.net|imgfrost\.net|imgblaze\.net)(\/\w+)+/, callback => {
  182. unsafeWindow.wuLu && unsafeWindow.wuLu()
  183. const img = document.querySelector('#newImgE')
  184. if(img) {
  185. callback(img.src)
  186. }
  187. }, url => {
  188. GM_xmlhttpRequest({
  189. method: 'GET',
  190. url: url.replace(/^https?:\/\/(imgfrost\.net|imgblaze\.net)/, 'https://imgair.net'),
  191. onload: res => {
  192. const src = res.responseText.match(/document\.getElementById\("newImgE"\)\.src = "(.*)"/)
  193. if(src.length > 1) window.postMessage({"LMT": src[1]}, '*')
  194. }
  195. });
  196. })
  197.  
  198. const href = document.location.href
  199. if(/^https?:\/\/(sukebei\.nyaa\.si).+/g.test(href)) {
  200. if(document.title === '502 Bad Gateway') {
  201. document.location.href = document.location.href
  202. return
  203. }
  204. if(/^https?:\/\/(sukebei\.nyaa\.si\/view\/).+/g.test(href)) {
  205. const desc = document.querySelector('#torrent-description')
  206. const links = desc.querySelectorAll('a')
  207. if(!desc || !links) return
  208.  
  209. const list = []
  210. for(let i in links) {
  211. if(!links[i].href) continue
  212. handlers.forEach(h=>{h.canHandle(links[i].href) && list.push({href:links[i].href,handler:h})})
  213. }
  214.  
  215. let LMT_Wrap, LMT_Frame, LMT_Loading
  216. function createWrap() {
  217. desc.parentNode.insertAdjacentHTML('afterend', '<div class="panel panel-default"><div class="panel-body" id="LMT_Wrap"></div></div>')
  218. LMT_Wrap = document.querySelector('#LMT_Wrap')
  219.  
  220. LMT_Loading = document.createElement('div')
  221. LMT_Loading.textContent = 'Loading Images...'
  222. LMT_Wrap.appendChild(LMT_Loading)
  223.  
  224. LMT_Frame = document.createElement('iframe')
  225. LMT_Frame.id = 'LMT_Frame'
  226. LMT_Frame.sandbox = 'allow-forms allow-scripts allow-same-origin'
  227. LMT_Frame.style.display = 'none'
  228. LMT_Wrap.appendChild(LMT_Frame)
  229. }
  230.  
  231. function process() {
  232. if(list.length) {
  233. if(!LMT_Frame) createWrap()
  234. let url = list.shift()
  235. if(url.handler.processNyaa) {
  236. url.handler.processNyaa(url.href)
  237. } else {
  238. LMT_Frame.src = url.href
  239. }
  240. } else {
  241. if(LMT_Frame) {
  242. LMT_Wrap.removeChild(LMT_Frame)
  243. LMT_Wrap.removeChild(LMT_Loading)
  244. }
  245. }
  246. }
  247.  
  248. unsafeWindow.addEventListener('message', function (e) {
  249. if(e.data.LMT) {
  250. LMT_Frame.src = ''
  251. const img = document.createElement('img')
  252. img.src = e.data.LMT
  253. img.style['max-width'] = '100%'
  254. LMT_Wrap.appendChild(img)
  255. process()
  256. }
  257. })
  258.  
  259. process()
  260. }
  261. } else {
  262. handlers.forEach(h=>{h.canHandle(href) && h.handle()})
  263. }
  264. })();