-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4748ad5
commit 895d8b7
Showing
7 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Example custom script | ||
alert('Custom Script Executed!'); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Blend and Run</title> | ||
<style> | ||
button { | ||
font-size: 14px; | ||
padding: 10px; | ||
margin: 5px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<button id="copy-btn">Copy Selected Text</button> | ||
<button id="run-script-btn">Run Custom Script</button> | ||
<script src="popup.js"></script> | ||
</body> | ||
</html> |