Skip to content
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

Search Engine Issues with React framework? #705

Open
runningcheese opened this issue May 26, 2024 · 8 comments
Open

Search Engine Issues with React framework? #705

runningcheese opened this issue May 26, 2024 · 8 comments

Comments

@runningcheese
Copy link

I‘m trying to add this website to ContextSearch-web-ext.

Website:
https://kimi.moonshot.cn

It's works with this code.
document.querySelector('[contenteditable]').textContent = searchTerms;

But the problem is,
This website is built with the React framework.
If we directly insert content, the search icon at the end won't be clickable.
Can this issue be resolved?

I've tried lots of id and class, but not working.
Thanks in advance.

iShot_2024-05-11_22 04 50 iShot_2024-05-11_22 05 35

@ssborbis

@ssborbis
Copy link
Owner

I cant access that website, even with a VPN. It must be blocked for me.

@runningcheese
Copy link
Author

try this site: https://hailuoai.com

It's the same problem,
when the site uses react framework,
it can't insert content correctly, is there a solution to this problem? @ssborbis

@runningcheese
Copy link
Author

runningcheese commented May 31, 2024

if you can't open that site either.
try https://www.meta.ai, the React Framework.
@ssborbis

@ssborbis
Copy link
Owner

ssborbis commented Jun 1, 2024

I see what you mean. I'm not sure what events need to be triggered to get the button to be clickable. It will take some investigation.

@runningcheese
Copy link
Author

runningcheese commented Jun 1, 2024

@ssborbis
I have tried this code, and it works well now.

(async () => {
await new Promise(r => setTimeout(r, 500));
let input = document.querySelector('textarea');
function setNativeValue(element, value) {
const lastValue = element.value;
element.value = value;
const event = new Event('input', { bubbles: true });
const tracker = element._valueTracker;
if (tracker) { tracker.setValue(lastValue);} element.dispatchEvent(event);}
input.focus();
setNativeValue(input, searchTerms);
await new Promise(r => setTimeout(r, 500));
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', keyCode: 13, bubbles: true }));
})();

@runningcheese
Copy link
Author

But the problem is, it still not working on https://kimi.moonshot.cn
Can this issue be resolved?
@ssborbis

@ssborbis
Copy link
Owner

ssborbis commented Jun 2, 2024

Sorry, I can't reach that website to test. Where did you find the code you used to make it work? I'm trying to understand why it works.

@runningcheese
Copy link
Author

Sorry, I can't reach that website to test. Where did you find the code you used to make it work? I'm trying to understand why it works.

I used ChatGPT to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants