高度な使い方
ルール
オプションページや「このサイトをブロックする」ダイアログでルールを編集できます。

マッチパターン
マッチパターンはワイルドカードを含む URL のようなものです。詳細は MDN web docs を参照してください。
有効なマッチパターンの例:
| パターン | マッチする例 |
|---|---|
*://example.com/*( example.com 上の URL) |
http://example.com/https://example.com/hoge |
*://*.example.net/*( example.net またはそのサブドメイン上の URL) |
http://example.net/https://foo.example.net/hoge |
*://example.org/hoge/*( example.org 上の URL で、パスが /hoge/ で始まるもの) |
http://example.org/hoge/fuga.html |
無効なマッチパターンの例:
| 無効なパターン | 理由 |
|---|---|
*://www.qinterest.*/ |
* が先頭以外に置かれています。 |
式
式を使ってルールを書くことができます。
変数
現在、url と title が使用できます。
# URL に "example" を含む検索結果
url *= "example"
# タイトルが "Something" で始まる検索結果
title ^= "Something"URL の一部である scheme、host、path も使用できます。
# スキームが HTTP の検索結果
scheme="http"
# ホスト名が ".example.com" で終わる検索結果
host $= ".example.com"
# パスが "blah" を含む検索結果 (大文字小文字を区別しない)
path*="blah"iさらに、検索結果ページ自体のプロパティ $site と $category が使用できます。
# Google 検索で YouTube をブロックする
$site="google" & host="youtube.com"
# 画像検索で Amazon.com をブロックする
$category = "images" & host = "www.amazon.com"文字列マッチ
文字列マッチは CSS の属性セレクター に似ています。
# タイトルが "Example Domain" と一致
title = "Example Domain"
# タイトルが "Example" で始まる
title ^= "Example"
# タイトルが "Domain" で終わる
title $= "Domain"
# タイトルが "ple Dom" を含む
title *= "ple Dom"大文字小文字を区別しない比較を行うには、i を追加します。
# タイトルが "domain" で終わる (大文字小文字を区別しない)
title $= "domain" i正規表現
正規表現を使って柔軟に式を書くことができます。
# URL に "example.net" または "example.org" を含む
url =~ /example\.(net|org)/
# "=~" は省略可能
url/example\.(net|org)/
# "url" も省略可能
/example\.(net|org)/
# タイトルが "example domain" を含む (大文字小文字を区別しない)
title =~ /example domain/i正規表現は JavaScript の正規表現リテラル (/example\.(net|org)/) の形で記述する必要があります。
有効な正規表現の例:
| 正規表現 | マッチする例 |
|---|---|
/^https:\/\/www\.qinterest\./( https://www.qinterest. で始まる URL) |
https://www.qinterest.com/https://www.qinterest.jp/hoge |
/^https?:\/\/([^/.]+\.)*?xn--/(国際化ドメイン名を含む URL) |
http://例.テスト/ |
無効な正規表現の例:
| 無効な正規表現 | 理由 |
|---|---|
^https?:\/\/example\.com\/ |
/ で囲まれていません。 |
/^https?://example\.com// |
正規表現内の / がエスケープされていません。 |
論理演算子
論理否定 (!)、論理積 (&)、論理和 (|) が使用できます。
# HTTPS 以外のスキームをブロック
!scheme="https"
# 画像検索で Amazon.com をブロック
$category = "images" & host = "www.amazon.com"
# タイトルが "example" または "domain" を含む (大文字小文字を区別しない)
title *= "example" i | title *= "domain" iマッチパターンと式の併用
マッチパターンの後に @if(式) を続けることができます。
# 画像検索で Amazon.com をブロックする
*://*.amazon.com/* @if($category="images")ブロック解除ルール
マッチパターンまたは正規表現の前に @ をつけると、そのサイトをブロックしないという意味になります。
これは購読したルールセットによるブロックを解除するのに便利です。例えば、もし http://example.com/ が購読中のルールセットによりブロックされていれば、ルール @*://example.com/* でそれを解除することができます。
ハイライトルール
マッチパターンまたは正規表現の前に @N (N=1,2,3,…) をつけると、そのサイトをハイライトするという意味になります。
例えば、@1*://example.com/* で example.com をハイライトすることができます。

デフォルトでは、@1 (青) のみが使用できます。色を変更または追加するには、オプションページの「外観」セクションを参照してください。
コメント
コメントは # で始まります。ルールとして解釈できない行は全て実質的にコメントですが、 # で始まるコメントには 2 つの利点があります。
#で始まるコメントは、将来新しいシンタックスが追加されても、コメントであることが保証されます。#で始まるコメントは、ルールの後に置くことができます。
# example.com またはそのサブドメイン上のサイトをブロックする
*://*.example.com/*
/example\.(net|org)/ # example.net または example.org を URL に含むサイトをブロックするその他の検索エンジン
この拡張機能は Bing、Brave、DuckDuckGo、Ecosia、SearXNG、Startpage.com、Yahoo! JAPAN、Yandex をサポートしています。この機能はデフォルトで無効ですが、オプションページで有効にすることができます。


同期
You can synchronize rulesets and other settings across devices using Google Drive, Dropbox, OneDrive, a WebDAV server, or the sync feature built into your browser.
To turn on sync, click the “Turn on sync” button in the options page and select a sync method.

Follow the instructions in the dialog to authenticate. Once authentication succeeds, your settings will be regularly synchronized.
You can choose what to sync in the “What to sync” list. The “Initial sync” option in the dialog determines which version is kept when the local and remote settings differ at the first sync.
Google ドライブ
Firefox またはその派生ブラウザでは、https://www.googleapis.com へのアクセスを許可する必要があります。
ルールセットは Google ドライブのアプリケーションデータフォルダーに保存されます。このフォルダーを見ることはできませんが、設定ページから削除することは可能です。
Dropbox
ルールセットは Dropbox の /アプリ/uBlacklist/ フォルダーに保存されます。フォルダーの名前は言語によって異なる場合があります。
OneDrive
You will be required to permit access to https://login.microsoftonline.com.
The ruleset is saved in the /Apps/uBlacklist/ folder on your OneDrive.
OneDrive is not available in Safari.
WebDAV
Enter the URL of a folder on your WebDAV server, along with the username and password. You will be required to permit access to the URL.
The ruleset is saved in the specified folder, which is created if it does not exist.
Browser
This method uses the sync feature built into your browser, so sync timing depends on the browser. The browser’s sync storage has a size limit, so if your ruleset is too large, reduce the number of rules or switch to another sync method.
Browser sync is not available in Safari or Firefox for Android.
購読
公開されたルールセットを購読することができます。既知の公開ルールセットは、 Subscriptions ページで見つけることができます。
購読を追加するには、オプションページの「購読を追加する」ボタンを押して、名前と URL を入力します。その URL へのアクセス許可を求められる場合があります。

購読を表示、更新、削除することができます。

購読を公開する
ルールセットを購読として公開するには、UTF-8 でエンコードしたルールセットファイルを適切な HTTP(S) サーバーに配置し、URL を公開します。
ルールセットには YAML frontmatter を書くことができます。name 変数を設定することが推奨されます。
---
name: あなたのルールセットの名前
---
*://*.example.com/*購読を GitHub で公開するのはよい考えです。Raw URL (例えば https://raw.githubusercontent.com/iorate/ublacklist-example-subscription/master/uBlacklist.txt) を公開してください。

購読リンク
注記
この機能は v8.11.0 以降で利用可能です。ユーザーは拡張機能のオプションページで「ルールセット購読リンクを有効にする」をオンにする必要があります。
購読を簡単に共有するために、以下の形式で購読リンクを作成できます。
https://ublacklist.github.io/rulesets/subscribe?url=<url-encoded-url><url-encoded-url> は URL エンコードされたルールセットの URL です。このリンクをクリックすると、拡張機能のオプションページに移動し、購読が事前入力されるため、簡単に購読できます。
例えば、ルールセットが以下にホストされている場合:
https://raw.githubusercontent.com/username/repository/master/ublacklist.txt購読リンクは以下のようになります:
https://ublacklist.github.io/rulesets/subscribe?url=https%3A%2F%2Fraw.githubusercontent.com%2Fusername%2Frepository%2Fmaster%2Fublacklist.txt