Copy Prompt

danbooru.donmai.us—gelbooru.com—safebooru.org—yande.re—rule34.xxx—furry.booru.org—nozomi.la—www.zerochan.net(nozomi/zerochan不支持列表页面直接复制)

  1. // ==UserScript==
  2. // @name Copy Prompt
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1.7
  5. // @description danbooru.donmai.us—gelbooru.com—safebooru.org—yande.re—rule34.xxx—furry.booru.org—nozomi.la—www.zerochan.net(nozomi/zerochan不支持列表页面直接复制)
  6. // @author zuogangju
  7. // @match *://danbooru.donmai.us/*
  8. // @match *://gelbooru.com/*
  9. // @match *://safebooru.org/*
  10. // @match *://yande.re/*
  11. // @match *://rule34.xxx/*
  12. // @match *://furry.booru.org/*
  13. // @match *://nozomi.la/*
  14. // @match *://www.zerochan.net/*
  15. // @match *://safe.aibooru.online/*
  16. // @match *://aibooru.online/*
  17. // @match *://xbooru.com/*
  18. // @match *://konachan.com/*
  19. // @match *://konachan.net/*
  20. // @match *://furbooru.org/*
  21. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11.0.16/dist/sweetalert2.all.min.js
  22. // @resource customCSS https://cdn.jsdelivr.net/npm/sweetalert2@11.7.20/dist/sweetalert2.min.css
  23. // @grant GM_setClipboard
  24. // ==/UserScript==
  25.  
  26.  
  27. // 获取当前页面的URL
  28. const currentURL = window.location.href;
  29.  
  30. const myEvent="mousemove"
  31.  
  32.  
  33.  
  34.  
  35.  
  36. /*复制文本到剪切板并弹出复制成功*/
  37. function copyPrompt(tagsValue){
  38. console.log("prompt:")
  39. console.log(tagsValue)
  40. // 复制选中内容到剪贴板
  41. // navigator.clipboard.writeText(tagsValue)
  42. GM_setClipboard(tagsValue)
  43. Swal.fire({
  44. //position: 'top-end',
  45. icon: 'success',
  46. title: '复制成功',
  47. showConfirmButton: false,
  48. timer: 600
  49. })
  50. }
  51.  
  52.  
  53. function addEvent(selectors, qualifiedName) {
  54. // 选择所有图片元素
  55. let imageElements = document.querySelectorAll(selectors);
  56. // 遍历每个图片元素并添加鼠标移动监听事件
  57. imageElements.forEach(function (image) {
  58. image.addEventListener(myEvent, function (event) {
  59. if (event.ctrlKey) {
  60. // 获取data-tags属性的值
  61. const data = image.getAttribute(qualifiedName);
  62. copyPrompt(data.split(" ").join(","))
  63. }
  64. // 这里可以执行你想要的操作,例如显示在页面上等
  65. });
  66. });
  67. }
  68.  
  69. window.onload=function() {
  70. 'use strict';
  71. let selectors = '[data-tags]';
  72. let qualifiedName ="data-tags";
  73.  
  74. if(currentURL.includes("danbooru.donmai.us")
  75. ||currentURL.includes("aibooru.online")
  76. ||currentURL.includes("safe.aibooru.online")
  77. ||currentURL.includes("gelbooru.com")){
  78. addEvent(selectors, qualifiedName);
  79. }else if (currentURL.includes("www.zerochan.net")){
  80. selectors = "#content .preview img";
  81. qualifiedName ="alt";
  82. }else if (currentURL.includes("safebooru.org")){
  83. selectors = "#content img";
  84. qualifiedName ="alt";
  85. } else if (currentURL.includes("yande.re")
  86. ||currentURL.includes("rule34.xxx")
  87. ||currentURL.includes("xbooru.com")
  88. ||currentURL.includes("konachan.com")
  89. ||currentURL.includes("konachan.net")){
  90. selectors = "#image";
  91. qualifiedName ="alt";
  92. }else if (currentURL.includes("nozomi.la")){
  93. selectors = ".container img";
  94. qualifiedName ="alt";
  95. }else if (currentURL.includes("furbooru.org")){
  96. selectors = "[data-image-tag-aliases]";
  97. qualifiedName ="data-image-tag-aliases";
  98. }
  99.  
  100.  
  101.  
  102. addEvent(selectors, qualifiedName);
  103. };