Skip to content

Commit

Permalink
update the "need bowser" function, it can return code and table now
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeMiracle committed Feb 27, 2023
1 parent d533707 commit bc4cadb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ignorefile/
ignorefile/
revChatGPT-2.3.14/
27 changes: 18 additions & 9 deletions chatGPTQQbot/js/getReply.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var elements = document.evaluate("(//div[@class='markdown prose w-full break-words dark:prose-invert dark'])[last()]", document, null, XPathResult.ANY_TYPE, null);
var element = elements.iterateNext();
var childElements = element.querySelectorAll('p, pre, ol > li,table');
var output = "";

var toomany_elements = document.evaluate("(//div[@class='w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-50 dark:bg-[#444654]'])[last()]", document, null, XPathResult.ANY_TYPE, null);
Expand All @@ -11,16 +12,24 @@ try{
return "😫你发送的次数太多啦,一小时之后再来吧"
}
if (element) {
var children = element.children;
for (var i = 0; i < children.length; i++) {
if (children[i].tagName === "P") {
output += children[i].outerHTML + "\n";
} else if (children[i].tagName === "OL") {
var listItems = children[i].getElementsByTagName("li");
for (var j = 0; j < listItems.length; j++) {
output += listItems[j].outerHTML + "\n";
for (let i = 0; i < childElements.length; i++) {
if (childElements[i].tagName === 'TABLE') {
var trElements = childElements[i].querySelectorAll('tr');


for (let j = 0; j < trElements.length; j++) {
var thElements = trElements[j].querySelectorAll('th, td');
var thoutput = ""
for(let n = 0; n < thElements.length; n++){
thoutput += (thElements[n].textContent + "\t|\t").toString();
}
output += thoutput + "\n";
}
}
}

else {
output += childElements[i].textContent + "\n";
}
}
}
return output;
Expand Down

1 comment on commit bc4cadb

@OrangeMiracle
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1.1.4

Please sign in to comment.