Nyaa.si - Load More Thumbnail

Load image from cover/screenshot links.

La data de 05-11-2023. Vezi ultima versiune.

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