New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for most search engines #31
Conversation
Wow thanks, I'll take a look tomorrow |
src/content-script/index.mjs
Outdated
import Browser from 'webextension-polyfill' | ||
import {getPossibleElementByClassArray, getPossibleElementByIdArray, getPossibleElementByNameArray} from './utils.mjs' | ||
|
||
const config = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing it this way which will get messy and harder to maintain. Having a configuration for each search engine then it will be a single lookup instead doing it for all arrays. Easier to maintain if we split this up per search engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing it this way which will get messy and harder to maintain. Having a configuration for each search engine then it will be a single lookup instead doing it for all arrays. Easier to maintain if we split this up per search engine.
agree with you, this is a 'just work' version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better!
This is a review generated by ChatGPT 🤩: This pull request appears to add support for multiple search engines to a browser extension that displays ChatGPT responses alongside search results. The extension currently only supports Google, but this pull request aims to add support for Bing, Yahoo, DuckDuckGo, StartPage, Baidu, Kagi, Yandex, Naver, Brave, Searx, and Ecosia. One potential problem with this pull request is that it hardcodes the input element names for search boxes into the To fix this issue, I would suggest using a more flexible approach for identifying search box input elements. One way to do this would be to use the Another potential problem with this pull request is that it adds a large number of new configuration options to the Overall, I think this pull request has the potential to add useful functionality to the extension, but it would benefit from some changes to improve its flexibility and readability. |
@kxxt That's cool |
@wong2 are you currently working on this PR? If not, I can do some updates tomorrow to make it more flexible and readable |
@josStorer I'm not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, now hope search engines don't change layouts or selector names :-)
Please resolve conflicts |
@wong2 resolved |
Nice work, @josStorer! |
src/content-script/utils.mjs
Outdated
} | ||
); | ||
return element; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer using simple for...of
loop for these functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't know what happened when I wrote this code, it does seem like a long and incomprehensible way 😂
src/content-script/index.mjs
Outdated
const siteNameReplaceList = [document.location.hostname, "www.", "search.", "cn."] | ||
const siteName = siteNameReplaceList.reduce((pre, cur) => { | ||
return pre.replace(cur, "") | ||
}).match(/(.+?)\./)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is hard to read and understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace the prefix of hostname, and then get first word before the dot with regex
do you think it would be better to change the implement, or just add some comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can create a regex with Object.keys(config)
and use it to match location.hostname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it!
src/manifest.json
Outdated
"https://*/search*", | ||
"https://duckduckgo.com/*q=*", | ||
"https://*.startpage.com/sp/search*", | ||
"https://*.baidu.com/s*wd=*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can change this to https://*/*
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we can
@wong2 have updated and tested, it works fine |
sidebarContainerId: ["rhs"], | ||
sidebarContainerClass: [], | ||
appendContainerId: ["rcnt"], | ||
appendContainerClass: [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can combine id and class, by using querySelector
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, wait a minute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wong2 finished
thanks, I'll merge after more tests tomorrow |
I'll merge this and do some fixes myself. |
大佬厉害 |
related: #1 #8 #20 #21 #22 #24
Now support Google, Bing, Yahoo, DuckDuckGo, StartPage, Baidu, Kagi, Yandex, Naver, Brave, Searx, Ecosia
Have a try here: https://github.com/josStorer/chat-gpt-search-engine-extension/releases
Preview: