Add example using MV3 userScripts API (#576)

This commit is contained in:
Rob Wu
2025-02-24 00:13:40 +01:00
committed by GitHub
parent 2ecc2198b3
commit d1116e32e9
13 changed files with 918 additions and 2 deletions

View 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...?");
}