Skip to content

Commit

Permalink
Merge pull request #18 from abz4375/v2-gemini
Browse files Browse the repository at this point in the history
V2 Gemini Integration and UX Enhancements
  • Loading branch information
abz4375 authored Oct 13, 2024
2 parents 70cbdfe + 3d6f258 commit c6599ab
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 228 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Prompter - custom prompts
**Prompter** is an add-on for the **Prompt Storm** [`Info`](https://chrome.google.com/webstore/detail/promptstorm-chatgpt-bard/gkcdaooannhlioejchebhpkllbcackig) Chrome extension, which allows to add your own set of prompt-templates 💡 for **Google Bard** 🤖 [`Info`](https://bard.google.com)
**Prompter** is an add-on for the **Prompt Storm** [`Info`](https://chrome.google.com/webstore/detail/promptstorm-chatgpt-bard/gkcdaooannhlioejchebhpkllbcackig) Chrome extension, which allows to add your own set of prompt-templates 💡 for **Google Gemini** 🤖 [`Info`](https://Gemini.google.com)

---

Expand All @@ -10,7 +10,7 @@
- Go to `🌐 Extensions Tab` in chrome and Turn ON `🛠️ Developer Mode` (It is shown in the top right of the Extensions Tab).
- Click `📦 Load Unpacked` button on the top bar & select `📁 prompter` folder in which the repo is cloned on your local machine 💾
- ☑️ Turn ON the Extension
- **🎉 All Set!**. Enjoy the extension! It is currently available for use on `🤖 Google Bard`'s website: https://bard.google.com.
- **🎉 All Set!**. Enjoy the extension! It is currently available for use on `🤖 Google Gemini`'s website: https://gemini.google.com.

---
## **📑 User Guide :**
Expand Down Expand Up @@ -41,3 +41,5 @@
![image](https://github.com/abz4375/prompter/assets/90337098/27c8a60b-5b11-480d-83e6-b0b20cc511bc)


<!--
# v2-gemini under development -->
61 changes: 54 additions & 7 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,56 @@
(()=>{
chrome.tabs.onUpdated.addListener((tabId, tab) => {
if (tab.url && (tab.url.includes("bard.google.com") )) {
chrome.tabs.sendMessage(tabId, {
message: "yes",
function sendMessage(tabId, message) {
chrome.tabs.sendMessage(tabId, message).catch(error => {
console.error(`Error sending message to tab ${tabId}:`, error);
});
}

// Listen for installation or update of the extension
chrome.runtime.onInstalled.addListener((details) => {
if (details.reason === "install" || details.reason === "update") {
// Initialize any default settings or perform first-time setup
chrome.storage.sync.set({ prompterEnabled: true, "prompter.abz4375.isOn": true }, () => {
console.log("Prompter enabled by default and initialized");
});
}
});

// Optional: Add a context menu item to quickly toggle the prompter
if (chrome.contextMenus) {
chrome.contextMenus.create({
id: "togglePrompter",
title: "Toggle Prompter",
contexts: ["page"],
documentUrlPatterns: ["https://gemini.google.com/*"]
});

chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "togglePrompter") {
chrome.storage.sync.get("prompter.abz4375.isOn", (data) => {
const newState = !data["prompter.abz4375.isOn"];
chrome.storage.sync.set({ "prompter.abz4375.isOn": newState }, () => {
const message = newState ? "turnOn" : "turnOff";
sendMessage(tab.id, { message: message });
});
}
});
}
});
}

chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === 'complete' && tab.url.includes("gemini.google.com")) {
chrome.storage.sync.get("prompter.abz4375.isOn", (data) => {
const message = data["prompter.abz4375.isOn"] ? "turnOn" : "turnOff";
sendMessage(tabId, { message: message });
});
}
});

chrome.action.onClicked.addListener((tab) => {
chrome.storage.sync.get("prompter.abz4375.isOn", (data) => {
const newState = !data["prompter.abz4375.isOn"];
chrome.storage.sync.set({ "prompter.abz4375.isOn": newState }, () => {
const message = newState ? "turnOn" : "turnOff";
sendMessage(tab.id, { message: message });
});
})();
});
});
Loading

0 comments on commit c6599ab

Please sign in to comment.