ssborbis / ContextSearch-web-ext

Search engine manager for modern browsers
314 stars 35 forks source link

Search Engine Issues with React framework? #705

Open runningcheese opened 1 month ago

runningcheese commented 1 month ago

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 commented 1 month ago

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

runningcheese commented 1 month ago

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 commented 1 month ago

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

ssborbis commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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

ssborbis commented 1 month ago

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 commented 1 month ago

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.