Sleazy Fork is available in English.

色华堂列表显示预览图

色华堂列表显示预览图,无需点进详情页查看

  1. // ==UserScript==
  2. // @name 色华堂列表显示预览图
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.1
  5. // @description 色华堂列表显示预览图,无需点进详情页查看
  6. // @author meteora
  7. // @match https://sehuatang.net/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=sehuatang.net
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. ;(() => {
  14. const domList = document.querySelectorAll(
  15. "#threadlisttableid > [id^='normalthread']"
  16. )
  17. if (!domList) return
  18. for (const item of domList) {
  19. //获取元素里面的预览图片的地址
  20. const aDom = item.querySelector("tr th .xst")
  21. const pageUrl = aDom.href
  22. fetch(pageUrl).then(async (res) => {
  23. let appendDom = ""
  24. const responseText = await res.text()
  25. //检索里面的磁力链接
  26. const magnetLink = responseText.match(
  27. /magnet:\?xt=urn:btih:[0-9a-zA-Z]*/
  28. )[0]
  29. appendDom += `<div style="width:800px; padding:10px 0; cursor: pointer" id="${magnetLink}">${magnetLink}</div>`
  30. //通过响应的网页代码构造出一颗dom树以选取里面的元素
  31. const dom = document.createElement("div")
  32. dom.innerHTML = responseText
  33. //预览图片
  34. const imgDom = dom.querySelector(".zoom:nth-child(1)")
  35. if (!imgDom) return
  36. let imageSrc = imgDom.getAttribute("zoomfile")
  37. if (!imageSrc) {
  38. imageSrc = imgDom.getAttribute("file")
  39. }
  40. appendDom += `<div style=""><img src="${imageSrc}" style="max-height: 300px"/></div>`
  41. //在下面插入一个元素
  42. const newElement = document.createElement("tbody")
  43. newElement.innerHTML = appendDom
  44. item.insertAdjacentElement("afterend", newElement)
  45. //添加点击事件
  46. const magnetLinkDom = document.getElementById(magnetLink)
  47. magnetLinkDom.addEventListener("click", (event) => {
  48. const inputDom = document.createElement("input")
  49. inputDom.value = magnetLink
  50. document.body.appendChild(inputDom)
  51. inputDom.select()
  52. document.execCommand("copy")
  53. document.body.removeChild(inputDom)
  54. event.target.innerText = magnetLink + " 已复制"
  55. event.target.style.color = "darkred"
  56. })
  57. })
  58. }
  59. })()