Nyaa.si - Load More Thumbnail

Load image from cover/screenshot links.

Από την 29/11/2023. Δείτε την τελευταία έκδοση.

  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. // @icon https://www.google.com/s2/favicons?sz=64&domain=sukebei.nyaa.si
  8. // @version 0.8.5
  9. // @license MIT
  10. // @author York Wang
  11. // @match https://sukebei.nyaa.si/*
  12. // @match https://pics.dmm.co.jp/*
  13. // @match https://xpic.org/*
  14. // @match https://imgrock.pw/*
  15. // @match https://picrok.com/*
  16. // @match https://picbaron.com/*
  17. // @match https://imgbaron.com/*
  18. // @match https://kvador.com/*
  19. // @match https://kropic.com/*
  20. // @match https://imgsto.com/*
  21. // @match https://imgsen.com/*
  22. // @match https://imgstar.eu/*
  23. // @match https://picdollar.com/*
  24. // @match https://pics4you.net/*
  25. // @match https://silverpic.com/*
  26. // @match https://fotokiz.com/*
  27. // @match https://premalo.com/*
  28. // @match https://piczhq.com/*
  29. // @match https://trypicz.com/*
  30. // @match http://imglord.com/*
  31. // @match https://croea.com/*
  32. // @match https://imgtaxi.com/*
  33. // @match https://imgadult.com/*
  34. // @match https://imgdrive.net/*
  35. // @match https://xxxwebdlxxx.org/*
  36. // @match https://uvonahaze.xyz/*
  37. // @match https://trans.firm.in/*
  38. // @match https://imgdawgknuttz.com/*
  39. // @match https://imagetwist.netlify.app/*
  40. // @match https://imagetwist.com/*
  41. // @match https://imagexport.com/*
  42. // @match https://hentai4free.net/*
  43. // @match https://pixhost.to/*
  44. // @match https://imgair.net/*
  45. // @match http://imgair.net/*
  46. // @match http://imgfrost.net/*
  47. // @match http://imgblaze.net/*
  48. // @match https://pig69.com/*
  49. // @match https://ai18.pics/*
  50. // @match https://porn4f.com/*
  51. // @match https://javball.com/*
  52. // @match https://ovabee.com/*
  53. // @match https://idol69.net/*
  54. // @match https://cnpics.org/*
  55. // @match https://cnxx.me/*
  56. // @run-at document-end
  57. // @grant unsafeWindow
  58. // @grant GM_xmlhttpRequest
  59. // ==/UserScript==
  60.  
  61. (function() {
  62. 'use strict';
  63.  
  64. function Handler(pattern, process, processNyaa) {
  65. this.pattern = pattern
  66. this.process = process
  67. this.processNyaa = processNyaa
  68. }
  69. Handler.prototype.canHandle = function(url) {
  70. return this.pattern.test(url)
  71. }
  72. Handler.prototype.handle = function() {
  73. this.process(url => {
  74. document.location.href = url
  75. unsafeWindow.top.postMessage({"LMT": url}, '*')
  76. })
  77. }
  78. const handlers = []
  79. const addHandler = (pattern, process, processNyaa) => handlers.push(new Handler(pattern, process, processNyaa))
  80.  
  81. addHandler(/^https?:\/\/pics\.dmm\.co\.jp(\/[\w]+)+\.jpg.*/, callback => {
  82. callback(document.location.href.match(/^https?:\/\/pics\.dmm\.co\.jp(\/[\w]+)+\.jpg/)[0])
  83. })
  84. addHandler(/^https?:\/\/xpic\.org(\/\w+)+/, callback => {
  85. unsafeWindow.wuLu && unsafeWindow.wuLu()
  86. const img = document.querySelector('img.attachment-original.size-original')
  87. if(img) {
  88. callback(img.src)
  89. }
  90. }, url => {
  91. GM_xmlhttpRequest({
  92. method: 'GET',
  93. url: url,
  94. onload: res => {
  95. const src = res.responseText.match(/src="(.*)" class="attachment-original size-original"/)
  96. if(src.length > 1) window.postMessage({"LMT": src[1]}, '*')
  97. }
  98. })
  99. })
  100. addHandler(/^https?:\/\/(imgrock\.pw)(\/[\w\-]+)+(\.[\w\-]+)+/, callback => {
  101. // pause on CAPTCHA
  102. const iframe = document.querySelector('iframe')
  103. if(iframe && iframe.src.indexOf('captcha') > -1) return
  104.  
  105. const img = document.querySelector('.picview')
  106. if(img) {
  107. callback(img.src)
  108. } else {
  109. const btns = document.querySelectorAll('input[name=fnext]')
  110. for(let i=0;i<btns.length;i++) {if(!btns[i].style.display) btns[i].click()}
  111. const forms = document.querySelectorAll('form')
  112. for(let i=0;i<forms.length;i++) {if(forms[i].hito) {forms[i].submit()}}
  113. }
  114. })
  115. addHandler(/^https?:\/\/(picrok\.com)(\/[\w\-]+)+\.php/, callback => {
  116. // pause on CAPTCHA
  117. const iframe = document.querySelector('iframe')
  118. if(iframe && iframe.src.indexOf('captcha') > -1) return
  119.  
  120. const img = document.querySelector('.picview')
  121. if(img) {
  122. callback(img.src)
  123. } else {
  124. unsafeWindow.setTimeout(() => {
  125. const forms = document.querySelectorAll('form')
  126. const btns = document.querySelectorAll('form>button')
  127. // for(let i=0;i<btns.length;i++) {if(btns[i].style.display) forms[i-1].submit()}
  128. }, 5000)
  129. }
  130. })
  131. addHandler(/^https?:\/\/(picbaron\.com|imgbaron\.com|kvador\.com|kropic\.com|imgsto\.com|imgsen\.com|imgstar\.eu|picdollar\.com|pics4you\.net|silverpic\.com|fotokiz\.com|premalo\.com|piczhq\.com|trypicz\.com|imglord\.com)(\/.+)+(\.[\w\-]+)+/, callback => {
  132. const img = document.querySelector('.pic')
  133. if(img) {
  134. callback(img.src)
  135. } else {
  136. const form = document.querySelector('form')
  137. form && form.submit()
  138. }
  139. })
  140. addHandler(/^https?:\/\/(croea\.com)(\/\w+)+/, callback => {
  141. const img = document.querySelector('.pic')
  142. if(img) {
  143. callback(img.src)
  144. } else {
  145. const form = document.querySelector('form')
  146. form && form.submit()
  147. }
  148. }, url => {
  149. GM_xmlhttpRequest({
  150. method: 'GET',
  151. url: url,
  152. onload: res => {
  153. const src = res.responseText.match(/src="(.*)" class="pic img img-responsive"/)
  154. if(src.length > 1) {
  155. GM_xmlhttpRequest({
  156. method: 'GET',
  157. responseType: "blob",
  158. url: src[1],
  159. onload: res => {
  160. const reader = new FileReader()
  161. reader.onload = () => {
  162. window.postMessage({"LMT": reader.result}, '*')
  163. }
  164. reader.readAsDataURL(res.response)
  165. }
  166. })
  167. }
  168. }
  169. })
  170. })
  171. addHandler(/^https?:\/\/(imgtaxi\.com|imgadult\.com|imgdrive\.net)(\/\w+)+/, callback => {
  172. unsafeWindow.ctipops = []
  173. unsafeWindow.adbctipops = []
  174. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  175. if(img) {
  176. callback(img.src)
  177. } else {
  178. unsafeWindow.setTimeout(() => {
  179. const btn = document.querySelector('.overlay_ad_link')
  180. if(btn) {
  181. btn.focus()
  182. btn.click()
  183. }
  184. }, 1000)
  185. }
  186. }, url => {
  187. GM_xmlhttpRequest({
  188. method: 'GET',
  189. url: url,
  190. onload: res => {
  191. const src = res.responseText.match(/og:image:secure_url" content="(.*)"/)
  192. if(src.length > 1) window.postMessage({"LMT": src[1].replace('small','big')}, '*')
  193. }
  194. })
  195. })
  196. addHandler(/^https?:\/\/(xxxwebdlxxx\.org)(\/\w+)+/, callback => {
  197. unsafeWindow.ctipops = []
  198. unsafeWindow.adbctipops = []
  199. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  200. if(img) {
  201. callback(img.src)
  202. } else {
  203. unsafeWindow.setTimeout(() => {
  204. const btn = document.querySelector('.overlay_ad_link')
  205. if(btn) {
  206. btn.focus()
  207. btn.click()
  208. }
  209. }, 1000)
  210. }
  211. })
  212. addHandler(/^https?:\/\/(uvonahaze\.xyz|trans\.firm\.in||imgdawgknuttz\.com)(\/\w+)+/, callback => {
  213. const img = document.querySelector('img.centred') || document.querySelector('img.centred_resized')
  214. if(img) {
  215. callback(img.src)
  216. } else {
  217. const btn = document.querySelector('input[name=imgContinue]')
  218. btn && btn.click()
  219. }
  220. })
  221. addHandler(/^https?:\/\/(imagetwist\.netlify\.app)(\/\w+)+/, callback => {
  222. if(unsafeWindow.targetURL) document.location.href = unsafeWindow.targetURL
  223. const btn = document.querySelector('a.btn')
  224. btn && btn.click()
  225. })
  226. addHandler(/^https?:\/\/(imagetwist\.com|imagexport\.com)(\/\w+)+/, callback => {
  227. const img = document.querySelector('.img-responsive')
  228. if(img) {
  229. callback(img.src)
  230. }
  231. })
  232. addHandler(/^https?:\/\/hentai4free\.net(\/\w+)+/, callback => {
  233. unsafeWindow.wuLu && unsafeWindow.wuLu()
  234. const img = document.querySelector('#image-viewer-container>img')
  235. if(img) {
  236. callback(img.src)
  237. }
  238. })
  239. addHandler(/^https?:\/\/pixhost\.to(\/\w+)+/, callback => {
  240. const img = document.querySelector('img.image-img')
  241. if(img) {
  242. callback(img.src)
  243. } else {
  244. const btn = document.querySelector('a.continue')
  245. btn && btn.click()
  246. }
  247. })
  248. addHandler(/^https?:\/\/(imgair\.net|imgfrost\.net|imgblaze\.net)(\/\w+)+/, callback => {
  249. unsafeWindow.wuLu && unsafeWindow.wuLu()
  250. const img = document.querySelector('#newImgE')
  251. if(img) {
  252. callback(img.src)
  253. }
  254. }, url => {
  255. GM_xmlhttpRequest({
  256. method: 'GET',
  257. url: url.replace(/^https?:\/\/(imgfrost\.net|imgblaze\.net)/, 'https://imgair.net'),
  258. onload: res => {
  259. const src = res.responseText.match(/document\.getElementById\("newImgE"\)\.src = "(.*)"/)
  260. if(src.length > 1) window.postMessage({"LMT": src[1]}, '*')
  261. }
  262. })
  263. })
  264. addHandler(/^https?:\/\/(pig69\.com|ai18\.pics|porn4f\.com|javball\.com|ovabee\.com|idol69\.net|cnpics\.org|cnxx\.me)(\/\w+)+/, callback => {
  265. const img = document.querySelector('#fileOriginalModal img')
  266. if(img) {
  267. callback(img.src)
  268. } else {
  269. const btn = document.querySelector('a.continue')
  270. btn && btn.click()
  271. }
  272. }, url => {
  273. GM_xmlhttpRequest({
  274. method: 'GET',
  275. url: url,
  276. onload: res => {
  277. const src = res.responseText.match(/"https?:\/\/((pig69\.com|ai18\.pics|porn4f\.com|javball\.com|ovabee\.com|idol69\.net|cnpics\.org|cnxx\.me)\/upload\/Application\/storage\/app\/public\/uploads\/users\/.*)"/)
  278. if(src.length > 1) window.postMessage({"LMT": "http://"+src[1]}, '*')
  279. }
  280. })
  281. })
  282.  
  283. const href = document.location.href
  284. if(/^https?:\/\/(sukebei\.nyaa\.si).+/g.test(href)) {
  285. if(document.title === '502 Bad Gateway') {
  286. document.location.href = document.location.href
  287. return
  288. }
  289. if(/^https?:\/\/(sukebei\.nyaa\.si\/view\/).+/g.test(href)) {
  290. const desc = document.querySelector('#torrent-description')
  291. const links = desc.querySelectorAll('a')
  292. if(!desc || !links) return
  293.  
  294. const list = []
  295. for(let i in links) {
  296. if(!links[i].href) continue
  297. handlers.forEach(h=>{h.canHandle(links[i].href) && list.push({href:links[i].href,handler:h})})
  298. }
  299.  
  300. let LMT_Wrap, LMT_Frame, LMT_Loading
  301. function createWrap() {
  302. desc.parentNode.insertAdjacentHTML('afterend', '<div class="panel panel-default"><div class="panel-body" id="LMT_Wrap"></div></div>')
  303. LMT_Wrap = document.querySelector('#LMT_Wrap')
  304.  
  305. LMT_Loading = document.createElement('div')
  306. LMT_Loading.textContent = 'Loading Images...'
  307. LMT_Wrap.appendChild(LMT_Loading)
  308.  
  309. LMT_Frame = document.createElement('iframe')
  310. LMT_Frame.id = 'LMT_Frame'
  311. LMT_Frame.sandbox = 'allow-forms allow-scripts allow-same-origin'
  312. LMT_Frame.style.display = 'none'
  313. LMT_Wrap.appendChild(LMT_Frame)
  314. }
  315.  
  316. function process() {
  317. if(list.length) {
  318. if(!LMT_Frame) createWrap()
  319. let url = list.shift()
  320. if(url.handler.processNyaa) {
  321. url.handler.processNyaa(url.href)
  322. } else {
  323. LMT_Frame.src = url.href
  324. }
  325. } else {
  326. if(LMT_Frame) {
  327. LMT_Wrap.removeChild(LMT_Frame)
  328. LMT_Wrap.removeChild(LMT_Loading)
  329. }
  330. }
  331. }
  332.  
  333. unsafeWindow.addEventListener('message', function (e) {
  334. if(e.data.LMT) {
  335. LMT_Frame.src = ''
  336. const img = document.createElement('img')
  337. img.src = e.data.LMT
  338. img.style['max-width'] = '100%'
  339. LMT_Wrap.appendChild(img)
  340. process()
  341. }
  342. })
  343.  
  344. process()
  345. }
  346. } else {
  347. handlers.forEach(h=>{h.canHandle(href) && h.handle()})
  348. }
  349. })();