mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 14:28:33 +02:00
first cut of content-scripts
This commit is contained in:
28
content-scripts/content-script.js
Normal file
28
content-scripts/content-script.js
Normal file
@@ -0,0 +1,28 @@
|
||||
chrome.runtime.onMessage.addListener(handleMessage);
|
||||
|
||||
function handleMessage(request, sender, sendResponse) {
|
||||
switch(request.name) {
|
||||
case "highlight-para":
|
||||
highlightPara();
|
||||
case "show-foo":
|
||||
showFoo();
|
||||
case "show-confirm":
|
||||
showConfirm();
|
||||
}
|
||||
}
|
||||
|
||||
function highlightPara() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
function beastNameToURL(beastName) {
|
||||
switch (beastName) {
|
||||
case "Frog":
|
||||
return chrome.extension.getURL("beasts/frog.jpg");
|
||||
case "Snake":
|
||||
return chrome.extension.getURL("beasts/snake.jpg");
|
||||
case "Turtle":
|
||||
return chrome.extension.getURL("beasts/turtle.jpg");
|
||||
}
|
||||
}
|
||||
20
content-scripts/manifest.json
Normal file
20
content-scripts/manifest.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "Content scripting",
|
||||
"version": "1.0",
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "content-scripts@mozilla.org"
|
||||
}
|
||||
},
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["https://mdn.github.io/webextensions-examples/"],
|
||||
"js": ["content-script.js"]
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user