chatgpt-google-extension
chatgpt-google-extension copied to clipboard
Fix baidu support
@josStorer since baidu loads search result page without a page load, the extension will not be triggered.
yes, currently have to make a refresh after a search
i think we can add action to the search engine config file
like
baidu: {
inputQuery: [],
sidebarContainerQuery: [],
appendContainerQuery: [],
action: {
beforeMount: someFunction1, // add some listener
onMount: someFunction2, // add some listener, and we can also implement custom styles here
..... // not sure if the other life cycle functions is necessary, like onFailedMount, onResponse, onResponseSuccess, onResponseUnauth, onResponseError
}
},
function someFunction1(container, parent){ // parent is null if not found
}
function someFunction2(container, parent){
}
I didn't add this to PR, cause it will make a big impact on index.mjs
i think we can add
actionto the search engine config file like
should i create another issue for that?
No, we can discuss in this issue
may i create a pull request to fix this with the above lifecycle actions, and then ask you to do a code review?
I don't we need general apis for beforeMount, onMount etc, what we need is run run after location changed for any reasons
i don't think that will work, because location will change first, and then components update, setTimeout will also not work, because we cannot know users' network status
so as an example, for baidu, we have to use MutationObserver, to observe #wrapper_wrapper, which means that it makes more sense to set in the config file for different search engines, and also for possible style adaptations in future
Makes sense. i think we can put baidu support on hold temporarily
I'll try to add the support in a generic way in my fork, maybe I can create a PR then and ask you to make a review, but of course, I won't have time today
fixed in #93