Files
Rob Wu 06330a69c2 Add declarativeNetRequest (DNR) + MV3 examples (#526)
These examples are designed to be cross-browser compatible.
In particular, these extensions do not use `background` because there is
currently no single manifest that can support both Firefox and Chrome,
due to the lack of event page support in Chrome, and the lack of service
worker support in Firefox.

Three examples demonstrating the use of the declarativeNetRequest API:
- dnr-block-only: One minimal example demonstrating the use of static
  DNR rules to block requests.
- dnr-redirect-url: One minimal example demonstrating the use of static
  DNR rules to redirect requests.
- dnr-dynamic-with-options: A generic example demonstrating how host
  permissions can be requested and free forms to input DNR rules.
2023-05-17 18:13:55 +02:00

37 lines
1.8 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width"> <!-- mobile-friendly -->
<link rel="stylesheet" type="text/css" href="options.css">
</head>
<body>
<fieldset class="input-and-buttons">
<legend>Allowed host permissions</legend>
Specify the JSON-formatted list of allowed host permissions (documentation: <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/Permissions#origins">origins</a>).
<textarea id="input-host-permissions"></textarea>
<button id="grant-host-permissions">Grant host permissions</button>
<button id="reset-host-permissions">Reset host permissions</button>
<output id="status-host-permissions"></output>
</fieldset>
<fieldset class="input-and-buttons">
<legend>Dynamic declarativeNetRequest rules (persists across restarts)</legend>
Specify the JSON-formatted list of dynamic DNR rules (documentation: <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rules">declarativeNetRequest rules</a>).
<textarea id="input-dynamic-rules"></textarea>
<button id="save-dynamic-rules">Save</button>
<output id="status-dynamic-rules"></output>
</fieldset>
<fieldset class="input-and-buttons">
<legend>Session-scoped declarativeNetRequest rules (cleared on extension unload/reload)</legend>
Specify the JSON-formatted list of session DNR rules (documentation: <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/declarativeNetRequest#rules">declarativeNetRequest rules</a>).
<textarea id="input-session-rules"></textarea>
<button id="save-session-rules">Save</button>
<output id="status-session-rules"></output>
</fieldset>
<script src="options.js"></script>
</body>
</html>