diff --git a/blend and run/background.js b/blend and run/background.js new file mode 100644 index 00000000..7e1cf808 --- /dev/null +++ b/blend and run/background.js @@ -0,0 +1,40 @@ +chrome.runtime.onInstalled.addListener(() => { + chrome.contextMenus.create({ + id: "blendAndRun", + title: "Blend and Run", + contexts: ["selection", "page"] + }); + + chrome.contextMenus.create({ + id: "copyText", + title: "Copy Selected Text", + parentId: "blendAndRun", + contexts: ["selection"] + }); + + chrome.contextMenus.create({ + id: "runScript", + title: "Run Custom Script", + parentId: "blendAndRun", + contexts: ["page"] + }); +}); + +chrome.contextMenus.onClicked.addListener((info, tab) => { + if (info.menuItemId === "copyText" && info.selectionText) { + copyToClipboard(info.selectionText); + } else if (info.menuItemId === "runScript") { + chrome.scripting.executeScript({ + target: {tabId: tab.id}, + files: ['customScript.js'] + }); + } +}); + +function copyToClipboard(text) { + navigator.clipboard.writeText(text).then(() => { + alert('Text copied to clipboard!'); + }, (err) => { + console.error('Failed to copy text: ', err); + }); +} diff --git a/blend and run/custom.js b/blend and run/custom.js new file mode 100644 index 00000000..7d6e6bec --- /dev/null +++ b/blend and run/custom.js @@ -0,0 +1,2 @@ +// Example custom script +alert('Custom Script Executed!'); diff --git a/blend and run/images/icon128.png b/blend and run/images/icon128.png new file mode 100644 index 00000000..1841cbdd Binary files /dev/null and b/blend and run/images/icon128.png differ diff --git a/blend and run/images/icon16.png b/blend and run/images/icon16.png new file mode 100644 index 00000000..c5fb2bc8 Binary files /dev/null and b/blend and run/images/icon16.png differ diff --git a/blend and run/images/icon48.png b/blend and run/images/icon48.png new file mode 100644 index 00000000..6902732d Binary files /dev/null and b/blend and run/images/icon48.png differ diff --git a/blend and run/manifest.json b/blend and run/manifest.json new file mode 100644 index 00000000..aaf75d79 --- /dev/null +++ b/blend and run/manifest.json @@ -0,0 +1,28 @@ +{ + "manifest_version": 3, + "name": "Blend and Run Extension", + "version": "1.0", + "description": "An extension that blends multiple utilities and allows running custom scripts.", + "permissions": [ + "activeTab", + "scripting", + "storage", + "contextMenus" + ], + "background": { + "service_worker": "background.js" + }, + "action": { + "default_popup": "popup.html", + "default_icon": { + "16": "images/icon16.png", + "48": "images/icon48.png", + "128": "images/icon128.png" + } + }, + "icons": { + "16": "images/icon16.png", + "48": "images/icon48.png", + "128": "images/icon128.png" + } +} diff --git a/blend and run/popup.html b/blend and run/popup.html new file mode 100644 index 00000000..6d249c85 --- /dev/null +++ b/blend and run/popup.html @@ -0,0 +1,18 @@ + + + + Blend and Run + + + + + + + +