This repository has been archived by the owner on Jun 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 修复引用分行的问题 - 重构项目 - 修改部分文档
- Loading branch information
gantrol
committed
Feb 15, 2023
1 parent
f8a8c79
commit 03dbd4a
Showing
7 changed files
with
255 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
export class Page { | ||
|
||
static getWhole = () => { | ||
return document | ||
.querySelector("#b_sydConvCont > cib-serp") | ||
.shadowRoot; | ||
}; | ||
|
||
static getMain = () => { | ||
return <HTMLElement>Page.getWhole() | ||
.querySelector("#cib-conversation-main") | ||
.shadowRoot | ||
.querySelector("#cib-chat-main"); | ||
}; | ||
|
||
static getWelcome = () => { | ||
return Page.getMain() | ||
.querySelector("cib-welcome-container"); | ||
}; | ||
|
||
static getQAsElement = () => { | ||
return Page.getMain() | ||
.querySelectorAll("cib-chat-turn"); | ||
}; | ||
|
||
static setFontWeightForAllRefs = () => { | ||
const groups_roots = Page.getQAsElement(); | ||
for (const groups_root of groups_roots) { | ||
for (let group of groups_root.shadowRoot.querySelectorAll("cib-message-group")) { | ||
console.log(`setFontWeightForAllRefs: ${group}`); | ||
// check user or bot | ||
if (group.getAttribute("source") === "bot") { | ||
// Answer | ||
const messagesShadowRoot = group.shadowRoot; | ||
const ansFrame = messagesShadowRoot.querySelector("cib-message[type=\"text\"]"); | ||
const refsBlock = ansFrame | ||
.shadowRoot | ||
.querySelector("cib-message-attributions"); | ||
if (refsBlock) { | ||
const refsElement = refsBlock.shadowRoot.querySelector("div[role=\"list\"]"); | ||
const linkElementList = Array.from(refsElement.querySelectorAll("a")); | ||
linkElementList.map(linkElm => { | ||
linkElm.style.fontWeight = "400"; | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
static getFeedbackBar = () => { | ||
return Page.getWhole() | ||
.querySelector("cib-serp-feedback") | ||
.shadowRoot | ||
.querySelector("div.root"); | ||
}; | ||
|
||
static waitForElm = (selector) => { | ||
return new Promise(resolve => { | ||
if (document.querySelector(selector)) { | ||
return resolve(document.querySelector(selector)); | ||
} | ||
|
||
const observer = new MutationObserver(mutations => { | ||
if (document.querySelector(selector)) { | ||
resolve(document.querySelector(selector)); | ||
observer.disconnect(); | ||
} | ||
}); | ||
|
||
observer.observe(document.body, { | ||
childList: true, | ||
subtree: true | ||
}); | ||
}); | ||
}; | ||
} | ||
|
Oops, something went wrong.