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

Add Whitelist #372

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add Whitelist #372

wants to merge 5 commits into from

Conversation

Banaanae
Copy link

@Banaanae Banaanae commented Jun 25, 2024

This PR adds a whitelist button, which then allows users to prevent sites from being filtered
Whitelisting is now pretty much finished, only the issue with subdomains being treated like separate sites remain, just waiting on maintainer's opinions on adding another library. (If current behaviour is also like there could be an option in settings)
This PR has only been tested on firefox, if chrome users could test it be greatly appreciated

  • Make whitelist for full domain (currently if www.example.com is whitelisted, example.com isn't. This could be considered intentional, but it would still break cases like www.example.com calling assets.example.com)
  • Allow users to unwhitelist whitelisted sites (only possible via full reset atm, would replace Whitelist Site with Remove From Whitelist when viewing a whitelisted page)
    • Update button after user presses it
    • Make button spam resistant
  • List whitelisted sites in settings
  • Fix styling
  • Support for ip addresses? (Might already be working, untested)
  • Whitelist sites on per rule basis (meaning exempt a site from one rule but not another, requested in Feature request to be able to exclude websites #93, but might not be added in this PR)

Once done this will close #93 and its many duplicates

image

Banaanae added 2 commits June 25, 2024 16:15
just show data in a text input
no fancy formatting needed!
@Banaanae
Copy link
Author

image

@Banaanae
Copy link
Author

Banaanae commented Jun 25, 2024

Using a library like tld.js could fix the first issue
Alternatively we could parse the psl ourselves, but seems redundant because of above lib

still needs to update after press
@Banaanae
Copy link
Author

image
image

- Button now reflects whitelist status instantly
- Fixed bug where only last site whitelisted displayed properly
- No longer breaks when spammed
- Removed test code
@Banaanae Banaanae marked this pull request as ready for review June 26, 2024 23:42
@Banaanae
Copy link
Author

I'm marking this as ready for review, before merging a few things need to happen

  • Chrome testing
  • Decide on if tld.js should be used to fix first task

Not going to do the last task, a bit above my skill level

@Banaanae
Copy link
Author

Banaanae commented Jul 9, 2024

@KevinRoebert do you have any plans to merge this?
If you'd rather me create this on gitlab I have finally got my account unblocked :)
I know you are in the process of rewriting this extension, (with whitelisting being included), but it has been some time since that announcement, (maybe merge this in the mean time, and then replace my stuff with your fix?). This has been one of the most requested features.

@KevinRoebert KevinRoebert self-assigned this Jul 9, 2024
@KevinRoebert KevinRoebert self-requested a review July 9, 2024 08:18
@rdslw
Copy link

rdslw commented Jul 14, 2024

Would be great to have it, as currently clearurls breaks amazon sorting, resulting in user not being able to select any other sorting.

@KevinRoebert
Copy link
Member

@Banaanae First of all, thank you for your contribution.

I am currently reviewing the code. It still needs some changes and also has a couple of bugs. I will make the changes directly and then merge.

* Skip whitelisted sites
*/
for (const site of storage.whitelist) {
if (url.indexOf(site) != -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!==

siteFound = true
}
});
if (!siteFound) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swap both cases

}
});
if (!siteFound) {
if (data.response.length != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this If. It causes the button to retain the "btn-danger" class when a page is added and immediately removed.

function: "getData",
params: ['whitelist']
}).then((data) => {
data.response.forEach(site => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be replaced by the following: let siteFound = data.response.some(site => currentSite.indexOf(site) !== -1);

* @param {boolean} remove If true remove current site instead of adding
*/
function changeWhitelist(removeWl = false) {
if (removeWl != true) { // Handle click obj
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment is useless. It is better to pass the correct state in the onclick event

element.classList.replace('btn-danger', 'btn-primary')
}
element.textContent = translate('popup_html_configs_whitelist_button_add')
document.getElementById('whitelist_btn').onclick = changeWhitelist;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass the desired state here: () => {changeWhitelist(true)}

}).then((data) => {
let siteUrl = new URL(site)
let domain = siteUrl.hostname
if (removeWl == false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swap both cases

if (removeWl == false) {
data.response.push(domain)
} else {
data.response = data.response.filter(wlSite => wlSite != domain)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsafe comparison, better !==

@KevinRoebert
Copy link
Member

https://gitlab.com/ClearURLs/ClearUrls/-/merge_requests/110

@Acleacius
Copy link

Acleacius commented Sep 12, 2024

Thanks for your work, just noticed as I was posting in the other thread about a new issue I found, unrelated to your fix.

I'm gonna quote my post as to not retype it, just thought if your actively working on it you might be interested. :)

New issue at least to me, when using Google Maps it keeps the url locked so Google can't zoom in and auto readjust
positioning. It also means many normal functions on Google Maps don't work such as clicking on a POI to get the popup
and all the information provided. Such as Hours of Operation, Crowd Size (haha) atm and Addresses.

Personally, I still use this mod BUT it's really good to get a list of places and situations, so we can be aware to disable manually
as necessary.

Looking forward to trying your fixes! :D

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

Successfully merging this pull request may close these issues.

Feature request to be able to exclude websites
4 participants