Export Claude.Ai v1.1-miniaturized

Download the conversation with Claude; works now on small screens.

  1. // ==UserScript==
  2. // @name Export Claude.Ai v1.1-miniaturized
  3. // @description Download the conversation with Claude; works now on small screens.
  4. // @version 1.1-mini
  5. // @author TheAlanK & SAPIENT
  6. // @grant none
  7. // @match *://claude.ai/*
  8. // @namespace https://github.com/TheAlanK
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. function getTextByClass(className) {
  13. var elements = document.getElementsByClassName(className);
  14. var result = [];
  15.  
  16. for (var i = 0; i < elements.length; i++) {
  17. // Clone the node to not affect the original element
  18. var clone = elements[i].cloneNode(true);
  19.  
  20. // Remove all SVG and button elements
  21. var unwantedElements = clone.querySelectorAll('svg, button');
  22. for (var j = 0; j < unwantedElements.length; j++) {
  23. unwantedElements[j].remove();
  24. }
  25.  
  26. // Add cleaned text to the result
  27. result.push(clone.innerText.trim());
  28. }
  29.  
  30. return result.join("\n");
  31. }
  32.  
  33.  
  34. function addButton() {
  35. var button = document.createElement("button");
  36. button.innerHTML = `Export`;
  37. button.style.cssText = `
  38. position: fixed;
  39. bottom: 10px;
  40. right: 10px;
  41. padding: 2px 4px;
  42. background-color: #4CAF50; /* Green */
  43. border: none;
  44. color: white;
  45. text-align: center;
  46. text-decoration: none;
  47. display: inline-block;
  48. font-size: 11px;
  49. cursor: pointer;
  50. border-radius: 4px;
  51. z-index: 999;
  52. `;
  53.  
  54. button.addEventListener ("click", function() {
  55. var text = getTextByClass('col-start-2');
  56. var blob = new Blob([text], {type: "text/plain;charset=utf-8"});
  57. var url = URL.createObjectURL(blob);
  58.  
  59. var link = document.createElement("a");
  60. link.download = 'extracted.txt';
  61. link.href = url;
  62. link.click();
  63. });
  64.  
  65. document.body.appendChild(button);
  66. }
  67.  
  68. addButton();