ext
This commit is contained in:
parent
9bf42e265c
commit
ab5f16bf63
|
|
@ -0,0 +1,11 @@
|
|||
import browser from 'webextension-polyfill';
|
||||
|
||||
browser.runtime.onInstalled.addListener(() => {
|
||||
console.log('Installed!');
|
||||
});
|
||||
|
||||
browser.browserAction.onClicked.addListener((tab) => {
|
||||
if (tab.id) {
|
||||
browser.tabs.sendMessage(tab.id, { action: 'insertFolkCanvas' });
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import browser from 'webextension-polyfill';
|
||||
import { FolkShape } from '../src/folk-shape';
|
||||
|
||||
// Define the custom element with its proper tag name
|
||||
customElements.define('folk-shape', FolkShape);
|
||||
|
||||
browser.runtime.onMessage.addListener((message: any) => {
|
||||
if (message.action === 'insertFolkCanvas') {
|
||||
// Append a 'folk-canvas' div to the document body
|
||||
const folkCanvas = document.createElement('div');
|
||||
folkCanvas.className = 'folk-canvas';
|
||||
document.body.appendChild(folkCanvas);
|
||||
|
||||
// Create and add a 'folk-shape' element
|
||||
const folkShape = document.createElement('folk-shape') as FolkShape;
|
||||
folkShape.innerHTML = '<p>Hello, Folk Shape!</p>';
|
||||
folkCanvas.appendChild(folkShape);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "folk-canvas-extension",
|
||||
"version": "1.0.0",
|
||||
"manifest_version": 2,
|
||||
"background": {
|
||||
"service_worker": "background.ts"
|
||||
},
|
||||
"options_page": "options.html",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"<all_urls>"
|
||||
],
|
||||
"js": [
|
||||
"contentScript.ts"
|
||||
]
|
||||
}
|
||||
],
|
||||
"browser_action": {
|
||||
"default_title": "Add Folk Canvas"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Folk Canvas options</title>
|
||||
</head>
|
||||
<body>
|
||||
Hello options screen!
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "folk-canvas-extension",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"vite": "^6.0.3",
|
||||
"vite-plugin-web-extension": "^4.3.1",
|
||||
"webextension-polyfill": "^0.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/webextension-polyfill": "^0.12.1"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import { defineConfig } from 'vite';
|
||||
import webExtension from 'vite-plugin-web-extension';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
webExtension({
|
||||
webExtConfig: {
|
||||
startUrl: ['https://www.humprog.org/~stephen/'],
|
||||
},
|
||||
}) as any,
|
||||
],
|
||||
});
|
||||
Loading…
Reference in New Issue