Sleazy Fork is available in English.

ehx torrent text

copy text in torrent page

  1. // ==UserScript==
  2. // @name ehx torrent text
  3. // @namespace https://github.com/x94fujo6rpg/SomeTampermonkeyScripts
  4. // @version 0.27
  5. // @description copy text in torrent page
  6. // @author x94fujo6
  7. // @match https://exhentai.org/*
  8. // @match https://e-hentai.org/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14. let autoclose = true;
  15. let m = "[ehx torrent text]: ";
  16. window.onload = function () {
  17. window.document.body.onload = main();
  18. };
  19.  
  20. function main() {
  21. let link = document.location.href;
  22. if (link.indexOf("gallerytorrents.php") === -1) return console.log(`${m}not torrent page, abort ${link}`);
  23. if (link.indexOf("//exhentai") === -1 && link.indexOf("//e-hentai") === -1) return console.log(`${m}incorrect site ${link}`);
  24.  
  25. let t = document.querySelectorAll("a[href$='.torrent']");
  26. if (t) {
  27. t.forEach(e => {
  28. let text = e.textContent;
  29. let tr = creatnewline(text, "Copy Name");
  30. let pos = e.parentElement.parentElement.parentElement;
  31. pos.appendChild(tr);
  32.  
  33. if (text.indexOf("(") === 0) {
  34. let end = text.indexOf(")") + 1;
  35. text = text.substring(0, end) + " ";
  36. tr = creatnewline(text, "Copy Event");
  37. pos.appendChild(tr);
  38. }
  39. });
  40. }
  41. }
  42.  
  43. function creatnewline(text, copy_text) {
  44. let tr = document.createElement("tr");
  45. let td = document.createElement("td");
  46. let s = document.createElement("span");
  47. s.textContent = text;
  48. td.colSpan = 5;
  49. td.appendChild(s);
  50. tr.appendChild(td);
  51. let e = document.createElement("a");
  52. e.textContent = copy_text;
  53. e.style = "width: max-content;";
  54. e.onclick = function () {
  55. navigator.clipboard.writeText(text).then(
  56. function () {
  57. console.log("done");
  58. if (autoclose) window.close();
  59. }, function () {
  60. console.log("failed");
  61. });
  62. };
  63. td = document.createElement("td");
  64. td.rowSpan = 1;
  65. td.style = "width:100px; text-align:center; border-style: outset; height: 1.5rem;";
  66. td.appendChild(e);
  67. tr.appendChild(td);
  68. return tr;
  69. }
  70. })();