Skip to content

Instructions for testing scriptlet#172

Open
ShivanKaul wants to merge 3 commits into
masterfrom
add-instructions-to-test-scriptlet
Open

Instructions for testing scriptlet#172
ShivanKaul wants to merge 3 commits into
masterfrom
add-instructions-to-test-scriptlet

Conversation

@ShivanKaul

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread 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
Copy Markdown
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
Copy Markdown
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.

Comment thread 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
Copy Markdown
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 😅

Comment thread README.md

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
Copy Markdown
Contributor

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