@Sampei.Nihira
Haha, alright, challenge accepted—let's adapt this to Medium Mode + TLD! First off, I appreciate you sharing the Hard Mode rule; it's a clever starting point, but as you probably know, DNR's `excludedRequestDomains` expects full domain names (like "example.com"), not just TLDs. Listing bare TLDs like "com" won't match anything useful in practice, since requests go to full domains. To make this work properly for TLD-based exclusions, we need to use `regexFilter` to target domains *ending* with those TLDs (e.g., anything .com, .net, etc.).
Based on classic uBO's modes:
- **Hard Mode** is super strict: Block all third-party by default, with very limited allowances (your rule approximates this by blocking third-party unless the request TLD is in that whitelist of common ones).
- **Medium Mode** is more balanced: Still blocks third-party stuff (especially trackers/scripts/frames), but allows more to reduce site breakage—often focusing on known bad actors while permitting same-site or same-TLD resources.
For Medium Mode + TLD, I'll modify it to be less aggressive:
- Keep the core block on third-party requests.
- Use a regex to *allow* (via higher priority) third-party requests to domains ending in your listed TLDs (plus .nl for Kees1958 in the Netherlands, as you mentioned).
- Add a few more common European TLDs (like .de, .fr, .uk) to make it "medium" by allowing broader access without opening the floodgates.
- Limit the block to riskier resource types (scripts, sub_frames, xmlhttprequest) to mimic Medium Mode's focus on trackers/privacy leaks, rather than blocking everything.
This setup approximates "dynamic filtering" by statically allowing same/common TLDs, reducing the need for constant whitelisting. It's not perfect (MV3 limits prevent true initiator-request TLD comparison), but it's close to what Gorhill describes in the uBO docs for MV3 workarounds. Test it in uBO Lite's Developer mode—paste into Personal DNR rules, save, and reload the extension.
Here's the adapted rule set in YAML (as a multi-rule array for better control):
Code:
---
# Higher-priority allow rule for third-party requests to approved TLDs (expanded for Medium Mode)
- id: 1
priority: 5 # Higher than the block
action:
type: allow
condition:
domainType: thirdParty
regexFilter: "^https?://[^/]+\\.(com|io|edu|eu|org|it|info|ms|net|nl|de|fr|uk)(/|$)" # Matches domains ending in these TLDs; added .nl, .de, .fr, .uk for broader allowance
resourceTypes: ["script", "sub_frame", "xmlhttprequest"] # Focused on common tracker types
# Lower-priority block rule for all other third-party requests (core of the mode)
- id: 2
priority: 4
action:
type: block
condition:
domainType: thirdParty
resourceTypes: ["script", "sub_frame", "xmlhttprequest"] # Same types for consistency
---
### Quick Explanation:
- The allow rule fires first (higher priority) for third-party requests to domains like google.com (.com), example.nl (.nl), or site.it (.it)—letting them through.
- Anything else third-party (e.g., to obscure TLDs like .xyz or .top) gets caught by the block rule.
- I added .nl for Kees/the Netherlands, and a few extras (.de for Germany, .fr for France, .uk for UK) to make it "Medium" by allowing more everyday sites without breakage. If you want stricter (fewer TLDs) or to include others (e.g., .es for Spain), just tweak the regex list.
- No `excludedRequestDomains` here since regex handles the TLD matching more accurately.
- If you want to include country-code second-level (like .co.uk), adjust the regex to something like "\\.(com|io|...|co\\.uk|...)$".
Give it a spin on a site with mixed third-party content (like a news page with embeds) and see if it feels like Medium Mode. If it's too permissive or breaks something, we can dial it back—maybe remove some TLDs or add initiator conditions. What do you think, does this nail the adaptation, or should we refine it further (e.g., based on Kees1958's improvements)?