Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instructions for testing scriptlet #172

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

Conversation

ShivanKaul
Copy link
Collaborator

No description provided.

README.md Outdated
## Shipping and locally testing a new scriptlet

1. In your local copy of https://github.com/brave/adblock-resources/, create a new git branch and add a new scriptlet using the instructions at the top of this README. You will manually add a new resource under `resources/`, and the building commands will auto-generate `dist/resources.json` and `metadata.json`. Here's a simple example: https://github.com/brave/adblock-resources/pull/131. Push your branch and create a new PR. Don't merge in yet.
2. You will also need an adblock rule to actually insert your scriptlet on a page. This will mean modifying a filter list that Brave ships. Go to your local copy of https://github.com/brave/adblock-lists. Create a new git branch and make your changes. This might look like a scriptlet injection for a site like `google.*##+js(brave-google-fix)` or something in `brave-specific.txt`. Here's a simple example: https://github.com/brave/adblock-lists/pull/1310. Create a new PR by pushing to a new remote branch. Don't merge in yet.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth mentioning that the rule can be added to brave://settings/shields/filters instead, as a simpler alternative?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh can it? I wasn't aware. I thought you couldn't insert scriptlets via custom filters.

README.md Outdated
1. In your local copy of https://github.com/brave/adblock-resources/, create a new git branch and add a new scriptlet using the instructions at the top of this README. You will manually add a new resource under `resources/`, and the building commands will auto-generate `dist/resources.json` and `metadata.json`. Here's a simple example: https://github.com/brave/adblock-resources/pull/131. Push your branch and create a new PR. Don't merge in yet.
2. You will also need an adblock rule to actually insert your scriptlet on a page. This will mean modifying a filter list that Brave ships. Go to your local copy of https://github.com/brave/adblock-lists. Create a new git branch and make your changes. This might look like a scriptlet injection for a site like `google.*##+js(brave-google-fix)` or something in `brave-specific.txt`. Here's a simple example: https://github.com/brave/adblock-lists/pull/1310. Create a new PR by pushing to a new remote branch. Don't merge in yet.
3. Now, we're ready to test changes locally. Go back to your adblock-resources git branch, and create another git branch. This git branch will be exclusively for testing. Modify `filter_lists/list_catalog.json` to point to the `https://raw.githubusercontent.com` URL for your new adblock-lists branch (that you have a PR up for) that you create in Step 2. For instance, if you're modifying `brave-specific.txt`, modify the `filter_lists/list_catalog.json` entry for "Brave Specific" to point to https://raw.githubusercontent.com/brave/adblock-lists/YOUR_BRANCH_NAME_FROM_STEP_2/brave-lists/brave-specific.txt. Push to a new remote branch - you don't need to create a PR for this branch since it will be purely for testing.
4. Now, go to your local copy of https://github.com/brave/brave-core-crx-packager. Change the `lib/adBlockRustUtils.js` file to point to your adblock-resources branches, not the `master` branches. You'll change the `braveResourcesUrl` variable to point to `https://raw.githubusercontent.com/brave/adblock-resources/YOUR_BRANCH_NAME_FROM_STEP_1/dist/resources.json` and `listCatalogUrl` to point to `https://raw.githubusercontent.com/brave/adblock-resources/YOUR_BRANCH_NAME_FROM_STEP_3/filter_lists/list_catalog.json`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor, but if we can [brave-core-crx-packager](https://github.com/brave/brave-core-crx-packager) the links, that might make it easier to read this wall of instructions 😅


1. In your local copy of [adblock-resources](https://github.com/brave/adblock-resources/), create a new git branch and add a new scriptlet using the instructions at the top of this README. You will manually add a new resource under `resources/`, and the building commands will auto-generate `dist/resources.json` and `metadata.json`. Here's a [simple example](https://github.com/brave/adblock-resources/pull/131). Push your branch and create a new PR. Don't merge in yet.
2. You will also need an adblock rule to actually insert your scriptlet on a page. This will mean modifying a filter list that Brave ships. Go to your local copy of [adblock-lists](https://github.com/brave/adblock-lists). Create a new git branch and make your changes. This might look like a scriptlet injection for a site like `google.*##+js(brave-google-fix)` or something in `brave-specific.txt`. Here's a [simple example](https://github.com/brave/adblock-lists/pull/1310). Create a new PR by pushing to a new remote branch. Don't merge in yet.
3. Now, we're ready to test changes locally. Go back to your `adblock-resources` git branch, and create another git branch. This git branch will be exclusively for testing. Modify `filter_lists/list_catalog.json` to point to the `https://raw.githubusercontent.com` URL for your new adblock-lists branch that you created in Step 2. For instance, if you're modifying `brave-specific.txt`, modify the `filter_lists/list_catalog.json` entry for "Brave Specific" to point to https://raw.githubusercontent.com/brave/adblock-lists/YOUR_BRANCH_NAME_FROM_STEP_2/brave-lists/brave-specific.txt. Push to a new remote branch - you don't need to create a PR for this branch since it will be purely for testing.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest mentioning here that you need to run npm run addScriptlet to generate the new resources.json file and commit it before pushing to the new remote branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants