-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from abz4375/v2-gemini
V2 Gemini Integration and UX Enhancements
- Loading branch information
Showing
7 changed files
with
329 additions
and
228 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
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 |
---|---|---|
@@ -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 }); | ||
}); | ||
})(); | ||
}); | ||
}); |
Oops, something went wrong.