Repository navigation
Safari build, macOS/Linux build scripts, Safari fixes, and the Reddit NSFW fix - #55
Open
asimovtekir wants to merge 4 commits into
Open
asimovtekir wants to merge 4 commits into
asimovtekir wants to merge 4 commits into
Conversation
NSFW subreddits opened unblocked for signed-out visitors. The check asked
/r/<name>/about.json; Reddit now answers that with an HTML 403 ("You've
been blocked by network security") for every subreddit, SFW or not, and
the 403 was read as "not NSFW". Its HTML pages are served after a JS
challenge; its JSON endpoints are refused outright.
- readRedditPageNsfw(): the answer from <reddit-page-data> (subreddit.isNsfw),
trusted only when it names the subreddit asked about (directly or via
<shreddit-screenview-data> with the same id), so data left behind by an
in-app navigation is not borrowed. No request is made.
- checkRedditSubredditNSFW() returns null, not false, when Reddit has not
answered (403/429, network error, no over18). Unknown never blocks and is
never cached. A 403/429 pauses about.json for 10 minutes: Reddit refuses
the client, not one subreddit, and a feed would otherwise send a refused
request per post.
- recheckRedditPage(): processContent's check runs at document_start, before
the page data parses, and skips while a pass is running. Asked again on
DOMContentLoaded and whenever a <reddit-page-data> is added.
- SOCIAL_SELECTORS.reddit matches <shreddit-post>, and its `nsfw` attribute
hides the post. The old selectors matched no element on current Reddit.
Tests: tests/reddit-nsfw.test.js (14).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…equest
Found running the built extension in Firefox 158:
- Reddit's <reddit-page-data> names the subreddit as `prefixedName`
("r/pics"), not `name`. The redirect worked only because
<shreddit-screenview-data> happened to be on the page too.
- Firefox's content script gets Reddit's about.json refusal as a
NetworkError, not a 403 (on main as well). The catch returned null but
did not pause, so with <shreddit-post> now matched, every post linking a
subreddit would send a failing request and print a console error. It now
pauses like a 403, and logs only in debug mode.
Tests: tests/reddit-nsfw.test.js (16).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… wait on storage - Dynamic rules: Safari refuses a whole updateDynamicRules batch over one rule its content-blocker regex can't take (Bing's alternation), which left 0 SafeSearch, whitelist and custom-image rules. A refused batch now falls back to one rule at a time, remembers the refusals per version and browser, and skips calls that would change nothing. Updates run one at a time. - Startup no longer awaits the dynamic-rules update or the blocklist cache write. Safari recompiles every rule list per accepted call (16-28 s before ready) and can leave a large storage.local.set unsettled forever. - Site access: Safari stores "Always allow on every website" as *://*/* and answers false for <all_urls>, so either pattern now counts as access. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- build-chrome.sh / build-firefox.sh run scripts/build-extension.sh: the same steps and checks as the .ps1 builds (store-mode and committed-tree checks, extras, timestamp, asset checks, zip read back by check-package.js), with the file lists read from the .ps1 scripts so the platforms can't drift. - build-safari.sh stages the Firefox build through it into dist/safari/extension/, generates the Xcode project with safari-web-extension-converter and, with --build, signs the app ad hoc to run locally. - Chrome's _metadata/ (written when the repository root is loaded unpacked) is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds BlockNSFW 2.0.8 for Safari, adds macOS/Linux build scripts for Chrome and Firefox, and fixes the Safari runtime problems found while testing it. The Reddit NSFW-subreddit fix (6448086, eaefeb8) is also included in this PR.
Safari build
build-safari.shstages the Firefox build intodist/safari/extension/(Safari has nochrome.offscreen, and the Firefox build already runs the image classifier on the background page). It then generates the Xcode project withsafari-web-extension-converter, and with--buildsigns the app ad hoc so it runs locally. The script doesn't package for the App Store; that needs a developer team and a real bundle ID.Safari runtime fixes
updateDynamicRulesbatch (its content-blocker regex has no alternation or\d, which rules out the Bing rule), it refuses the whole batch. That left 0 SafeSearch, whitelist and custom-image rules. A refused batch now falls back to adding rules one at a time. Refusals are remembered per extension version and browser build, an update that would change nothing makes no call, and updates run one at a time. Browsers that accept the batch keep the single atomic swap.storage.local.setunsettled forever.*://*/*and answersfalsefor<all_urls>, so either pattern now counts as access. Chrome and Firefox behave as before.Chrome/Firefox builds on macOS and Linux
build-chrome.sh/build-firefox.sh(viascripts/build-extension.sh) take the same flags as the.ps1builds:--zip,--open-source,--sandbox. They also make the same checks: store mode, committed tree, Supporter extras, build timestamp, AI assets, and a read-back of the zip bycheck-package.js. The file lists are read from the.ps1scripts, so the platforms can't drift apart._metadata/is gitignored. README documents the new scripts.Reddit (included)
about.jsonwith a 403 for every subreddit, and the 403 was read as "not NSFW". The flag is now read from the<reddit-page-data>Reddit serves (prefixedName), and an unknown answer never blocks and is never cached. A refusedabout.jsonrequest (a 403/429, or a NetworkError in Firefox) pauses those requests for 10 minutes.<shreddit-post nsfw>posts are hidden in feeds.Testing
npm test: 1438/1438 pass../build-chrome.sh --zip --open-sourceand./build-firefox.sh --zip --open-source: both packages passcheck-package.js(133 and 131 files)../build-safari.sh --build --open-source: the app builds and is signed ad hoc. The staged extension has exactly the Firefox build's file list. A clean first run in Safari opens onboarding.web-ext lint(not installed locally), and a store build (extras-private not available here).🤖 Generated with Claude Code