diff --git a/src/lib/constants.ts b/src/lib/constants.ts index fd085e2..d3bbc5e 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -18,6 +18,7 @@ import Poe from 'providers/poe'; import InflectionPi from 'providers/inflection'; import StableChat from 'providers/stablechat'; import Falcon180BSpace from 'providers/falcon180bspace'; +import Google from 'providers/google'; export const allProviders = [ OpenAi, @@ -40,4 +41,5 @@ export const allProviders = [ LeptonLlama, Vercel, Smol, + Google, ]; diff --git a/src/providers/claude2.js b/src/providers/claude2.js index 0400705..41ccb02 100644 --- a/src/providers/claude2.js +++ b/src/providers/claude2.js @@ -74,7 +74,7 @@ class Claude2 extends Provider { } static getUserAgent() { - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'; + return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'; } static isEnabled() { diff --git a/src/providers/google.js b/src/providers/google.js new file mode 100644 index 0000000..de44fd4 --- /dev/null +++ b/src/providers/google.js @@ -0,0 +1,72 @@ +const Provider = require('./provider'); + +class Google extends Provider { + static webviewId = 'webviewGOOGLE'; + static fullName = 'Google Search'; + static shortName = 'Google'; + + static url = 'https://www.google.com/'; + + static handleInput(input) { + let webview = this.getWebview(); + input = JSON.stringify(input); + console.log(webview.getURL(), this.url); + if (!webview.getURL().startsWith(this.url)) { + webview.loadURL(this.url) + .catch(e => { + console.log(e); + }); + } + webview.executeJavaScript(` + var inputElement = document.querySelector('#tsf > div:nth-child(1) > div.A7Yvie.Epl37 > div.zGVn2e > div.SDkEP > div > textarea'); + inputElement.value = ${input}; + `) + } + + static handleSubmit() { + this.getWebview().executeJavaScript(` + { + document.querySelector("form").submit(); + }`) + } + + static handleCss() { + this.getWebview().addEventListener('dom-ready', () => { + this.getWebview().insertCSS(` + @media (max-width:320px){ + html,body{ + zoom:95%; + } + } + `); + }); + } + + static handleDarkMode(isDarkMode) { + // if (isDarkMode) { + // this.getWebview().insertCSS(` + // body { + // background-color: #1d1d1d !important; + // filter: invert(100%) hue-rotate(180deg); + // } + // `); + // } else { + // this.getWebview().insertCSS(` + // body { + // background-color: #ffffff !important; + // filter: none; + // } + // `); + // } + } + + static getUserAgent() { + return 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36 Edg/125.0.0.0'; + } + + static isEnabled() { + return window.electron.electronStore.get(`${this.webviewId}Enabled`, true); + } +} + +module.exports = Google; diff --git a/src/renderer/browserPane.tsx b/src/renderer/browserPane.tsx index d023961..533e9e6 100644 --- a/src/renderer/browserPane.tsx +++ b/src/renderer/browserPane.tsx @@ -80,7 +80,10 @@ export function BrowserPane({ {(provided2, snapshot) => ( -
+