mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-18 07:18:34 +02:00
Add example using MV3 userScripts API (#576)
This commit is contained in:
20
userScripts-mv3/userscript_examples/unprivileged.user.js
Normal file
20
userScripts-mv3/userscript_examples/unprivileged.user.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ==UserScript==
|
||||
// @name Demo of unprivileged user script
|
||||
// @description Show dialog on MDN and every URL starting with "https://example".
|
||||
// @match https://developer.mozilla.org/*
|
||||
// @include https://example*
|
||||
// @exclude-match https://example.com/display_userscript_result*
|
||||
// @grant none
|
||||
// @version 1.2.3
|
||||
// ==/UserScript==
|
||||
|
||||
// To test:
|
||||
// 1. Visit https://example.com/ or https://developer.mozilla.org/
|
||||
// 2. Confirm that a dialog shows up.
|
||||
|
||||
alert(`This is a demo of a user script, running at ${document.URL}.`);
|
||||
|
||||
// This user script should not get access to privileged APIs.
|
||||
if (typeof GM_info !== "undefined") {
|
||||
alert("Unexpectedly, GM_info is defined...?");
|
||||
}
|
||||
Reference in New Issue
Block a user