-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: swyxio <swyxio@users.noreply.github.com>
- Loading branch information
Showing
24 changed files
with
141 additions
and
83 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
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
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
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
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,50 @@ | ||
const Provider = require('./provider'); | ||
|
||
class YouChat extends Provider { | ||
static webviewId = 'webviewYoudotcom'; | ||
static fullName = 'You.com Chat'; | ||
static shortName = 'You.com'; | ||
|
||
static url = 'https://you.com/chat/'; | ||
|
||
static handleInput(input) { | ||
const fullName = this.fullName; | ||
this.getWebview().executeJavaScript(`{ | ||
var inputElement = document.querySelector('textarea[placeholder*="Ask me anything..."]'); // can be "Ask anything" or "Ask follow-up" | ||
if (!inputElement) { | ||
console.error('inputElement for ${fullName} doesnt exist, have you logged in or are you on the right page?') | ||
} else { | ||
var nativeTextAreaValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set; | ||
nativeTextAreaValueSetter.call(inputElement, \`${input}\`); | ||
var event = new Event('input', { bubbles: true}); | ||
inputElement.dispatchEvent(event); | ||
} | ||
}`); | ||
} | ||
|
||
static handleSubmit() { | ||
this.getWebview().executeJavaScript(`{ | ||
var buttons = Array.from(document.querySelectorAll('button[type="submit"]')); | ||
buttons[0].click(); | ||
}`); | ||
} | ||
static handleCss() { | ||
// this.getWebview().addEventListener('dom-ready', () => { | ||
// // Hide the "Try asking" segment | ||
// setTimeout(() => { | ||
// this.getWebview().insertCSS(` | ||
// .mt-lg { | ||
// display: none; | ||
// } | ||
// `); | ||
// }, 100); | ||
// }); | ||
} | ||
|
||
static isEnabled() { | ||
return window.electron.electronStore.get(`${this.webviewId}Enabled`, false); | ||
} | ||
} | ||
|
||
module.exports = YouChat; |
Oops, something went wrong.