BooruBear

Gathers tags from a few boorus

  1. // ==UserScript==
  2. // @name BooruBear
  3. // @namespace https://greasyfork.org/scripts/456125-boorubear/code/BooruBear.user.js
  4. // @version 0.6
  5. // @description Gathers tags from a few boorus
  6. // @author @Archgoddess_gd
  7. // @match https://danbooru.donmai.us/*
  8. // @match https://gelbooru.com/*
  9. // @match https://rule34.xxx/*
  10. // @match https://censored.booru.org/*
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. // Create the button and textarea elements
  16. var button = document.createElement("button");
  17. var textarea = document.createElement("textarea");
  18. var closeButton = document.createElement("button");
  19.  
  20. button.innerHTML = "Extract Tags";
  21. button.style.position = "fixed";
  22. button.style.bottom = "0";
  23. button.style.right = "0";
  24. button.style.backgroundColor = "black";
  25. button.style.color = "white";
  26.  
  27. textarea.style.position = "fixed";
  28. textarea.style.bottom = "0";
  29. textarea.style.right = "0";
  30. textarea.style.width = "400px";
  31. textarea.style.height = "200px";
  32. textarea.style.backgroundColor = "black";
  33. textarea.style.color = "white";
  34. textarea.style.display = "none";
  35.  
  36. closeButton.innerHTML = "Close";
  37. closeButton.style.position = "fixed";
  38. closeButton.style.bottom = "210px";
  39. closeButton.style.right = "0";
  40. closeButton.style.backgroundColor = "black";
  41. closeButton.style.color = "white";
  42. closeButton.style.display = "none";
  43.  
  44. // Add the button and textarea to the page
  45. document.body.appendChild(button);
  46. document.body.appendChild(textarea);
  47. document.body.appendChild(closeButton);
  48.  
  49. // Add a click event listener to the button
  50. button.addEventListener("click", function() {
  51. // Find all instances of "tags=" in the page
  52. var matches = document.body.innerHTML.match(/tags=([^&"]+)/g);
  53.  
  54. if (matches) {
  55. // For each match, extract the text after the "=" and before the next " or &
  56. for (var i = 0; i < matches.length; i++) {
  57. var tag = matches[i].split("=")[1];
  58.  
  59. // Replace "%3A" with ":", "%28" with "(", and "%29" with ")"
  60. tag = tag.replace(/%3A/g, ":").replace(/%28/g, "(").replace(/%29/g, ")").replace(/%27/g, "'").replace(/%21/g, "!").replace(/%3F/g, "?").replace(/%2B/g, "+");
  61.  
  62. // Exclude instances of "all" and tags that include "user:", "date:", or "status:"
  63. if (tag.toLowerCase() !== "all" && !tag.toLowerCase().includes("user:") && !tag.toLowerCase().includes("date:") && !tag.toLowerCase().includes("status:") && !tag.toLowerCase().includes("order:") && !tag.toLowerCase().includes("my_tags") && !tag.toLowerCase().includes("parent:") && !tag.toLowerCase().includes("+")) {
  64. // Append the tag to the textarea
  65. textarea.value += tag + " ";
  66. }
  67. }
  68. }
  69.  
  70. // Show the textarea and close button
  71. textarea.style.display = "block";
  72. closeButton.style.display = "block";
  73. });
  74.  
  75. // Add a click event listener to the close button
  76. closeButton.addEventListener("click", function() {
  77. // Hide the textarea and close button
  78. textarea.style.display = "none";
  79. closeButton.style.display = "none";
  80. });