Guest User

Untitled

a guest
Dec 6th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getVisibleText(node, skipOlderText, skipNewText, skipMenuText)
  2. {
  3.     var text = "";
  4.    
  5.     if (node.classList)
  6.     {
  7.         if (node.classList.contains("fa")) return "";
  8.         if (node.classList.contains("fa-stack")) return "";
  9.         if (node.classList.contains("deco-font")) return "";
  10.         if (skipOlderText && node.classList.contains("current")) return "";
  11.         if (skipOlderText && node.classList.contains("old")) return "";
  12.         if (skipOlderText && node.classList.contains("veryold")) return "";
  13.         if (skipNewText && node.classList.contains("newest")) return "";
  14.         if (skipMenuText && node.classList.contains("trans")) return "";
  15.     }
  16.    
  17.     if (node.nodeName.toLowerCase() == "br") return "\n";
  18.    
  19.     if (node.nodeType === Node.TEXT_NODE) return node.textContent.replace(/\n/g, "");
  20.    
  21.     var style = getComputedStyle(node);
  22.     if (style && style.display === "none") return "";
  23.    
  24.     for (var i=0; node.childNodes.length > i; i++)
  25.         text += getVisibleText(node.childNodes[i], skipOlderText, skipNewText, skipMenuText);
  26.    
  27.     text = text.replace(/\n\n+/g, "\n\n").replace(/  +/g, " ").replace(/\n /g, "\n");
  28.    
  29.     if (node.classList.contains("tooltiptext") ||
  30.         node.classList.contains("tooltiptext-small") ||
  31.         node.classList.contains("tooltiptext-large") ||
  32.         node.classList.contains("tooltiptext-corner"))
  33.             text = "[TOOLTIP: " + text + "]";
  34.    
  35.     return text;
  36. }
  37.  
  38. function getText(skipOlderText, skipNewText, skipMenuText)
  39. {
  40.     return getVisibleText(document.body, skipOlderText, skipNewText, skipMenuText);
  41. }
  42.  
  43. function getAllText()
  44. {
  45.     return getText(false, false, true);
  46. }
  47. function getNewText()
  48. {
  49.     return getText(true, false, true);
  50. }
  51. function getMenuText()
  52. {
  53.     return getText(true, true, false);
  54. }
  55.  
  56. var ESOTERIC_PASTE_TARGET = undefined;
  57. function setPasteTarget(node)
  58. {
  59.     ESOTERIC_PASTE_TARGET = node;
  60. }
  61. function pasteText(text)
  62. {
  63.     if (ESOTERIC_PASTE_TARGET)
  64.         ESOTERIC_PASTE_TARGET.value += text;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment