diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5550426..7b62142 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,8 @@ jobs: - name: Chrome accepts the build run: node scripts/verify-load.mjs chrome - run: npm run test:e2e + - name: Firefox smoke test + run: npm run test:firefox - run: npm run package - uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36ca22f..a2c840f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,22 @@ name: Release +# Push a tag like v2.0.1 and this builds, tests, creates the GitHub release, then submits +# the new version to every store it has credentials for: +# Chrome Web Store keyless, via Workload Identity Federation (clicktrack-505800) +# Firefox (AMO) secrets AMO_JWT_ISSUER, AMO_JWT_SECRET +# Microsoft Edge secrets EDGE_PRODUCT_ID, EDGE_CLIENT_ID, EDGE_API_KEY +# A store with no credentials is skipped, not failed. Each store then reviews the upload +# before it reaches users. on: push: tags: ['v*'] -permissions: - contents: write - jobs: - release: + build: runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 25 + permissions: + contents: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -25,6 +31,8 @@ jobs: - run: npm test - run: node scripts/verify-load.mjs chrome - run: npm run test:e2e + - name: Firefox smoke test + run: npm run test:firefox - run: npm run package - name: Release notes from CHANGELOG run: | @@ -36,7 +44,74 @@ jobs: const next = cl.indexOf("\n## [", start + 1); require("fs").writeFileSync("notes.md", cl.slice(cl.indexOf("\n", start) + 1, next === -1 ? undefined : next).trim() + "\n"); ' - - name: Publish + - name: GitHub release env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" release/*.zip --title "SilentBlock ${GITHUB_REF_NAME#v}" --notes-file notes.md + + chrome: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - id: auth + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: projects/667575805085/locations/global/workloadIdentityPools/github/providers/silentblock + service_account: cws-publisher@clicktrack-505800.iam.gserviceaccount.com + token_format: access_token + access_token_scopes: https://www.googleapis.com/auth/chromewebstore + - name: Download release zips + env: + GH_TOKEN: ${{ github.token }} + run: gh release download "$GITHUB_REF_NAME" --dir release + - name: Submit to the Chrome Web Store + env: + CWS_ACCESS_TOKEN: ${{ steps.auth.outputs.access_token }} + run: node scripts/publish/chrome.mjs + + firefox: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Download release zips + env: + GH_TOKEN: ${{ github.token }} + run: gh release download "$GITHUB_REF_NAME" --dir release + - name: Submit to addons.mozilla.org + env: + AMO_JWT_ISSUER: ${{ secrets.AMO_JWT_ISSUER }} + AMO_JWT_SECRET: ${{ secrets.AMO_JWT_SECRET }} + run: node scripts/publish/firefox.mjs + + edge: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + - name: Download release zips + env: + GH_TOKEN: ${{ github.token }} + run: gh release download "$GITHUB_REF_NAME" --dir release + - name: Submit to Microsoft Edge Add-ons + env: + EDGE_PRODUCT_ID: ${{ secrets.EDGE_PRODUCT_ID }} + EDGE_CLIENT_ID: ${{ secrets.EDGE_CLIENT_ID }} + EDGE_API_KEY: ${{ secrets.EDGE_API_KEY }} + run: node scripts/publish/edge.mjs diff --git a/CHANGELOG.md b/CHANGELOG.md index cf741f9..7d59613 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## [Unreleased] +## [2.0.1] - 2026-09-28 + +### Fixed +- Firefox build uses the existing add-on ID (`silentblock@local`), so it updates the AMO + listing instead of arriving as a new add-on, and declares that it collects no data. + +### Added +- Automated store releases: pushing a version tag builds, tests and submits the new version + to the Chrome Web Store, Firefox Add-ons and Edge Add-ons. +- Firefox smoke test (real Firefox) in CI and releases. +- Licensed under GPL-3.0-or-later; privacy policy; store listing copy and generated images. + ## [2.0.0] - 2026-09-28 A rebuild. The 1.x engine (a hand-written list of ~226 domains plus global page patches) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/PRIVACY.md b/PRIVACY.md new file mode 100644 index 0000000..4d93775 --- /dev/null +++ b/PRIVACY.md @@ -0,0 +1,41 @@ +# SilentBlock privacy policy + +Last updated: 28 September 2026 + +**SilentBlock collects nothing.** It has no accounts, no analytics, no telemetry and no +servers. Nothing you browse, block or configure ever leaves your browser. + +## What SilentBlock does on your device + +- **Blocks requests** using filter lists that ship inside the extension. Lists are updated by + releasing a new version of the extension, never downloaded while you browse. +- **Checks pages against malware, phishing and scam lists** stored inside the extension. The + check happens on your device. SilentBlock does not send the addresses you visit to anyone, + including Google Safe Browsing or any other lookup service. +- **Reads the pages you visit** in order to hide ads, remove anti-adblock walls and colour + its toolbar icon. What it reads stays in the browser and is not stored. +- **Stores your settings** (paused sites, categories, display options) with your browser's + extension storage. They stay in that browser. Export them from Settings if you want a copy. +- **Keeps per-tab counts** (how many requests were blocked) in memory for the popup. They are + cleared when you close the tab or the browser. + +## Why it asks for its permissions + +| Permission | Used for | +|---|---| +| Access to all sites | Blocking and hiding ads on every site you visit, and redirecting blocked scripts to harmless local stand-ins | +| declarativeNetRequest | The browser's built-in blocking engine, which applies the filter lists | +| scripting | Injecting the hiding rules and the anti-adblock fixes into pages | +| webNavigation | Knowing when a page loads, to apply site-specific rules, follow pop-ups and show the malware warning | +| webRequest (read-only) | Counting blocked requests for the toolbar icon and popup. It cannot change or read request contents | +| storage | Saving your settings | + +## Third parties + +None. SilentBlock has no third-party code, SDKs, trackers or advertising, and does not share, +sell or transfer data, because it has none. + +## Contact + +Click Click Media, [clickclickmedia.com.au](https://clickclickmedia.com.au). Source code and +issues: [github.com/ClickClickMedia/SilentBlock](https://github.com/ClickClickMedia/SilentBlock). diff --git a/README.md b/README.md index 4536fe1..227b66c 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,20 @@ git add package.json package-lock.json CHANGELOG.md git commit -m "Release vX.Y.Z" && git tag vX.Y.Z && git push --follow-tags ``` -Pushing the tag runs `.github/workflows/release.yml`, which builds, tests and attaches both -zips to a GitHub release. +Pushing the tag runs `.github/workflows/release.yml`: build, full tests (Chrome and a Firefox +smoke test), a GitHub release with the Chrome, Firefox and source zips, then a submission to +each store it has credentials for. Every store reviews the upload before users get it. + +| Store | Item | Credentials | +|---|---|---| +| Chrome Web Store | `accdpphckockpflaggbplikpmaknioao` | None stored: keyless login from GitHub Actions to the `cws-publisher` service account (Workload Identity Federation in `clicktrack-505800`, tags only) | +| Firefox (AMO) | `silentblock@local` | Repo secrets `AMO_JWT_ISSUER`, `AMO_JWT_SECRET` | +| Microsoft Edge | `hhdolnhpfeeipbomjfkalbhegkakbkmo` | Repo secrets `EDGE_PRODUCT_ID`, `EDGE_CLIENT_ID`, `EDGE_API_KEY` | + +A store with no credentials is skipped. The same scripts run locally: `npm run package`, then +`npm run publish:chrome` (signs in through your gcloud login), `publish:firefox` or +`publish:edge` with the variables above. `npm run store:status` shows what Chrome has. +Listing text and images: `docs/store-listing.md` and `npm run store:art`. ## Filter lists and licences @@ -148,6 +160,5 @@ zips to a GitHub release. | Phishing URL Blocklist | CC BY-SA 4.0 (sources: OpenPhish, PhishTank, IPThreat) | | Scam Blocklist by DurableNapkin | MIT | -The lists are bundled as data in their original terms. Publishing SilentBlock outside CCM -(for example on the public Chrome Web Store) means distributing GPL-3.0 material, so check -the licence position first. +SilentBlock itself is licensed under the [GNU GPL v3.0 or later](LICENSE). The bundled +filter lists keep their own licences, listed above. Privacy policy: [PRIVACY.md](PRIVACY.md). diff --git a/docs/store-listing.md b/docs/store-listing.md new file mode 100644 index 0000000..65cb36e --- /dev/null +++ b/docs/store-listing.md @@ -0,0 +1,73 @@ +# Store listing + +One source for all three stores. The Firefox listing text is updated automatically on +release (`scripts/publish/firefox.mjs`). Chrome and Edge have no API for listing text, so +paste these in by hand when they change. Store images: `npm run store:art` renders them into +`release/store-art/`. + +Store items: +- Chrome Web Store: `accdpphckockpflaggbplikpmaknioao` (publisher b7b011da-ecfd-4ec1-8d99-c600f9c31543) +- Firefox: `silentblock@local`, https://addons.mozilla.org/firefox/addon/silentblock/ +- Edge: `hhdolnhpfeeipbomjfkalbhegkakbkmo` + +## Name + +SilentBlock + +## Summary + + +Blocks ads, trackers, pop-ups, cookie banners and malware sites, silently. No nags, no accounts, no data collection. Free forever. + +## Description + + +SilentBlock is a free ad blocker that stays out of your way. No upsells, no nags, no account, and nothing you do ever leaves your browser. + +WHAT IT BLOCKS +• Ads and ad networks, using EasyList and the uBlock Origin filter lists +• Trackers and analytics, using EasyPrivacy +• Pop-ups, pop-unders and tab-unders +• Cookie consent banners, without breaking the page underneath +• Malware, phishing and scam sites, using URLhaus, the Phishing URL Blocklist, uBlock Origin's Badware list and a scam blocklist +• "Turn off your ad blocker" walls, with one click, or automatically on sites you choose + +THE ICON TELLS YOU WHAT HAPPENED +• Blue: nothing on this page needed blocking +• Green: ads and trackers blocked +• Amber: a pushy site, with pop-ups or a nag wall dealt with +• Red: a dangerous site or host was blocked +• Grey: paused + +WHY IT'S FAST +SilentBlock compiles more than 120,000 filters into the browser's own blocking engine, so pages are checked before anything loads. Hiding rules are applied as invisible user styles, and only the ones a page actually needs. On ordinary sites SilentBlock doesn't patch anything in the page at all. + +YOUR PRIVACY +The filter lists ship inside the extension and are never downloaded while you browse. Malware checks happen on your device: SilentBlock never sends the addresses you visit to anyone. No analytics, no telemetry, no servers. + +SITE BROKEN? +Click the icon and switch off "Block on this site". Paused sites get no blocking at all, except the malware protection, which always stays on. + +Open source (GPL-3.0): https://github.com/ClickClickMedia/SilentBlock + + +## Category + +Leave each store's category as the existing listing has it (Firefox: Privacy & Security). + +## Chrome Web Store privacy tab + +**Single purpose:** Blocks ads, trackers, pop-ups and known malicious sites while you browse. + +**Permission justifications:** +- `declarativeNetRequest`: applies the bundled filter lists with the browser's built-in request blocker. +- `scripting`: injects the bundled hiding rules and anti-adblock fixes into pages, and removes anti-adblock walls when the user asks. +- `storage`: saves the user's settings (paused sites, categories, display options). +- `webNavigation`: knows when a page loads, to apply site-specific rules, follow new tabs opened by pages (pop-up blocking), and show the malware warning page. +- `webRequest`: read-only, counts blocked requests per tab for the toolbar icon colour and the popup count. +- Host permission ``: ads, trackers and malicious content can appear on any site; blocking and hiding must work on every site the user visits. +- Remote code: **No**. All code and filter lists are bundled. + +**Data usage:** collects no user data. Tick nothing. Certify that data is not sold, not used for unrelated purposes, and not used for creditworthiness. + +**Privacy policy URL:** https://github.com/ClickClickMedia/SilentBlock/blob/main/PRIVACY.md diff --git a/package-lock.json b/package-lock.json index 08b33aa..2a2a300 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,27 @@ { "name": "silentblock", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "silentblock", - "version": "2.0.0", + "version": "2.0.1", "devDependencies": { - "@playwright/test": "^1.63.0" + "@playwright/test": "^1.63.0", + "selenium-webdriver": "^4.49.0" }, "engines": { "node": ">=22.2" } }, + "node_modules/@bazel/runfiles": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@bazel/runfiles/-/runfiles-6.5.0.tgz", + "integrity": "sha512-RzahvqTkfpY2jsDxo8YItPX+/iZ6hbiikw1YhE0bA9EKBR5Og8Pa6FHn9PO9M0zaXRVsr0GFQLKbB/0rzy9SzA==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@playwright/test": { "version": "1.63.0", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.63.0.tgz", @@ -30,6 +38,64 @@ "node": ">=20" } }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jszip": { + "version": "3.10.2", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.2.tgz", + "integrity": "sha512-3l+rb15IOWtUhU0H5MFqES/T6Kh7abYwjosBey/vD6hDt8zoEffkSC5Ws5SGtgVw3gBx2NEbhTeSW1+kWkpyTQ==", + "dev": true, + "license": "(MIT OR GPL-3.0-or-later)", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "immediate": "~3.0.5" + } + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true, + "license": "(MIT AND Zlib)" + }, "node_modules/playwright": { "version": "1.63.0", "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.63.0.tgz", @@ -58,6 +124,118 @@ "engines": { "node": ">=20" } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true, + "license": "MIT" + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/selenium-webdriver": { + "version": "4.49.0", + "resolved": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-4.49.0.tgz", + "integrity": "sha512-16XqeOEMj+4+p+pzLLyvNWmF5jCY05EKIl3e1anZBgv4+zq7PUTtiNjKtQhMpwosZ0wIMKDFAQ2xdyogOHD4DA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/SeleniumHQ" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/selenium" + } + ], + "license": "Apache-2.0", + "dependencies": { + "@bazel/runfiles": "^6.5.0", + "jszip": "^3.10.1", + "tmp": "^0.2.7", + "ws": "^8.21.3" + }, + "engines": { + "node": ">= 22.0.0" + } + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "dev": true, + "license": "MIT" + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/tmp": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz", + "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/ws": { + "version": "8.22.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", + "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index 830a1eb..b069abb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "silentblock", - "version": "2.0.0", + "version": "2.0.1", "private": true, "description": "Free, silent ad blocker for Chrome (MV3). No ads, no nags.", "type": "module", @@ -16,9 +16,17 @@ "check": "npm run build && npm test && node scripts/verify-load.mjs && npm run test:e2e", "package": "node scripts/package.mjs", "bump": "node scripts/bump.mjs", - "verify": "node scripts/verify-load.mjs" + "verify": "node scripts/verify-load.mjs", + "test:firefox": "node test/firefox/smoke.mjs", + "publish:chrome": "node scripts/publish/chrome.mjs", + "publish:firefox": "node scripts/publish/firefox.mjs", + "publish:edge": "node scripts/publish/edge.mjs", + "store:status": "node scripts/publish/chrome.mjs --status", + "store:art": "node scripts/store-art.mjs" }, "devDependencies": { - "@playwright/test": "^1.63.0" - } + "@playwright/test": "^1.63.0", + "selenium-webdriver": "^4.49.0" + }, + "license": "GPL-3.0-or-later" } diff --git a/scripts/build.mjs b/scripts/build.mjs index 28c8a44..f206ea8 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -265,7 +265,7 @@ function manifestFor(target) { }; if (target === 'firefox') { m.background = { scripts: ['background/main.js'], type: 'module' }; - m.browser_specific_settings = { gecko: { id: 'silentblock@clickclickmedia.com.au', strict_min_version: '128.0' } }; + m.browser_specific_settings = { gecko: { id: 'silentblock@local', strict_min_version: '128.0', data_collection_permissions: { required: ['none'] } } }; delete m.minimum_chrome_version; } return m; diff --git a/scripts/bump.mjs b/scripts/bump.mjs index a60d06a..00196db 100644 --- a/scripts/bump.mjs +++ b/scripts/bump.mjs @@ -32,7 +32,9 @@ try { const clPath = path.join(root, 'CHANGELOG.md'); const today = new Intl.DateTimeFormat('en-CA', { timeZone: 'Australia/Sydney' }).format(new Date()); let cl = await readFile(clPath, 'utf8'); -if (cl.includes('## [Unreleased]')) { +if (cl.includes(`## [${next}]`)) { + console.log(`CHANGELOG.md already has a ${next} entry; left as is.`); +} else if (cl.includes('## [Unreleased]')) { cl = cl.replace('## [Unreleased]', `## [Unreleased]\n\n## [${next}] - ${today}`); await writeFile(clPath, cl); } else { diff --git a/scripts/package.mjs b/scripts/package.mjs index c36ea5b..2c8c946 100644 --- a/scripts/package.mjs +++ b/scripts/package.mjs @@ -4,6 +4,7 @@ import { readdir, readFile, writeFile, mkdir, stat } from 'node:fs/promises'; import path from 'node:path'; import zlib from 'node:zlib'; +import { execFileSync } from 'node:child_process'; const root = path.resolve(import.meta.dirname, '..'); const pkg = JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')); @@ -88,3 +89,9 @@ for (const target of ['chrome', 'firefox']) { const size = (await stat(file)).size; console.log(`${path.relative(root, file)} ${names.length} files, ${(size / 1024 / 1024).toFixed(1)} MB`); } + +// Source archive of the tagged tree, for store reviewers (AMO requires it for generated code). +const source = path.join(outDir, `SilentBlock-${pkg.version}-source.zip`); +execFileSync('git', ['archive', '--format=zip', `--output=${source}`, 'HEAD'], { cwd: root }); +console.log(`${path.relative(root, source)} source (git archive HEAD), ${((await stat(source)).size / 1024 / 1024).toFixed(1)} MB`); + diff --git a/scripts/publish/chrome.mjs b/scripts/publish/chrome.mjs new file mode 100644 index 0000000..414c0bf --- /dev/null +++ b/scripts/publish/chrome.mjs @@ -0,0 +1,76 @@ +// Chrome Web Store: upload the Chrome zip and submit it for review. +// node scripts/publish/chrome.mjs upload + submit +// node scripts/publish/chrome.mjs --status show what the store has +// +// Auth is the CCM Web Store service account, never a key file: +// - in GitHub Actions, CWS_ACCESS_TOKEN comes from Workload Identity Federation +// - locally, gcloud impersonates the service account for whoever is signed in +import { execSync } from 'node:child_process'; +import { existsSync, readFileSync } from 'node:fs'; +import { homedir } from 'node:os'; +import path from 'node:path'; +import { call, sleep, version, zipFor } from './common.mjs'; + +const PUBLISHER = process.env.CWS_PUBLISHER_ID || 'b7b011da-ecfd-4ec1-8d99-c600f9c31543'; +const ITEM = process.env.CWS_ITEM_ID || 'accdpphckockpflaggbplikpmaknioao'; +const SERVICE_ACCOUNT = process.env.CWS_SERVICE_ACCOUNT || 'cws-publisher@clicktrack-505800.iam.gserviceaccount.com'; +const API = `https://chromewebstore.googleapis.com/v2/publishers/${PUBLISHER}/items/${ITEM}`; +const UPLOAD = `https://chromewebstore.googleapis.com/upload/v2/publishers/${PUBLISHER}/items/${ITEM}:upload`; + +function token() { + if (process.env.CWS_ACCESS_TOKEN) return process.env.CWS_ACCESS_TOKEN; + // gcloud is often not on PATH on Windows; the quotes survive the space in "Cloud SDK". + const win = path.join(homedir(), 'AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud.cmd'); + const gcloud = process.platform === 'win32' && existsSync(win) ? `"${win}"` : 'gcloud'; + try { + return execSync(`${gcloud} auth print-access-token --impersonate-service-account=${SERVICE_ACCOUNT} --scopes=https://www.googleapis.com/auth/chromewebstore`, + { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim(); + } catch (e) { + const err = String(e.stderr || e); + if (/Reauthentication|auth login/.test(err)) throw new Error('gcloud needs signing in again: gcloud auth login'); + throw new Error(`Could not get a Web Store token: ${err.split('\n')[0]}`); + } +} + +const describe = (r) => { + if (!r?.state) return 'none'; + const v = (r.distributionChannels || []).map((c) => c.crxVersion).filter(Boolean); + return `${r.state}${v.length ? ` (v${v.join(', v')})` : ''}`; +}; + +const t = token(); +const auth = { authorization: `Bearer ${t}` }; +const status = async () => { + const { body } = await call(`${API}:fetchStatus`, { headers: auth }, 'fetchStatus'); + console.log(`chrome: published ${describe(body.publishedItemRevisionStatus)}, submitted ${describe(body.submittedItemRevisionStatus)}`); + if (body.takenDown || body.warned) console.log(`chrome: POLICY takenDown=${body.takenDown} warned=${body.warned}`); + return body; +}; + +const before = await status(); +if (process.argv.includes('--status')) process.exit(0); + +const v = await version(); +const published = (before.publishedItemRevisionStatus?.distributionChannels || []).map((c) => c.crxVersion); +if (published.includes(v)) { console.log(`chrome: v${v} is already published, nothing to do`); process.exit(0); } +if (before.submittedItemRevisionStatus?.state === 'PENDING_REVIEW') { + console.error('chrome: a submission is already waiting for review; wait for it or cancel it in the dashboard'); + process.exit(1); +} + +console.log(`chrome: uploading v${v}`); +let { body: up } = await call(UPLOAD, { method: 'POST', headers: { ...auth, 'content-type': 'application/zip' }, body: readFileSync(await zipFor('chrome')) }, 'upload'); +for (let i = 0; up.uploadState === 'UPLOAD_IN_PROGRESS' || (!up.uploadState && i === 0); i++) { + if (i > 60) throw new Error('chrome: upload still processing after two minutes; check the dashboard'); + await sleep(2000); + const { body: s } = await call(`${API}:fetchStatus`, { headers: auth }, 'fetchStatus'); + up = { ...up, uploadState: s.lastAsyncUploadState }; +} +if (up.uploadState !== 'SUCCEEDED') throw new Error(`chrome: upload did not succeed: ${JSON.stringify(up)}`); +if (up.crxVersion && up.crxVersion !== v) throw new Error(`chrome: store read v${up.crxVersion} from the zip, package.json says ${v}`); + +const { body: pub } = await call(`${API}:publish`, { + method: 'POST', headers: { ...auth, 'content-type': 'application/json' }, body: JSON.stringify({ publishType: 'DEFAULT_PUBLISH' }), +}, 'publish'); +console.log(`chrome: submitted v${v} for review (${pub.state ?? 'ok'})`); +if (pub.warningInfo) console.log(`chrome: warnings ${JSON.stringify(pub.warningInfo)}`); diff --git a/scripts/publish/common.mjs b/scripts/publish/common.mjs new file mode 100644 index 0000000..fd7a9fb --- /dev/null +++ b/scripts/publish/common.mjs @@ -0,0 +1,51 @@ +// Shared bits for the store publishers. +import { readFile, stat } from 'node:fs/promises'; +import path from 'node:path'; + +export const root = path.resolve(import.meta.dirname, '..', '..'); + +export async function version() { + return JSON.parse(await readFile(path.join(root, 'package.json'), 'utf8')).version; +} + +export async function zipFor(target) { + const v = await version(); + const file = path.join(root, 'release', `SilentBlock-${v}-${target}.zip`); + try { await stat(file); } catch { throw new Error(`${path.relative(root, file)} is missing: run npm run package first`); } + return file; +} + +// The CHANGELOG section for a version, as plain text for store "what's new" fields. +export async function releaseNotes(v) { + const cl = await readFile(path.join(root, 'CHANGELOG.md'), 'utf8'); + const start = cl.indexOf(`## [${v}]`); + if (start === -1) return `SilentBlock ${v}`; + const next = cl.indexOf('\n## [', start + 1); + return cl.slice(cl.indexOf('\n', start) + 1, next === -1 ? undefined : next).trim(); +} + +export async function call(url, init, what) { + const res = await fetch(url, init); + const text = await res.text(); + let body; + try { body = text ? JSON.parse(text) : {}; } catch { body = { raw: text }; } + if (!res.ok) { + const err = new Error(`${what}: HTTP ${res.status} ${JSON.stringify(body).slice(0, 800)}`); + err.status = res.status; + err.body = body; + throw err; + } + return { body, res }; +} + +export const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); + +// Store scripts exit 0 with a notice when their credentials are absent, so one release +// workflow can publish to whichever stores are configured. +export function need(names, store) { + const missing = names.filter((n) => !process.env[n]); + if (missing.length) { + console.log(`${store}: skipped, missing ${missing.join(', ')}`); + process.exit(0); + } +} diff --git a/scripts/publish/edge.mjs b/scripts/publish/edge.mjs new file mode 100644 index 0000000..6044932 --- /dev/null +++ b/scripts/publish/edge.mjs @@ -0,0 +1,36 @@ +// Microsoft Edge Add-ons: upload the Chrome zip (Edge runs the same build) to the draft +// submission, then publish it for certification. +// EDGE_PRODUCT_ID=... EDGE_CLIENT_ID=... EDGE_API_KEY=... node scripts/publish/edge.mjs +// Credentials: Partner Center > Microsoft Edge > Publish API. The product ID is the Partner +// Center GUID of the SilentBlock product, not the store's hhdolnhpfeeipbomjfkalbhegkakbkmo. +import { readFile } from 'node:fs/promises'; +import { call, need, releaseNotes, sleep, version, zipFor } from './common.mjs'; + +need(['EDGE_PRODUCT_ID', 'EDGE_CLIENT_ID', 'EDGE_API_KEY'], 'edge'); +const API = `https://api.addons.microsoftedge.microsoft.com/v1/products/${process.env.EDGE_PRODUCT_ID}/submissions`; +const auth = { authorization: `ApiKey ${process.env.EDGE_API_KEY}`, 'x-clientid': process.env.EDGE_CLIENT_ID }; + +// Uploads and publishes are asynchronous: the POST returns an operation id in Location. +async function waitFor(url, what) { + for (let i = 0; i < 90; i++) { + await sleep(3000); + const { body } = await call(url, { headers: auth }, `${what} status`); + if (body.status === 'Succeeded') return body; + if (body.status === 'Failed') throw new Error(`edge: ${what} failed: ${JSON.stringify(body).slice(0, 1500)}`); + } + throw new Error(`edge: ${what} still running after four minutes`); +} + +const v = await version(); +console.log(`edge: uploading v${v}`); +const { res: upRes } = await call(`${API}/draft/package`, { + method: 'POST', headers: { ...auth, 'content-type': 'application/zip' }, body: await readFile(await zipFor('chrome')), +}, 'upload'); +await waitFor(`${API}/draft/package/operations/${upRes.headers.get('location')}`, 'upload'); + +const { res: pubRes } = await call(API, { + method: 'POST', headers: { ...auth, 'content-type': 'application/json' }, + body: JSON.stringify({ notes: (await releaseNotes(v)).slice(0, 1500) }), +}, 'publish'); +await waitFor(`${API}/operations/${pubRes.headers.get('location')}`, 'publish'); +console.log(`edge: submitted v${v} for certification`); diff --git a/scripts/publish/firefox.mjs b/scripts/publish/firefox.mjs new file mode 100644 index 0000000..09e419e --- /dev/null +++ b/scripts/publish/firefox.mjs @@ -0,0 +1,64 @@ +// addons.mozilla.org: upload the Firefox build as a new listed version of silentblock@local, +// with the source archive attached (the build generates the rule and scriptlet files, so AMO +// reviewers need the source and build steps). +// AMO_JWT_ISSUER=... AMO_JWT_SECRET=... node scripts/publish/firefox.mjs +// Credentials: https://addons.mozilla.org/developers/addon/api/key/ +import { createHmac, randomUUID } from 'node:crypto'; +import { readFile } from 'node:fs/promises'; +import path from 'node:path'; +import { call, need, releaseNotes, root, sleep, version, zipFor } from './common.mjs'; + +need(['AMO_JWT_ISSUER', 'AMO_JWT_SECRET'], 'firefox'); +const API = 'https://addons.mozilla.org/api/v5'; +const GUID = 'silentblock@local'; + +// AMO wants a fresh short-lived HS256 JWT on every request. +function jwt() { + const b64 = (o) => Buffer.from(JSON.stringify(o)).toString('base64url'); + const now = Math.floor(Date.now() / 1000); + const head = b64({ alg: 'HS256', typ: 'JWT' }); + const body = b64({ iss: process.env.AMO_JWT_ISSUER, jti: randomUUID(), iat: now, exp: now + 60 }); + const sig = createHmac('sha256', process.env.AMO_JWT_SECRET).update(`${head}.${body}`).digest('base64url'); + return `JWT ${head}.${body}.${sig}`; +} + +const v = await version(); +const { body: addon } = await call(`${API}/addons/addon/${encodeURIComponent(GUID)}/`, { headers: { authorization: jwt() } }, 'addon'); +if (addon.current_version?.version === v) { console.log(`firefox: v${v} is already live, nothing to do`); process.exit(0); } +console.log(`firefox: live v${addon.current_version?.version}, uploading v${v}`); + +const form = new FormData(); +form.set('upload', new Blob([await readFile(await zipFor('firefox'))]), `SilentBlock-${v}-firefox.zip`); +form.set('channel', 'listed'); +let { body: up } = await call(`${API}/addons/upload/`, { method: 'POST', headers: { authorization: jwt() }, body: form }, 'upload'); +for (let i = 0; !up.processed; i++) { + if (i > 90) throw new Error('firefox: upload still validating after three minutes'); + await sleep(2000); + ({ body: up } = await call(`${API}/addons/upload/${up.uuid}/`, { headers: { authorization: jwt() } }, 'upload status')); +} +if (!up.valid) throw new Error(`firefox: AMO rejected the package: ${JSON.stringify(up.validation?.messages?.filter((m) => m.type === 'error') || up.validation).slice(0, 1500)}`); + +// Translated fields only work as JSON; the source archive only works as multipart. So: +// create the version as JSON, then attach the source to it. +const { body: created } = await call(`${API}/addons/addon/${encodeURIComponent(GUID)}/versions/`, { + method: 'POST', headers: { authorization: jwt(), 'content-type': 'application/json' }, + body: JSON.stringify({ upload: up.uuid, release_notes: { 'en-US': (await releaseNotes(v)).slice(0, 3000) } }), +}, 'create version'); +const src = new FormData(); +src.set('source', new Blob([await readFile(path.join(root, 'release', `SilentBlock-${v}-source.zip`))]), `SilentBlock-${v}-source.zip`); +await call(`${API}/addons/addon/${encodeURIComponent(GUID)}/versions/${created.id}/`, { + method: 'PATCH', headers: { authorization: jwt() }, body: src, +}, 'attach source'); +console.log(`firefox: submitted v${created.version} (review: ${created.file?.status || 'pending'})`); + +// Keep the AMO listing text in step with docs/store-listing.md (the one store with an API for it). +const listing = await readFile(path.join(root, 'docs/store-listing.md'), 'utf8'); +const summary = /\r?\n(.+)\r?\n/.exec(listing)?.[1]?.trim(); +const description = /\r?\n([\s\S]*?)\r?\n/.exec(listing)?.[1]?.replace(/\r\n/g, '\n').trim(); +if (summary && description) { + await call(`${API}/addons/addon/${encodeURIComponent(GUID)}/`, { + method: 'PATCH', headers: { authorization: jwt(), 'content-type': 'application/json' }, + body: JSON.stringify({ summary: { 'en-US': summary }, description: { 'en-US': description } }), + }, 'update listing'); + console.log('firefox: listing text updated from docs/store-listing.md'); +} diff --git a/scripts/store-art.mjs b/scripts/store-art.mjs new file mode 100644 index 0000000..52ed637 --- /dev/null +++ b/scripts/store-art.mjs @@ -0,0 +1,153 @@ +// Renders the store images from the real extension pages in dist/chrome. +// npm run store:art -> release/store-art/*.png +// +// The popup and options pages run with a stubbed `chrome` API so each shot shows a chosen +// state. Hostnames use example.com and example.net (reserved for documentation) so no real +// site appears in a listing. +import { mkdir, readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; +import { chromium } from '@playwright/test'; + +const root = path.resolve(import.meta.dirname, '..'); +const dist = path.join(root, 'dist/chrome'); +const out = path.join(root, 'release/store-art'); +const ORIGIN = 'https://silentblock.art'; +await mkdir(out, { recursive: true }); + +const meta = JSON.parse(await readFile(path.join(dist, 'meta.json'), 'utf8')); +const svg = async (state) => `data:image/svg+xml;base64,${(await readFile(path.join(root, `assets/icons/${state}.svg`))).toString('base64')}`; +const ICON = Object.fromEntries(await Promise.all(['idle', 'protected', 'caution', 'danger', 'paused'].map(async (s) => [s, await svg(s)]))); + +function popupState(status, host) { + return { enabled: true, version: meta.version, supported: true, hostname: host, pausedBy: null, unwall: false, status }; +} +const STATES = { + protected: popupState({ blocked: 47, popups: 0, walls: 0, danger: 0, dangerHosts: [], level: 'protected', icon: 'protected' }, 'news.example.com'), + caution: popupState({ blocked: 31, popups: 2, walls: 1, danger: 0, dangerHosts: [], level: 'caution', icon: 'caution' }, 'streams.example.net'), + danger: popupState({ blocked: 12, popups: 0, walls: 0, danger: 3, dangerHosts: ['cdn-payload.example.net'], level: 'danger', icon: 'danger' }, 'free-downloads.example.net'), +}; +const stub = (popupData) => ` + window.chrome = { + runtime: { + sendMessage: async (m) => m.type === 'popup:get' ? ${JSON.stringify(popupData)} + : m.type === 'settings:get' ? { state: { enabled: true, allowlist: ['intranet.example.com'], categories: { ads: true, privacy: true, annoyances: true, security: true }, unwallSites: ['recipes.example.com'], badge: false, statusIcon: true }, meta: ${JSON.stringify(meta)} } + : {}, + openOptionsPage() {}, + }, + tabs: { query: async () => [{ id: 1 }], reload: async () => {}, getCurrent: async () => ({ id: 1 }) }, + };`; + +const browser = await chromium.launch(); +async function capture(pagePath, { width, height, data, scale = 2, colorScheme = 'light' }) { + const ctx = await browser.newContext({ viewport: { width, height }, deviceScaleFactor: scale, colorScheme }); + await ctx.route(`${ORIGIN}/**`, async (route) => { + const rel = new URL(route.request().url()).pathname.slice(1); + const type = rel.endsWith('.html') ? 'text/html' : rel.endsWith('.css') ? 'text/css' : rel.endsWith('.js') ? 'text/javascript' : rel.endsWith('.png') ? 'image/png' : 'application/octet-stream'; + try { await route.fulfill({ body: await readFile(path.join(dist, rel)), contentType: type }); } catch { await route.fulfill({ status: 404 }); } + }); + const page = await ctx.newPage(); + if (data !== undefined) await page.addInitScript(stub(data)); + await page.goto(`${ORIGIN}/${pagePath}`); + await page.waitForTimeout(600); + const png = await page.screenshot({ fullPage: false }); + await ctx.close(); + return `data:image/png;base64,${png.toString('base64')}`; +} + +const shots = { + protected: await capture('popup/popup.html?tabId=1', { width: 300, height: 330, data: STATES.protected }), + caution: await capture('popup/popup.html?tabId=1', { width: 300, height: 330, data: STATES.caution }), + danger: await capture('popup/popup.html?tabId=1', { width: 300, height: 330, data: STATES.danger }), + options: await capture('options/options.html', { width: 760, height: 900, data: null, scale: 1.5 }), + warning: await capture(`warning/warning.html?u=${encodeURIComponent('https://free-prize-claim.example.net/login')}&h=example.net`, { width: 900, height: 620, scale: 1.5 }), +}; + +const FONT = `"Segoe UI", system-ui, -apple-system, Roboto, sans-serif`; +const frame = (w, h, inner) => `${inner}`; + +const pages = { + 'screenshot-1-blocks': frame(1280, 800, ` +
+
+ +

Ads gone.
Silently.

+

Ads, trackers, pop-ups and cookie banners are blocked before they load. No nags, no account, nothing leaves your browser.

+
+ +
`), + 'screenshot-2-status': frame(1280, 800, ` +
+

One look tells you what happened

+

The icon changes colour with every page.

+
+ ${[['idle', 'Nothing to block'], ['protected', 'Ads and trackers blocked'], ['caution', 'Pushy site handled'], ['danger', 'Dangerous site blocked'], ['paused', 'Paused']].map(([s, l]) => ` +
+ +

${l}

`).join('')} +
`), + 'screenshot-3-malware': frame(1280, 800, ` +
+
+

Stops dangerous sites before they load

+

Known malware, phishing and scam sites are checked on your device. Your browsing is never sent anywhere to be checked.

+
+ +
`), + 'screenshot-4-pushy': frame(1280, 800, ` +
+ +
+

Pop-ups and nag walls, handled

+

Pop-unders get closed, tab-unders get undone, and "turn off your ad blocker" walls come down with one click, or on their own on sites you choose.

+
+
`), + 'screenshot-5-settings': frame(1280, 800, ` +
+
+

Free. Open source. No strings.

+

More than 120,000 filters from EasyList, EasyPrivacy and uBlock Origin, bundled with each release. Pause any site with one switch.

+
+ +
`), + 'promo-small-440x280': frame(440, 280, ` +
+ +

SilentBlock

Ads gone. Silently.

+
`), + 'promo-marquee-1400x560': frame(1400, 560, ` +
+ +

SilentBlock

+

Ads, trackers, pop-ups and malware, blocked. Silently.

+ +
`), +}; + +const sizes = { 'promo-small-440x280': [440, 280], 'promo-marquee-1400x560': [1400, 560] }; +for (const [name, html] of Object.entries(pages)) { + const [w, h] = sizes[name] || [1280, 800]; + const page = await browser.newPage({ viewport: { width: w, height: h } }); + await page.setContent(html); + await page.waitForTimeout(200); + await page.screenshot({ path: path.join(out, `${name}.png`) }); + await page.close(); + console.log(`${name}.png ${w}x${h}`); +} +// Store icons: Edge wants 300x300, Chrome's listing icon is 128x128. +for (const [name, size] of [['logo-300', 300], ['icon-128', 128]]) { + const page = await browser.newPage({ viewport: { width: size, height: size } }); + await page.setContent(``); + await page.locator('img').screenshot({ path: path.join(out, `${name}.png`), omitBackground: true }); + await page.close(); + console.log(`${name}.png ${size}x${size}`); +} +await browser.close(); diff --git a/test/e2e/fixtures.mjs b/test/e2e/fixtures.mjs index 936e320..9157e4d 100644 --- a/test/e2e/fixtures.mjs +++ b/test/e2e/fixtures.mjs @@ -27,7 +27,7 @@ export const test = base.extend({ context: async ({}, use) => { const context = await chromium.launchPersistentContext('', { - channel: 'chromium', + channel: process.env.SB_CHANNEL || 'chromium', // SB_CHANNEL=msedge runs the suite in Edge headless: true, args: [ '--enable-unsafe-extension-debugging', // lets tests re-install the build over CDP diff --git a/test/firefox/smoke.mjs b/test/firefox/smoke.mjs new file mode 100644 index 0000000..fa47763 --- /dev/null +++ b/test/firefox/smoke.mjs @@ -0,0 +1,94 @@ +// Firefox smoke test: the real dist/firefox build in real Firefox (Selenium + geckodriver, +// installed as a temporary add-on). Checks the layers most likely to differ from Chrome. +// npm run test:firefox +import { Builder, until } from 'selenium-webdriver'; +import firefox from 'selenium-webdriver/firefox.js'; +import path from 'node:path'; +import { startServer } from '../e2e/server.mjs'; + +const EXT = path.resolve(import.meta.dirname, '..', '..', 'dist', 'firefox'); +const HOSTS = ['site.test', 'sb-ads.test', 'cdn-ok.test', 'sb-selftest.test', 'sb-malware.test', 'sb-phish.test']; + +const server = await startServer(); +// Pin the installed binary and stop a running Firefox from absorbing the test instance. +process.env.MOZ_NO_REMOTE = '1'; +const opts = new firefox.Options().addArguments('-headless', '-no-remote'); +// Windows: pin the installed Firefox. Elsewhere Selenium finds it (or FIREFOX_BIN). +const bin = process.env.FIREFOX_BIN || (process.platform === 'win32' ? 'C:/Program Files/Mozilla Firefox/firefox.exe' : ''); +if (bin) opts.setBinary(bin); +opts + .setPreference('network.dns.localDomains', HOSTS.join(',')) + .setPreference('dom.security.https_only_mode', false) + .setPreference('extensions.webextensions.restrictedDomains', ''); +const driver = await new Builder().forBrowser('firefox').setFirefoxOptions(opts).build(); + +const results = []; +async function check(name, fn) { + try { + await fn(); + results.push(['ok', name]); + } catch (err) { + results.push(['FAIL', name, String(err.message || err).split('\n')[0]]); + } +} +const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); +const url = (host, file) => `http://${host}:${server.port}/page/${file}`; +async function poll(fn, expected, ms = 8000) { + const end = Date.now() + ms; + let last; + while (Date.now() < end) { + last = await fn(); + if (JSON.stringify(last) === JSON.stringify(expected)) return; + await sleep(250); + } + throw new Error(`expected ${JSON.stringify(expected)}, got ${JSON.stringify(last)}`); +} + +try { + await driver.installAddon(EXT, true); + await sleep(4000); // install: rulesets enable, content scripts register + + await check('network: third-party ad blocked, other host loads', async () => { + await driver.get(url('site.test', 'basic.html')); + await poll(() => driver.executeScript('return window.__net'), { ad: 'error', ok: 'load' }); + }); + + await check('cosmetic: generic token, generic complex and site-specific hiding', async () => { + await driver.get(url('sb-selftest.test', 'basic.html')); + for (const id of ['tokenProbe', 'complexProbe', 'specificProbe']) { + await poll(() => driver.executeScript(`return getComputedStyle(document.getElementById('${id}')).display`), 'none'); + } + }); + + await check('scriptlets: set-constant and prevent-setTimeout run before page scripts', async () => { + await driver.get(url('sb-selftest.test', 'basic.html')); + await sleep(400); + await poll(() => driver.executeScript('return [window.__flag, window.__timerRan, window.__otherTimerRan]'), [true, false, true]); + }); + + await check('stubs: first-party gtag swapped for a stub that fires callbacks', async () => { + await driver.get(url('site.test', 'gtag.html')); + await poll(() => driver.executeScript('return [window.__callback, window.__ended]'), [true, true]); + }); + + await check('security: listed host gets the warning page', async () => { + await driver.get(url('sb-malware.test', 'landing.html')).catch(() => {}); + await driver.wait(until.urlContains('/warning/warning.html'), 8000); + }); + + await check('hygiene: page APIs stay native on ordinary sites', async () => { + await driver.get(url('site.test', 'hygiene.html')); + await sleep(800); + const natives = await driver.executeScript('return window.__natives'); + const bad = Object.entries(natives).filter(([, src]) => !src.includes('[native code]')).map(([k]) => k); + if (bad.length) throw new Error(`patched: ${bad.join(', ')}`); + }); +} finally { + await driver.quit(); + await server.close(); +} + +for (const r of results) console.log(r.join(' ')); +const failed = results.filter((r) => r[0] === 'FAIL').length; +console.log(`\n${results.length - failed}/${results.length} Firefox checks passed`); +process.exitCode = failed ? 1 : 0;