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

fix(brave): blocking search results no longer work #374

Merged
merged 12 commits into from
Nov 20, 2023

Conversation

rsuwa
Copy link
Contributor

@rsuwa rsuwa commented Nov 17, 2023

Issue

#371

Changes from the previous version

  • Slight modifications were made to the target DOM in accordance with Brave Search's specification changes.
  • Minor style modifications
  • Add missing support for Brave Goggle Search

*Note: Subdomains are not supported in Brave Image Search due to the difficulty in obtaining the complete URL of the image link. (e.g., if the link is to "www.example.com", it will block the entire "example.com"). I have not been able to do anything about this, but if you think you can improve the logic, please advise.

url: root => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
let m = root.querySelector('.text-ellipsis')!.innerHTML;
if (!m.startsWith('http://') && !m.startsWith('https://')) {
m = 'https://' + m;
}
return m;
},

@rsuwa
Copy link
Contributor Author

rsuwa commented Nov 17, 2023

@iorate
The detailed cause is under investigation, but it appears that the DOM is being modified after the load event is fired in Brave Search's specification.

Reference:

I have tried to solve the problem by changing run_at in manifest.json.ts to document_idle, using MutationObserver, etc., but my implementation skills were not enough to solve the problem, so I would like to borrow some of your knowledge.

I apologize for the very naive implementation, but changing content-script.tsx as follows will solve the problem once, but it is not a clean way and I would like to avoid it.

// main();
setTimeout(() => {
  main();
}, 1000);

@rsuwa rsuwa changed the title fix(brave): blocking search results no longer work [WIP] fix(brave): blocking search results no longer work Nov 17, 2023
@rsuwa
Copy link
Contributor Author

rsuwa commented Nov 17, 2023

PS: This problem did not occur in Firefox, so it may be specific to Chrome or Chromium-based browsers.

Environment

  • OS: macOS Sonoma 14.1.1
  • Browser (Firefox): Firefox 119.0.1
  • Browser (Chrome): Chrome 119.0.6045.15

Both browsers are newly launched from VSCode's launch.json, without any other extensions, and are in a vanilla state.

@iorate
Copy link
Owner

iorate commented Nov 19, 2023

@rsuwa
Thank you for your contribution.
I think the only way we can do now is to delay the content script.
I have modified the main code to support delaying.

@iorate
Copy link
Owner

iorate commented Nov 19, 2023

*Note: Subdomains are not supported in Brave Image Search due to the difficulty in obtaining the complete URL of the image link. (e.g., if the link is to "www.example.com", it will block the entire "example.com"). I have not been able to do anything about this, but if you think you can improve the logic, please advise.

I think your solution is the best we can do.

@rsuwa
Copy link
Contributor Author

rsuwa commented Nov 20, 2023

@rsuwa Thank you for your contribution. I think the only way we can do now is to delay the content script. I have modified the main code to support delaying.

Thanks for your modification!
After several attempts, I thought 100 ms would be enough.

@rsuwa rsuwa changed the title [WIP] fix(brave): blocking search results no longer work fix(brave): blocking search results no longer work Nov 20, 2023
@rsuwa rsuwa marked this pull request as ready for review November 20, 2023 07:51
@iorate
Copy link
Owner

iorate commented Nov 20, 2023

@rsuwa I really appreciate your help.

@iorate iorate merged commit 1f8cc2b into iorate:master Nov 20, 2023
2 checks passed
Copy link

🎉 This PR is included in version 8.3.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants