{"id":17989266,"url":"https://github.com/poomsmart/blockemall","last_synced_at":"2025-04-04T03:40:18.064Z","repository":{"id":154019432,"uuid":"158915960","full_name":"PoomSmart/BlockEmAll","owner":"PoomSmart","description":"No 50K/150K entries limit for Safari content blockers.","archived":false,"fork":false,"pushed_at":"2024-01-18T15:29:39.000Z","size":21,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-09T15:14:52.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Logos","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PoomSmart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-24T08:14:43.000Z","updated_at":"2024-12-26T20:46:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"da184141-ff86-48c6-8e94-004f6e8d1fa8","html_url":"https://github.com/PoomSmart/BlockEmAll","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PoomSmart%2FBlockEmAll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PoomSmart%2FBlockEmAll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PoomSmart%2FBlockEmAll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PoomSmart%2FBlockEmAll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PoomSmart","download_url":"https://codeload.github.com/PoomSmart/BlockEmAll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247117749,"owners_count":20886439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T19:14:11.455Z","updated_at":"2025-04-04T03:40:18.045Z","avatar_url":"https://github.com/PoomSmart.png","language":"Logos","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlockEmAll\nA jailbreak tweak that bypasses 50,000/150,000 content filter rules limit for iOS Safari.\n\n# Increasing memory limit\nAs of iOS 9, iOS will kill such processes that consume too much memory.\n\nMemory usage of processes like Safari content blockers are limited to **12 MB**. This is why we must alter the file storing memory limits: `/System/Library/LaunchDaemons/com.apple.jetsamproperties.XX.plist` where `XX` is your device internal model number. For example `XX` either is `N69` or `N69u` for iPhone SE 1st-generation devices.\n\nWe can increase `ActiveHardMemoryLimit` and `InactiveHardMemoryLimit` in `VersionN -\u003e Extension -\u003e Override -\u003e com.apple.Safari.content-blocker` (`N` is some number) to, says, **256 MB**. Doing so allows content blockers like Adguard Pro to add ten thousands of filters with no errors.\nHowever, it will complain again when the rules exceed 50,000 (or 150,000) entries, as iOS refuses to compile any rules of size over that limit. We need more work.\n\n# Compromising WebCore's limitation\nApple hardcoded the limit in their open-source WebCore implementation which can be founded [here](https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp). In a function called `Expected\u003cVector\u003cContentExtensionRule\u003e, std::error_code\u003e loadEncodedRules(ExecState\u0026 exec, const String\u0026 ruleJSON)`, filter rules are in form of an encoded string, being parsed as a JSON array.\nIt raises an error `ContentExtensionError::JSONTooManyRules` when the array length exceeds `maxRuleCount = 50000 or 150000`.\n\nHooking into this pure C++ function is *uneasy*, but there's an alternative *smart* approach; we can hook a higher level Objective-C API: `-[WKContentRuleListStore (_)compileContentRuleListForIdentifier:encodedContentRuleList:completionHandler:]`, and [here](https://trac.webkit.org/browser/webkit/trunk/Source/WebKit/UIProcess/API/Cocoa/WKContentRuleListStore.mm) is where it is located.\nThis method compiles the rules by calling a lower level API, given the content blocker identifier and some action to be done after the compilation has been done. Eventually, this method will invoke the `loadEncodedRules()` function.\nWe cannot input more than 50,000/150,000 rules at a time, but we can input no more than 50,000/150,000 rules multiple times. In other words, **you can seperate the rules into chunks that each one is no more than 50,000/150,000 entries**.\n\nIn terms of pseudocode:\n```\ncompile(identifier, ruleList, completion):\n    count = ruleList.count\n    j = 0\n    while count \u003e 0:\n        range = (j, min(50000, count)) // 50000 for backward compatibility\n        subruleList = subarray(ruleList, range)\n        original_compile(identifier, subruleList, completion)\n        j += range.length\n        count -= range.length\n```\n\n# Increasing memory limit (again)\nThat Objective-C method is invoked in a XPC service dedicated for loading rules from user-installed content blockers. Similarly, there is a memory limit which this process should never exceed.\n\nFound in `VersionN -\u003e XPCService -\u003e Override -\u003e com.apple.SafariServices.ContentBlockerLoader`, we can set both `ActiveSoftMemoryLimit` and `InactiveHardMemoryLimit` to something higher, like **512 MB** that seems to be enough. Of course, you need to check how much RAM your device can offer.\n\nChanges to increasing memory limit **require a reboot**.\n\n# Per-app limitation bypassing\nUsually, content blockers (Adguard Pro included) will both limit the total rules to 50,000 and warn users about that. One must find and hook method(s) that limit the number, and the rest would work as intended.\n\nEnsuring all four sections and **reenabling the content blockers that you are using**, you are set. And for your information, BlockEmAll 0.0.2+ will do the memory limit increasing automatically, though without rolling back when uninstalling - as it is way harmless.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoomsmart%2Fblockemall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoomsmart%2Fblockemall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoomsmart%2Fblockemall/lists"}